Skill Level: Beginner

This recipe provides step-by-step instruction to deploy an application in docker container to Kubernetes Cluster in Bluemix using Kubernetes CLI. The sample application used is the same one presented in Kavisuresh’s recipe published in December, 2016.


  • IBM Bluemix Account (https://console.ng.bluemix.net)
  • Local workstation


  1. Login to your IBM Bluemix Account

    1. From your web borwser, login to your IBM Bluemix account at https://console.ng.bluemix.net.

    Note: if you do not have an IBM Bluemix account, you can open a 30-day trial account with a valid email address.

  2. Create a Kubernetes Cluster in Bluemix

    1. After login to your Bluemix account, click on the Catalog link on the top, select Apps -> Containers from the left navigation menu and click on the Kubernetes Cluster as shown below:


    2. In the Create a Kubernates Cluster page, enter your Cluster Name, set the Cluster type as Free and select the Bluemix Data Center Location from the dropdown list (dal10 is the default), then click on Submit.


    Your will see your Kubernetes Cluster is now in Deploying status.


    When the deployment is done, you can see your Kubernetes cluster status is updated as Deployed.


    1. Install Bluemix CLI and Kubernetes CLI

      1. After your Bluemix Kubernates cluster is deployed, you need to configure your local workstation to run Bluemix CLI and Kubernetes CLI. To do this, click on the Access cluster link on the Kubernates cluster Summary page.


      a. Install Bluemix CLI

      i. Click on the Download Bluemix CLI link.


      ii. Select and download the CLI for your OS to your local workstation, and follow the direction on the page to run the setup script in the package to install the Bluemix CLI on your local workstation.


      iii. After the Bluemix CLI is installed, install the Container Service CLI plugin with the command: 

      bx plugin install container-service -r Bluemix

      b. Install Kubernetes CLI

      i. Click on the Kubernetes CLI (kubectl) link.


      ii. In the Kubernetes Guide page click on the Installing and Setting Up kubectl link.p9

      iii. Follow the directions in the download page to download and install Kubernetes CLI.p10

    2. Run Kubernetes CLI

      1. In your local workstation terminal window, login to Bluemix from your local workstation with command:

      bx login -a https://api.ng.bluemix.net

      2. Login to the Bluemix Container Service plugin in the Bluemix CLI with command:

      bx cs init

      3. Set the Kiubernetes cluster you created in Bluemix as the context for this session. Complete this configuration step every time you want to work with your cluster with the CLI.

      a. Download the Kubernetes cluster configuration file with command: 

      bx cs cluster-config <your Bluemix Kubernetes cluster name >

      Example: bx cs cluster-config mycluster4YT

       When the download is finished, an export command is shown that you can use to set the path to your configuration file as an environment variable.


      b. Copy and paste the command from the previous step to set the environment variable and configure your CLI to run kubectl commands within your Kubernates cluster.

      export KUBECONFIG=<path_to_kubeconfig>


      export KUBECONFIG=/home/ibmdemo/.bluemix/plugins/container-service/clusters/mycluster4YT/kube-config-prod-dal10-mycluster4YT.yml cli/clusters/my_cluster/kube-config-dev-mex01-my_cluster.yml

    3. Deploy containerized application to the Kubernetes cluster in Bluemix using Kubernetes CLI

      1. Deploy mongo container

      a. In your terminal window, enter the following two kubectl commands:

      kubectl run mongo –image=mongo –port=27017

      kubectl expose deployment mongo –type=NodePort

      Kubernetes has now created a deployment for the mongo database container, and exposed it as a service and updated the DNS server so the sample application can locate it.

      b. You can see the new service by issuing the following command to list it.

      kubectl get services

      2. Deploy node.js container

      a. Enter the following two kubetcl commands:

      kubectl run myemp –image=kavisuresh/employee –port=80

      kubectl expose deployment myemp –type=NodePort –port=80 –target-port=8888

      The myemp application is now deployed to the Kubernates Cluster.

      3. Access Kubernetes dashboard to view your deployment.

      a. Set a port number for Kubernets server with command

      kubectl proxy


      b. Open the following url in a web browser and you will get in the Kubernetes dashboard page.



      As you can see the two containers deployed are up and running.


    4. Access the Employee Application

      The url of deployed Employee application running in myemp pod has a format like: http://myemp_Node_IP:myemp_Node_Port


      1. To get the myemp service Node IP and Port info.

      a. From the Kubernetes Dashboard, click on Nodes and write down the Node IP address (Fox example: myemp_Node_IP=


      b. Click on Services and write down the Node Port of the myemp pod (For example: myemp_Node_Port =32146).


      c. Enter the myemp application url (For example: 32146) in a web bowser, you can access the application.


      Now you can add, update, retrieve and delete employee data in this application (as described in detail in Kavisuresh’s recipe).



    5. Reference

      This recipe uses the sample application and database docker images and configurations created by Kavisuresh in her recipe published in December, 2016 (https://developer.ibm.com/recipes/tutorials/deploying-a-containerized-app-in-kubernetes-using-kubernetes-dashboard/).

    1 comment on"Kubernetes: How to deploy a containerized application to Kubernetes Cluster in Bluemix"

    1. tomwat@us.ibm.com May 05, 2017

      Hi great lab. I am on last step, and getting an error on the myemp deployment. Any thoughts on this error: Failed to start container with docker id 657376df3923 with error: Error response from daemon: {“message”:”oci runtime error: container_linux.go:247: starting container process caused \”exec: \\\”–port=80\\\”: executable file not found in $PATH\”\n”}
      Error syncing pod, skipping: failed to “StartContainer” for “myemp” with RunContainerError: “runContainer: Error response from daemon: {\”message\”:\”oci runtime error: container_linux.go:247: starting container process caused \\\”exec: \\\\\\\”–port=80\\\\\\\”: executable file not found in $PATH\\\”\\n\”}”
      Back-off restarting failed docker container

    Join The Discussion