IBM is deploying the open-source software Kubernetes to manage container-based applications in the Bluemix environment. This article follows on from the first article in this series, and describes how to build and deploy a basic IBM Integration Bus (IIB) node in a Bluemix environment, using Kubernetes as a management tool for the IIB containers.
There is already a large and extensive set of Kubernetes documentation available. This article provides a basic implementation of IIB using Kubernetes, so if you are not familiar with Kubernetes, we recommend you review some of the many available articles. A good starting point would be the Bluemix Container Service website, at https://console.bluemix.net/docs/containers/container_index.html?pos=2, and specifically the paragraph â€śTutorials for clustersâ€ť will be helpful.
Schematic for this article
This document describes the basic minimum set of tasks to configure a Kubernetes cluster to allow an IIB integration node to run. The schematic below shows the main components that will be used and built in this article.
This article was generated on a Linux ubuntu system, so some of the commands will reflect this environment.
Linux commands are shown in italics, like this: cd /home/iibadmin.
Install the pre-requisite components on the ubuntu system
- Install curl. You may already have this installed, but if not:
sudo apt-get install -y curl
- In a browser, download the Bluemix CLI from https://clis.ng.bluemix.net/ui/home.htmlThe current version for Linux is Bluemix_CLI_0.5.6_amd64.tar.gz
- Unzip the downloaded Bluemix CLI installation file Bluemix_CLI_0.5.5_amd64.tar.gz.
For this article, we unzipped into /home/iibadmin, creating the Bluemix_CLI directory.
- In the Linux terminal, navigate to /Bluemix_CLI, and then install the Bluemix CLI:
- cd Bluemix_CLI
- sudo ./install_bluemix_cli
- Install the Kubernetes CLI (required to deploy apps to Kubernetes and run the local Kubernetes dashboard proxy). This is described for all platforms on this page: https://kubernetes.io/docs/tasks/tools/install-kubectl/, but for the Linux ubuntu system that we used for this article, all you need to do is run these commands:
- curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
- chmod +x ./kubectl
- sudo mv ./kubectl /usr/local/bin/kubectl
- Confirm the Kubernetes installation:
At the time of writing this article, the Kubernetes CLI was at version 1.7.3
- Install Bluemix Container Service plugin. Run the command:
bx plugin install container-service -r Bluemix
- Confirm the Container Service plugin installation is OK:
bx plugin show container-service
- Install the Container Registry plugin. Run the command:
bx plugin install container-registry -r Bluemix
- Check the Bluemix Container Registry plugin is OK:
bx plugin show container-registry
- Check Bluemix plugins
bx plugin list
This will show your installed Bluemix plugins:
Define a Kubernetes Cluster
- Login to Bluemix CLI:
bx login -a https://api.ng.bluemix.netNote â€“ if you have a federated Bluemix ID, you have to include the -sso parameter, and obtain a one-time passcode, using this variation of the above command:
bx login -sso -a https://api.ng.bluemix.net
Note the cursor does not move when you type the passcode, so be sure you type (or paste) correctly.
- Login to the Container Registry:
sudo bx cr loginNote â€“ on my system, I required the â€śsudoâ€ť prefix, to ensure the correct local credentials were used for CR authentication.
- Initialise the Bluemix Container Service plugin:
bx cs init
- Create a Kubernetes cluster (provide a suitable name; this example uses â€śiibclusterâ€ť):
bx cs cluster-create â€“name iibcluster
- Check the cluster has been created (this could take some time to complete â€“ minimum 15 minutes, but possibly longer). This should show â€śnormalâ€ť when fully available.bx cs clusters
- Check the cluster workers for the new cluster:
bx cs workers iibcluster
- Get the cluster configuration details (required in order to set local configuration context):
bx cs cluster-config iibclusterThis will respond with a generated EXPORT command.
Copy this (highlight the entire EXPORT command, right-click, copy), and then paste into the command prompt. Then press return to execute. The EXPORT will have a format similar to this:
- Confirm the KUBECONFIG variable has been set correctly:
- Start the kubectl web admin proxy. Itâ€™s a good idea to execute this proxy in a second Linux terminal (it performs a blocked wait in the terminal), so open a new terminal and run the following commands (the export can be copy/pasted from the previous step).
export KUBECONFIG= . . . as aboveThen run the command:
Tip â€“ if you get the message that port 8001 is in use elsewhere, switch to port 8002, with this command:
kubectl proxy â€“â€“port=8002
Upload your IIB docker image to the Container Registry
- Add a Container Registry namespace. This article will use the value â€śnamespaceâ€ť. Adjust each command as required.
bx cr namespace-add namespace
- Confirm (or retrieve) your Bluemix namespace:
bx cr namespace-list
- Obtain the IMAGE ID of your local docker image, by using this command:
sudo docker images
- Tag your local docker image with details of your Bluemix container registry. This article will use a local docker image called iib10009.
- Set the value of â€śnamespaceâ€ť as required.
- Set the Bluemix region to your own region (for example, replace â€śngâ€ť with â€śeu-gbâ€ť â€¦ etc).
- Set the value of â€śdockerImageIDâ€ť to the ID of your own image (a68145644fc6 in the example show below).
sudo docker tag dockerImageID registry.ng.bluemix.net/namespace/iib10009
Check it worked:
sudo docker images
- Push the image to Bluemix (again, set â€śnamespaceâ€ť and Bluemix region to your own values):
sudo docker push registry.ng.bluemix.net/namespace/iib10009Depending on your network bandwidth, this will take some time, typically 5-15 minutes. Future uploads of the docker images which contain incremental changes will be much quicker, due to the layered construction of docker images.
- Check the uploaded docker images:
bx cr images
Create a Kubernetes deployment and service for the IIB node
- Create a Kubernetes deployment for the IIB node by running a command similar to this (the example below assumes your Docker container is expecting environment variables LICENSE and NODENAME):
kubectl run iib10009-deployment
- Create a Kubernetes service for the IIB webadmin port, 4414:
kubectl expose deployment/iib10009-deployment
â€“â€“name=ib10node-svc-4414In this example, for readability, we have named this service ib10node-svc-4414; this service only exposes port 4414 for IIB webadmin.
Using this command, Kubernetes will generate a value for the external port (known as the NodePort) in the range 30000-32767 that maps to the IIB internal port of 4414.
- Retrieve service details (ports):
kubectl describe service ib10node-svc-4414The NodePort value is the external port on which the IIB web admin is available.
- Get the Public IP address of your Kubernetes cluster:
bx cs workers iibcluster
- In a browser, connect to the IIB web admin with â€śPublicIPâ€ť:â€ťNodePortâ€ť.
- You can use the exposed web admin IP address and port to connect an Integration Toolkit or the Integration API to this IIB node, using the IIB facilities for connecting to remote nodes.
- Finally, return to the Kubernetes dashboard. You can see details of the IIB deployment and service by clicking the appropriate links in the navigator. Clicking “ib10node-svc-4414” on the screen below will drill down to the service details.
Login to the bash shell of the IIB container
- Retrieve the Kubernetes pod ID of the IIB deployment:
kubectl get pods
- Run the “kubectl exec” command to open a bash shell:
kubectl exec -it podID â€“â€“ /bin/bash (where podID is the value of the NAME output of the above command – use copy/paste to get this value)
- Now run your favourite IIB commands, for example:
- cd /opt/ibm/iib-10.0.0.9/server/bin (adjust to your installation directory for IIB)
- . ./mqsiprofile