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.
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.
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.
iii. Follow the directions in the download page to download and install Kubernetes CLI.
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=/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
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
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.
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=188.8.131.52).
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: http://184.108.40.206: 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).
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/).