The Complete Magazine on Open Source

Programming Docker containers and Kubernetes clusters on IBM Bluemix

1.51K 0

IBM Bluemix bringing Docker containers and Kubernetes together

A container image is a lightweight, standalone, executable package of a piece of software that includes everything needed to run it — code, runtime and system tools. Kubernetes is an open source system for automating deployment, scaling and managing containerised applications. Both these technologies have a meeting point in IBM Bluemix, which is a cloud Platform-as-a-Service (PaaS) developed by IBM.

Issues related to overheads and resource consumption due to increased use of virtualisation technology are being researched since a long time. The key limitations associated with virtualisation include upfront costs, security, software licensing and the complexities. In traditional cloud implementations, virtual machines that have fully dedicated operating systems along with separate memories are used. But these are not effective in the distributed high-performance computing environment.

Therefore, the need to work on a new technology like Docker containers arises. Using Docker technology, the containers are executed in association with the Docker engine rather than the core hypervisor.

Docker containers are quite effective and have enormous potential compared to traditional virtual machines (VMs). They can work on a single kernel with the sharing of multiple libraries, which is not possible in the typical VM based environment.

Container technology is very swift compared to traditional VMs and consumes minimum resources. Users can share a common library as well as the kernel to reduce the overhead on multiple modules. In addition, Docker containers are loaded and launched within a few seconds compared to the lengthier startup time for typical Vms.

Figure 3 depicts the integrated or the hybrid approach of traditional virtualisation and Docker container technology for specific applications. Using this approach, the cross-platform hybrid cloud can be programmed for high performance computing applications.

Figure 1: A layered approach to container technology

Figure 2: A layered approach to Hypervisor and VMachine technology

Working with containers on Real Cloud IBM Bluemix

IBM Bluemix is one of the powerful clouds in the Platform-as-a-Service (PaaS) segment. It supports enormous cloud based services including mobile applications, NoSQL databases, Internet of Things (IoT), network services, DevOps, Cloud Foundry apps, virtual private networks and many others.

For the deployment and scaling of Docker applications on the IBM Bluemix cloud, a cloud based chat application called BlueChatter is used. This service uses Express, Node.js and RedisCloud.

Requirements to work with IBM Bluemix and containers include the following:

  • An IBM Bluemix account
  • An IBM Bluemix container service
  • Cloning of the BlueChatter application with the local system
  • Node.js
  • Installation of Docker on the local machine
  • Cloud Foundry CLI

To build and run the Docker container locally, first change the directory to the BlueChatter folder, which is cloned as follows:

$ cd bluechatter

Start building the Docker container, using the code below:

$ docker-compose build

$ docker-compose up

Now, the successful execution of the app can be checked from the URL http://localhost in case there is a Mac or a Linux operating system.

For Windows, there is a need to map the IP address of the Docker machine for testing the application, as follows:

$ docker-machine IPAddress Name-of-the-Machine

Figure 3: The hybridd approach of Docker containers and VMs

Figure 4: Catalogue of services in IBM Bluemix

Deploying the Docker image to IBM Bluemix

To begin, log in with the IBM Bluemix account with valid authentication. The trial account can be created for 30 days.

$ cf login -a api.ng.bluemix.net

Next, log on to the IBM container plugin so that the Docker images can be programmed and accessed in IBM Bluemix, as follows:

$ cf ic login

The name space on the IBM Bluemix panel is specified in the next instruction:

$ cf ic build -t mynamespace/bluechatter ./

In the next step, verify if the images have been created with the push to the IBM Bluemix container image registry. The images in IBM Bluemix can be programmed effectively once they are visible in the Bluemix panel.

$ cf ic images

The BlueChatter app is integrated with Redis; so there is a need to create a new Redis service, which can store all the chat communication in the storage space, as follows:

$ cf create-service rediscloud 10mb redis-chatter

By following all these instructions, the Docker image can be deployed on the Real Cloud IBM Bluemix. In addition to the classical deployment, applications can be scaled for multiple users and access rights. The number of users can be set in the instruction, which can send and receive the messages using Redis services.

$ cf scale MyApp -i 10

The customisation of the app with the new code can be done in IBM Bluemix. Using this approach, the new features in the application can be integrated and deployed using IBM DevOps services (JazzHub).

$ git clone https://github.com/CodenameBlueMix/bluechatter.git

$ cd bluechatter

$ cf push MyApp

$ cf app MyApp

To evaluate the features and performance of the app deployed to IBM Bluemix, it can be tested on various Web browsers.

Figure 5: The IBM Bluemix based BlueChatter app

Figure 6: Chat environment in IBM Bluemix based BlueChatter app

Kubernetes and cluster programming

Kubernetes or K8s is a free and open source distribution that automates the scaling, deployment and management of container based applications. It was initially developed by Google and subsequently donated to the Cloud Native Computing Foundation.

To work with Kubernetes and IBM Bluemix, there is need to work on Kubernetes CLI.

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

bx plugin install container-service -r Bluemix

For the initialisation of the container service plugin, the following command is executed:

bx cs init

To create a new cluster, the free-tier cluster in IBM Bluemix can be selected. By using the following command, a cluster that has a single node with 4GB memory and two vCPUs will be created:

bx cs cluster-create --name my-cluster

The clusters can be listed using the following command:

bx cs clusters

To access the dashboard of Bluemix Kubernetes, the following command is executed on the local system:

kubectl proxy

The IBM Bluemix Container Service with Kubernetes can be viewed on http://127.0.0.1:8001/ui using a Web browser.

Figure 7: Creating an IBM Bluemix account

Scope for R&D

There is huge scope for research activities and projects using Docker container technology. As NoSQL databases are now widely used for Big Data based applications, the integration of a NoSQL database, including MongoDB, Cassandra, CouchDB, Neo4J and many others, can be programmed and attached with the containers, and their performance can be evaluated. The distribution, access and sharing of database services with security on a real, hybrid cross-platform cloud can be programmed, along with the evaluation of assorted parameters including performance, privacy, security, integrity, cost factor, complexity and many others.