Using Kubernetes (K8s) on IBM Bluemix

Tuesday May 23rd 2017 by Deepak Vohra

Learn about installing and using Kubernetes on IBM Bluemix.

Kubernetes is the most commonly used container cluster manager. Installing Kubernetes is a complex task, requiring multiple commands and configuration settings. The IBM Bluemix cloud platform offers Kubernetes as a managed cloud service. A Kubernetes cluster may be spun from the Bluemix Console. In this tutorial, we shall discuss Kubernetes on IBM Bluemix. This tutorial assumes an introductory knowledge of Docker and Kubernetes because we shall be using Docker image/s to create Kubernetes objects: nodes, services, Pods, and replica sets. This tutorial has the following sections:

Setting the Environment

As a pre-requisite, an IBM Bluemix account is required. An account may be registered at We have used the Windows OS platform for accessing the Kubernetes cluster on IBM Bluemix for which two command line interfaces (CLIs) are required. The two CLIs are Bluemix CLI and Kubernetes CLI called kubectl. Download the Bluemix CLI Windows (64-bit) binaries Bluemix_CLI_0.5.2_amd64.exe from, as shown in Figure 1. To install, click the Bluemix_CLI_0.5.2_amd64.exe application.

Downloading Bluemix CLI
Figure 1: Downloading Bluemix CLI

The command line interface for Kubernetes kubectl application, kubectl.exe, may be downloaded from Double-click the kubectl.exe application to install kubectl on Windows. Restart the system for Bluemix CLI configurations to take effect.

Creating a Kubernetes Cluster on Bluemix

To create a Kubernetes cluster, log in to the Bluemix account and click Catalog, as shown in Figure 2.

Selecting Catalog in Bluemix
Figure 2: Selecting Catalog in Bluemix

Using the Filter, search for "kubernetes" and select the service Kubernetes Cluster, as shown in Figure 3.

Selecting Kubernetes Cluster
Figure 3: Selecting Kubernetes Cluster

In the Create a Kubernetes Cluster dialog, specify a cluster name in the Cluster Name field and select the cluster location in the Location field, and click on Create Cluster, as shown in Figure 4.

Create a Kubernetes Cluster
Figure 4: Create a Kubernetes Cluster

A Welcome to the Container Service Beta dialog gets displayed. Click I'm ready, as shown in Figure 5.

Welcome to the Container Service Beta
Figure 5: Welcome to the Container Service Beta

The Kubernetes cluster begins to get deployed, as indicated by the "Deploying" message for kube-cluster in Figure 6.

Kubernetes Cluster getting deployed
Figure 6: Kubernetes Cluster getting deployed

When the Kubernetes cluster gets deployed, the message becomes "Ready," as shown in Figure 7.

Kubernetes Cluster Ready
Figure 7: Kubernetes Cluster Ready

The Overview, shown in Figure 8, lists the Summary of the cluster, including the Cluster ID, Kubernetes version, Location, and Managed from region. The number of Worker nodes, including node status, is also shown with 1 being Ready.

Cluster overview
Figure 8: Cluster overview

The Worker Nodes table lists one node in Ready state. The Private IP, Public IP, and Kube version of the cluster is also listed, as shown in Figure 9.

Worker Nodes
Figure 9: Worker Nodes

The Kubernetes cluster is an application itself and gets listed in the All Apps table as kube-cluster cluster, as shown in Figure 10.

All Apps lists the kube-cluster
Figure 10: All Apps lists the kube-cluster

Accessing the Kubernetes Cluster

The Kubernetes cluster may be accessed on the command line or from a dashboard. We shall discuss each of these next. To access the cluster from the command line, some pre-requisite tasks need to be performed, which we shall discuss first.

Installing IBM Bluemix Container Service Plug-in

In a command shell, install the IBM Bluemix Container Service plug-in with the following Bluemix CLI command:

bx plugin install container-service -r Bluemix

Regardless of from which directory the preceding command is run, the plug-in gets installed in a user directory C:\Users\<user>\.bluemix\plugins\container-service; the <user> represents the variable user. The output from the preceding command is as follows:

C:\Kubernetes>bx plugin install container-service -r Bluemix
Looking up 'container-service' from repository 'Bluemix'...
Attempting to download the binary file...
21202432 bytes downloaded
Installing binary...
Plug-in 'container-service 0.1.238' was successfully
   installed into C:\Users\Deepak Vohra\.bluemix\plugins

Logging in to the Bluemix Account

Next, log in to the Bluemix account from the command-line, using the Bluemix CLI.

bx login -a

As the output indicates, a user is prompted for e-mail information. Specify the Email and subsequently the Password prompt is displayed. Provide the password and the user gets authenticated. Select an account to log in to and the user gets logged into the account.

C:\Kubernetes>bx login -a
API endpoint:
Select an account (or press enter to skip):
1. NuBean (c1b88fbec5a71a6231a9518666d2714f)
Enter a number> 1
Targeted account NuBean
Targeted org dvohra15
Targeted space dev (API version: 2.54.0)
Region:      us-south
Account:     NuBean
Org:         dvohra15
Space:       dev

