Getting started with Kubernetes on IBM Bluemix : The CLI Way

This blog post helps you in getting started with Kubernetes on IBM Bluemix via CLI. After a post on how to get started with Docker Containers on Bluemix, the next destination was to play with container orchestration on Bluemix.

IBM Bluemix Container Service

Why do we need container orchestration?

As the use of containers increases and organizations deploy them more widely, the need for tools to manage containers across the infrastructure also increases. Orchestrating a cluster of containers is a competitive and rapidly evolving area, and many tools exist offering various feature sets.

Kubernetes is one of the many container orchestration tools available out there.

Why Kubernetes on Bluemix?

Earlier this year, IBM announced the integration of advanced container orchestration of Kubernetes into the IBM Bluemix Container Service. You can create your first Kubernetes cluster within minutes and flexibly manage dedicated cluster resources for both stateless (microservice) applications and stateful workloads. With a single Kubernetes dashboard,

  • Manage security compliance throughout your DevOps pipeline by automatically scanning both Docker images and live containers for known vulnerabilities and the presence of malware.
  • Verify appropriate container settings and application configurations.
  • Review risk ratings and match container service policies to those of your organization.
  • Deploy your application with auto-scaling policies to handle fluctuations in workloads and auto-recovery for higher availability.
  • Leverage the value of the IBM Bluemix platform by easily binding to other services, which bring cognitive and analytics capabilities to your application.

Setting Bluemix CLI for Kubernetes

Refer this link for the initial setup and login. Additionally, setup kubernetes CLI on your local machine to run kubectl commands; Running Kubernetes locally via Minikube

Run the below commands to install Bluemix Container-registry and Container-service plugins.

Login before you start,

Creating and configuring your first cluster on Bluemix

Firstly, Initialise Bluemix container service by running on the below command


Let’s start with a lite cluster

To check the list of clusters, run the below command

Run the below commands to set the environment variable and also to download the Kubernetes configuration files

When the download of the configuration files is finished, a command is displayed that you can use to set the path to the local Kubernetes configuration file as an environment variable.

To verify whether the KUBECONFIG environment variable is set properly or not, run the below command (This is for OSX)

Also, run the below command to check the current context; Should be set to your cluster you created on IBM Cloud

Point to any folder with a Dockerfile and run the below command

Example <tag> values – latest, 1 etc.,

The build command results in a new image that you can start using, docker run just like any other image. Each line in the Dockerfile will correspond to a layer in the images’ commit history.

For a sample, Docker Project and DockerFile, refer this link.

Run the below command to push the image to your Bluemix private registry,

Run the below command to list the images available in your private registry on Bluemix,

Note: Remove –include-ibm to see images under your namespace.

This should list the images available in your registry as shown below

Create a deployment and expose the service

To create a deployment, run the below command

List all your deployments anytime using the command below

Run the below command to create a service

Note: Use –type=LoadBalancer to accept external traffic.

You need an IP address and a port number to access your app.

For IP address, run the command below

You should see below response

Public IP is the one you require.

The port you mentioned while creating the deployment above is not the actual port; You need NodePort

For NodePort, run the below command

You should see the below response,

Pointing to External_IP: NodePort, you should show the desired output.

For logs, you need the pod name

Once you have the pod details, run the below command on your terminal to view the logs

Happy Learning!!

Polyglot & Pragmatic Programmer • Developer Advocate, IBM Cloud • Microsoft MVP • Intel software Innovator • DZone MVB
(Visited 117 times, 1 visits today)

You may also like...

Show Buttons
Hide Buttons