Over a million developers have joined DZone.

Kubernetes From IBM Bluemix Container Service

DZone's Guide to

Kubernetes From IBM Bluemix Container Service

Learn to set up clusters using Kubernetes on IBM Bluemix, expose services, and manage the logs with the following steps.

Free Resource

How to Transform Your Business in the Digital Age: Learn how organizations are re-architecting their integration strategy with data-driven app integration for true digital transformation.

This post helps you get 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.

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 to this link for the initial setup and login. Additionally, setup Kubernetes CLI on your local machine to run kubectl commands, tunning Kubernetes locally via Minikube.

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

bx plugin install container-registry -r Bluemix-bx
bx plugin install container-service -r Bluemix-bx

Login before you start:

bx login

Creating and Configuring Your First Cluster on Bluemix

First, initialize the Bluemix container service by running the below command:

bx cs init


Using default API endpoint: https://us-south.containers.bluemix.net


Let's start with a lite cluster:

bx cs cluster-create --name {cluster_name}

To check the list of clusters, run the below command:

bx cs clusters

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

bx cs cluster-config {cluster_name or ID}

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 (for OSX):


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

kubectl config current-context

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

docker build -t registry.ng.bluemix.net/<namespace>/<image_name>:<tag>  .

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 image's commit history.

For a sample Docker project and DockerFile, refer to this link.

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

docker push registry.ng.bluemix.net/<namespace>/<image_name>:<tag>

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

bx cr images --include-ibm

Note: Remove --include-ibm to see images under your namespace. This should list the images available in your registry, as shown below:

Listing images...

REPOSITORY                                                     NAMESPACE   TAG            DIGEST         CREATED         SIZE     VULNERABILITY STATUS   

registry.ng.bluemix.net/ibm-backup-restore                                 latest         bce829551e9a   2 months ago    203 MB   Vulnerable   

registry.ng.bluemix.net/ibm-integration-bus                                latest         d614af281959   2 weeks ago     694 MB   Vulnerable   

registry.ng.bluemix.net/ibm-mq                                             latest         ed28839a5c76   1 week ago      780 MB   OK   

registry.ng.bluemix.net/ibm-node-strong-pm                                 latest         ae3138081fa6   1 month ago     281 MB   Vulnerable   

registry.ng.bluemix.net/ibm-websphere-extreme-scale                        latest         6b458b36f95d   1 week ago      463 MB   OK   

registry.ng.bluemix.net/ibm_wa_agent                                       latest         bc818ce92d11   1 month ago     435 MB   Vulnerable   

registry.ng.bluemix.net/ibmliberty                                         javaee7        6f5ef08d5376   2 months ago    317 MB   Vulnerable   

registry.ng.bluemix.net/ibmliberty                                         latest         6f5ef08d5376   2 months ago    317 MB   Vulnerable   

registry.ng.bluemix.net/ibmliberty                                         microProfile   a6f9cbfeaa95   2 months ago    241 MB   Vulnerable   

registry.ng.bluemix.net/ibmliberty                                         webProfile6    26efdf1f962c   2 months ago    271 MB   Vulnerable   

registry.ng.bluemix.net/ibmliberty                                         webProfile7    e9849596c72c   2 months ago    279 MB   Vulnerable   

registry.ng.bluemix.net/ibmnode                                            latest         329c7a70282d   1 week ago      192 MB   OK   

registry.ng.bluemix.net/ibmnode                                            v1.1           866bede31a01   1 week ago      180 MB   OK   

registry.ng.bluemix.net/ibmnode                                            v1.2           0881af5d9188   1 week ago      186 MB   OK   

registry.ng.bluemix.net/ibmnode                                            v4             dd7bb74fe76d   1 week ago      192 MB   OK   

registry.ng.bluemix.net/mods15/bluechatter                     mods15      latest         2fc2265a9a93   1 hour ago      216 MB   Vulnerable   

registry.ng.bluemix.net/mods15/docker-openwhisk-node-console   mods15      1              9de7a52cc8ed   1 day ago       271 MB   Vulnerable   

registry.ng.bluemix.net/mods15/hello-world                     mods15      latest         30c3326e99f1   4 months ago    971 B    OK   

registry.ng.bluemix.net/mods15/mf-analytics                    mods15      latest         1cddd191f00f   7 months ago    808 MB   Vulnerable   

registry.ng.bluemix.net/mods15/mf-server                       mods15      latest         c765a3767146   10 months ago   1.1 GB   Vulnerable   

registry.ng.bluemix.net/mods15/node-openwhisk-docker-console   mods15      latest         96d709515c73   1 month ago     266 MB   Vulnerable   


Create a Deployment and Expose the Service

To create a deployment, run the below command:

kubectl run <deployment_name> --image=registry.ng.bluemix.net/<namespace>/<image_name>:<tag>

List all your deployments anytime using the command below:

kubectl get deployments

Run the below command to create a service:

kubectl expose deployment <deployment_name_created_above> --type=NodePort --name=<service_name>  --port=<port_number>

Note: Use --type=LoadBalancer to accept external traffic. You need an IP address and a port number to access your app. For the IP address, run the command below:

bx cs workers <cluster_name>

You should see the below response:

Listing cluster workers...


ID                                                 Public IP        Private IP    Machine Type   State    Status   

kube-xxxx                                          xxx.xxx.xxx.xx   yy.yy.yy.yy    free/paid     normal   Ready

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:

kubectl describe service <service_name>

You should see the below response:

Name: donc

Namespace: default

Labels: run=donc

Annotations: <none>

Selector: run=donc

Type: LoadBalancer


Port: <unset> 32100/TCP

NodePort: <unset> 30007/TCP


Session Affinity: None


Pointing to External_IP: NodePort, you should show the desired output. For logs, you need the pod name:

kubectl get pods

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

kubectl logs <pod_name>

Happy learning!

Build and deploy API integrations 7x faster. Try the Cloud Elements 100% RESTful platform for 30 days free. Access your trial here.

kubernetes ,bluemix ,container orchestration ,ibm bluemix ,integration ,containers

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}