Initializing the IBM Bluemix Container Service Plug-in

To initialize the IBM Bluemix Container Service plug-in, run the following Bluemix CLI command.

bx cs init

The Container Service plug-in gets initialized.

C:\Kubernetes>bx cs init
Using default API endpoint:
Set the terminal context to the cluster.
C:\Kubernetes>bx cs cluster-config kube-cluster
Downloading cluster config for kube-cluster
The configuration for kube-cluster was downloaded
   successfully. Export environment variables to
   start using Kubernetes.
SET KUBECONFIG=C:\Users\Deepak Vohra\.bluemix\plugins

The output from the preceding command outputs a command to use to set the KUBECONFIG environment variable to the configuration file. Copy and paste the command in the cmd shell or use a slight variation of the command (such as adding double-quotes on the file path) to set the KUBECONFIG environment variable.

C:\Kubernetes>SET KUBECONFIG="C:\Users\Deepak Vohra

Using kubectl to Access the Kubernetes Cluster

In a cmd shell, run the following kubectl command to list the cluster nodes.

kubectl get nodes

Initially, the cluster node may not get listed or could be in the NotReady state, as indicated by the following output.

C:\Kubernetes>kubectl get nodes
      NotReady   7m

Run the preceding command again. After a while, the cluster node should be listed as Ready.

C:\Kubernetes>kubectl get nodes
NAME   LABELS STATUS    AGE arch=amd64,
   /arch=amd64, linux,,
89     Ready            20m

Accessing the Kubernetes Dashboard

To access the Kubernetes dashboard, first run the following command to start a proxy to the Kubernetes API server:

kubectl proxy

As the command output in Figure 11 indicates, a proxy to the API server gets started.

Starting proxy to API server on port 8001
Figure 11: Starting proxy to API server on port 8001

Open URL in a browser to view the Kubernetes dashboard, as shown in Figure 12.

The Kubernetes dashboard
Figure 12: The Kubernetes dashboard

Creating Kubernetes Services in the Dashboard

To create a Kubernetes service, click Create, as shown in Figure 13.

Click CREATE to create a service
Figure 13: Click CREATE to create a service

In the Deploy a Containerized App dialog, specify an App name (oracle-database-11xe), the Container image (sath89/oracle-xe-11g), Number of pods to run (1), Service External/Internal/None, Port(1521), Target Port(1521), and service Protocol (TCP), as shown in Figure 14.

Specifying Containerized App details
Figure 14: Specifying Containerized App details

Optionally, Labels may be specified. The Namespace may also be set, the default namespace being "default." CPU requirement (cores), Memory requirement (MB), Run command including run command args, whether to run as privileges, and Environment variables also may be specified. Click DEPLOY to deploy the service, as shown in Figure 15.

Deploying a service
Figure 15: Deploying a service

The service oracle-database-11xe gets deployed and is listed in Services in addition to the Kubernetes service, as shown in Figure 16.

Service oracle-database-11xe
Figure 16: Service oracle-database-11xe

Click the service link and the service details, including Pods, in the service get displayed, as shown in Figure 17.

Service details
Figure 17: Service details

To display the replica sets (see Figure 18) in the service, click the Replica Sets in the margin.

Replica Sets
Figure 18: Replica Sets

Similarly, deploy another service for nginx server using the nginx Docker image, as shown in Figure 19.

Deploying the nginx service
Figure 19: Deploying the nginx service

The Deployments list both the Oracle database deployment and the Nginx server deployment, as shown in Figure 20. The CPU Usage and Memory Usage are also shown.

Figure 20: Deployments

Scroll down for the Replica Sets and Pods in the deployments, as shown in Figure 21.

Replica Sets and Pods in Deployments
Figure 21: Replica Sets and Pods in Deployments

The Services should list three services—Kubernetes, oracle-database-11xe, and nginx—as shown in Figure 22.

Figure 22: Services

In the Kubernetes Dashboard, click Nodes to display the Nodes in the cluster, as shown in Figure 23.

Nodes in the cluster
Figure 23: Nodes in the cluster

In the cmd shell, list the services with the kubectl get services command.

C:\Kubernetes>kubectl get services
kubernetes      <none>        443/TCP   <none>     57m
nginx                         80/TCP    app=nginx   2m
oracle-                      1521/TCP  app=oracle- 6m
 database-11xe                                               database-11xe

To list the Pods, run the kubectl get pods command.

C:\Kubernetes>kubectl get pods
NAME                                   READY  STATUS   RESTARTS  AGE
nginx-4153138332-2x8p1                 1/1    Running  0          2m
oracle-database-11xe-1994322078-114wr  1/1    Running  0          5m


Installing Kubernetes cluster is a complex task. The IBM Bluemix managed service Kubernetes Cluster service simplifies the tasks of creating a Kubernetes cluster, and subsequently accessing and using the Kubernetes cluster.

Mobile Site | Full Site
Copyright 2017 © QuinStreet Inc. All Rights Reserved