Skill Level: Any Skill Level

This article discusses steps to deploy IBM containers which earlier deployed as Independent Images in Kubernetes cluster framework recently made available on Bluemix. This article is in continuation with my previous series on IBM containers.


Knowledge of concepts of dockers, IBM Container Commandline and kubernetes.


  1. Introduction

    Kubenetes is a Open Source container cluster management tool. IBM® Bluemix® Container Service offers several options to configure and customize Kubernetes cluster to meet the functional and non-functional requirements of your organization. IBM has replaced its previous architecture of container groups with that of kubernetes to achieve high availability. Apart from introducing kubernetes there has been changes in bluemix commandline as well. IBM has moved from IBM Container (ic) command line to Container Registry (cr) commandline to upload custom docker images to bluemix private registry. IBM has also introduced Container Service (cs) command which would help in creating and managing kubernetes cluster from commandline. The login command has been appended with SSO switch for two factor authentication.

    This article is an extension to my previous article on IBM containers which show cased Implementation Wildfly as container image on IBM Bluemix. The same is further extended with Kubernetes. This article specifically deals with Bluemix Lite deployment of Kubernetes.

  2. Bluemix Commandline Installation and Configuration

    It is assumed that one has already installed Bluemix (bx) commandline in his operating system. This can be done using binary installer available on Bluemix page.  Once that is done one needs to add plugins to this commandline environment. Login into Bluemix region


    OOnce we have logged in into the Organization one can go ahead and install respective plugins




    Once the Container Service (cs) plugin is installed one can test this using init command.



    Installing Container Registry plugin.


    Container Registry (cr) plugin can be tested using login command. This is essential pre-requisite to upload docker images to IBM Bluemix private registry.


    Add a namespace in Bluemix private registry if previously not done


    Download and Install kubectl commandline in your operating system path. On windows one can copy this command line in System32 folder of Windows directory.

    Note: After you have created the cluster it is mandatory to run the below command to for kubectl command to work properly.

    bx cs cluster-config <<CLUSTER_NAME>>



  3. Kubernetes Basic Concepts

    I will not discuss all the concepts here and will adhare to only those which are required by developer to create a YAML file.

    Pods: are the smallest deployable unit of also referred to as docker containers.

    Services: are an abstaction for a logical sets of pods.

    Labels: are key/value pairs attached to objects used for identification.

    Replica Sets: ensures specific number of pods are running.



    Applications within a pod also have access to shared volumes, which are defined as part of a pod and are made available to be mounted into each application’s filesystem. In terms of Docker constructs, a pod is modelled as a group of Docker containers with shared namespaces and shared volumes.

    The Kubernetes master in IBM Bluemix for each cluster is managed by IBM, is highly available, and includes IBM® Bluemix® Container Service security settings that ensure security compliance and secure communication to and from the worker nodes. Updates are performed by IBM as required. The dedicated Kubernetes master centrally controls and monitors all Kubernetes resources in the cluster. Based on the deployment requirements and capacity in the cluster, the Kubernetes master automatically schedules your containerized apps to deploy across available worker nodes.

    Bluemix Lite deployment make use of NodePort where in when you expose your app by creating a Kubernetes service of type NodePort, a NodePort in the range of 30000 – 32767 and an internal cluster IP address is assigned to the service. The NodePort service serves as the external entrypoint for incoming requests for your app. The assigned NodePort is publicly exposed in the kubeproxy settings of each worker node in the cluster. Every worker node starts listening on the assigned NodePort for incoming requests for the service. To access the service from the internet, you can use the public IP address of any worker node that was assigned during cluster creation and the NodePort in the format <ip_address>:<nodeport>. 




    When a public request arrives at the NodePort service, it is automatically forwarded to the internal cluster IP of the service and further forwarded from the kubeproxy component to the private IP address of the pod where the app is deployed. The cluster IP is accessible inside the cluster only. If you have multiple replicas of your app running in different pods, the kubeproxy component load balances incoming requests across all replicas

  4. Settings Kubernetes in IBM Bluemix

    Click on Kubernetes cluster option in Catalog of your Bluemix account



    and wait for few minutes before you see Ready in green. Click on Access link on the left to see the instructions to access cluster from commandline.




    Download/build docker image which you want to deploy on Kubernetes on Bluemix. In this example I will be showing deployment of Wildfly Server.



    Check in your local docker registry weather the image has been downloaded successfully.


    Upload this Image in local bluemix docker registry. For this one needs to tag this Image with bluemix registry URL.


    Now upload the image to bluemix local registry



    check weather the Image is uploaded successfully in your private registry in Bluemix



  5. Writing a YAML file

    Download any existing standard Pod and Service YAML and modify it as per your reuquirement. Give reference to your private registry URL of docker image that you have just uploaded in previous step.



    Services YAML



    Run kubectl command on the yml of both the files that you have just created.






    Since we have already logged in into Bluemix and initiated container service (cs) using init command, the kubectl command will directly create pod in Bluemix kubernets. Check weather POD is created using below command.




    Verify the details of private IP by the below command.



    All pods that are deployed to a worker node are also assigned a private IP address. Pods are assigned an IP in the private address range and are routed between worker nodes only. To avoid conflicts, do not use this IP range on any nodes that will communicate with your worker nodes. Worker nodes and pods can securely communicate on the private network by using the private IP addresses. However, when a pod crashes or a worker node needs to be re-created, a new private IP address is assigned.


    Enable console and check the logs.




    Open the URL in browser and check logs to verify integrity of Installation


    On clicking the Elipsis button on the extreme right, the logs will be opened in a new tab in your browser



    Get the details of Public IP and Ports




    The URL will be formed by combining Public IP and Node Port which is mapped to 8080 as .


  6. Result


  7. Addendum - Binding existing Bluemix Services with Kubernetes Cluster

    To bind an existing Bluemix services to Kubernetes cluster one can use the below steps:

    1. Get the namespace of your Kubernetes cluster




    2. Bind the existing service with Kuberetes using the default namespace




  8. References

    1. YAML Basics:  https://www.mirantis.com/blog/introduction-to-yaml-creating-a-kubernetes-deployment

    2. Bluemix Cli: https://console.bluemix.net/docs/containers/cs_apps.html#cs_apps_cli

    3. Kubernets and IBM Bluemix: https://www.ibm.com/blogs/bluemix/2017/05/kubernetes-and-bluemix-container-based-workloads-part1/

    4. https://medium.com/ibm-watson-data-lab/zero-to-kubernetes-on-the-ibm-bluemix-container-service-fd104fd193c1

    5. http://www.developer.com/cloud/using-kubernetes-k8s-on-ibm-bluemix.html

    6. https://console.bluemix.net/docs/containers/cs_planning.html#cs_planning

    7. https://console.bluemix.net/docs/containers/cs_apps.html#cs_apps



3 comments on"Deploying IBM Containers in Kubernetes on IBM Bluemix"

  1. thanks for the recipe. This is one of the simplest and best one I found

  2. jainrahul1234 August 21, 2018

    I see you have mentioned ‘Volume’ sec 3. but I do not find any reference of it in rest of the blog. Can you please explain how / which service can be used in BlueMix public to keep data persistent with container. Thansks!

  3. SharadChandra August 22, 2018

    Rahul, You need to have full access to IBM cloud account to mount share in this service.

Join The Discussion