Tech Tip

IBM Cloud Platform (Bluemix)

Print

<< Back to Getting Started with IBM UrbanCode Deploy and Containers

This document contains information and best practices for automating deployments to IBM Cloud Platform (formerly known as IBM Bluemix) using IBM UrbanCode Deploy.

What is IBM Bluemix?

Visit this page to learn what IBM Bluemix is.

To learn even more about IBM Bluemix, visit this page.

Creating a Kubernetes Cluster in IBM Bluemix

  1. Login to the IBM Bluemix website and, from the menu on the left, click Containers.
  2. Click the Create Cluster button.
  3. Under Cluster type, select Standard or Lite.
  4. Enter a name for your cluster in the Cluster Name field and click the Create Cluster button.
  5. Your cluster begins to deploy and the Gain access to your cluster page appears. Click Clusters to go back to the Clusters page.
  6. Refresh the page until the State of your cluster shows as Ready (this may take a few minutes).

Your Kubernetes cluster has been created and is ready for use.

Setting up the Kubernetes Config File for IBM Cloud Platform (Bluemix)

Instead of editing an existing Kubernetes configuration file, IBM Cloud Platform downloads a unique configuration file for each Kubernetes cluster to your Kubernetes client machine.

By default, this file contains a token that expires after 30 days of inactivity.

It is possible to download a configuration file which does not expire. To do so, from the terminal, login in to Bluemix with the bx login command. Next, run the bx cs init command to initialize the Container Service plug-in. Finally, run the command:

bx cs cluster-config clusterName --admin

Automating the Download of the Kubernetes Config File

As mentioned in the previous section, IBM Cloud Platform downloads a unique configuration file for each Kubernetes cluster to your Kubernetes client machine. By default, this file contains a token that expires after 30 days of inactivity.

The previous section described how to download a Kubernetes configuration file that will not expire. If you do not want to use a configuration file that never expires, you may automate the process of downloading a Kubernetes config file from IBM Bluemix.

To do so, first create a step that logs in to Bluemix. This may be done by adding a Shell step to your process which simply runs a bx login command. For example, if using an API key to connect to Bluemix, your script may look something like this:

bx login -u myUser -a https://api.ng.bluemix.net --apikey @/home/keys/myKey.txt -s mySpace -o myOrg

Next, insert the step Get Kube Config File – IBM Cloud. This step is included with the Kubernetes plug-in for IBM UrbanCode Deploy. This step runs the bx cs init command, followed by the bx cs cluster-config [cluster name] command to download a Kubernetes config file for use with your Bluemix cluster. This step will generate an output property named ${p:Get Kube Config File – IBM Cloud/kubeconfig} containing the location and name of the downloaded Kubernetes config file. Subsequent Kubernetes and Helm steps may reference this property. For example, most Kubernetes steps contain a Global Flags property (under Show Hidden Properties). By entering the value

--kubeconfig=${p:Get Kube Config File - IBM Cloud/kubeconfig}

to the Global Flags field, the step will reference the newly downloaded Kubernetes config file when running kubectl commands.

Helm steps contain a Kube Config File property (under Show Hidden Properties) which may be set to ${p:Get Kube Config File – IBM Cloud/kubeconfig} in order to reference the newly downloaded Kubernetes config file when running helm commands.

Installing Tiller on your Bluemix Kubernetes Cluster

Helm helps users manage Kubernetes applications. For more information, see this page.

There are two pieces to Helm. One is the Helm client, which should be installed on your UrbanCode Deploy agent machine. The second part is the Helm server, called Tiller. Tiller is installed on each Kubernetes cluster which uses Helm.

Kubernetes clusters on IBM Bluemix do not contain Tiller by default.

To install Tiller on your IBM Bluemix Kubernetes cluster, from the terminal, login to Bluemix.

Next, run the bx cs init command to initialize the Container Service plug-in.

Run the bx cs cluster-config [cluster name] command to download the configuration for your cluster.

The result of that command shows a line starting with export KUBECONFIG=. Copy that line, paste it in the terminal, and press enter to set the KUBECONFIG environment variable. Helm uses this environment variable to determine which cluster it is working with.

Now that Helm knows which Kubernetes cluster to use, we may install Tiller onto the cluster by running the command:

helm init

Tiller is now installed on your IBM Cloud Platform (Bluemix) Kubernetes Cluster.