The Complete Magazine on Open Source

Kontena: A developer-friendly container and microservices platform

2.58K 0

Kontena as a developer-friendly container platform

Kontena is driving innovation in container platform technology by accelerating projects and taking container-based release automation to the next level. Kontena developers can leverage multiple cloud providers into one secure virtual environment which means no lock-in, apart from many other uses.

Containerisation has been a hot topic in the industry for a long time now. Basically, containerisation is an OS level virtualisation technique for deploying and running distributed applications without launching separate VMs for a single application. Kubernetes is very popular for deploying, scaling and maintaining container based applications. But it requires a lot of manpower to install and maintain it. It is also complex to start with. Kontena is another open source system whose ultimate goal is to build a DevOps-friendly platform. It serves the same purpose that Kubernetes does, but in an easier and more manageable way so that a typical software developer can program and manage containers and micro systems.

Kontena

Kontena is an open source project available in the GitHub Repository that helps us to run and manage containerised applications on a cluster. Figures 1 and 2 demonstrate its architecture. The Kontena system has a number of nodes and a master node, which controls the Kontena nodes. Kontena nodes are servers or VMs, which run container apps and the Kontena master is the controller for all the nodes.

To build an application, we require Kontena Service Definition, which includes details about the container image, scaling, networking details and other attributes. These services can be linked together to create the desired architecture. Here, each service will automatically generate an internal IP address and DNS, so that they can communicate internally.

Architecture

One of the best things about Kontena is its simple architecture, which makes it easier to grasp and so you can quickly start using it. With the Kontena CLI, we can do all the administrative stuff. Currently, there is no GUI for Kontena, which makes the code simpler and manageable.

The architecture consists of four layers:

  • The authentication layer (external).
  • Masters, which will manage each grid.
  • Grids, which are logical abstractions. Nodes will recede into a grid, which provides actual compute power.
  • Services that will run on the grid.

Figure 1: The Kontena system

Figure 2: Kontena architecture

Features of Kontena

Listed below are the key additional features of Kontena, apart from its standard features:

  • Separate authentication layer
  • Audit logs
  • Built-in Docker image registry
  • Remote access to workload services
  • Load-balancing
  • Log and statistics aggregation with streaming
  • Different roles and access control for users
  • A scheduler with affinity filtering

Installation and a demo

Kontena is built using Ruby, so the latter first needs to be installed. We can download the latest version from the official site. What we require is version > 2.1.

If you are on Windows, then download its Windows-exclusive Ruby installer.

The next step is to install Kontena-CLI. We can download it using the Rubygems Package Manager, as follows:

gem install kontena-cli

To check the Kontena version, run the command given below:

kontena Version

To install Kontena Masters, we can either use the cloud platform or the local environment. Here, we will consider the local environment.

We will use Vagrant to install Kontena Master in a local environment. Here, too, the minimum requirement is version 1.6 and above.

Figure 3: Kontena yml Part 1

Once you are ready with Vagrant, we will start installing Kontena Master, using the following commands:

kontena plugin install vagrant

kontena vagrant master create

While installing, you will be asked how you want to authenticate it. It’s good to choose External authentication. We can also use Kontena Cloud for the authentication.

The next step is to install Kontena nodes; we will use Vagrant to do this:

kontena grid create newgrid

# or to switch to an existing grid, use:

kontena grid use newgrid

Now the grid is ready, and we have selected newgrid as the current grid. We will now create nodes in it:

kontena vagrant node create

To create multiple nodes for faster computing, we can repeat this step. It is recommended to have more than one node in the grid.

To check all the nodes in the grid, we can use the command given below:

kontena node list

Now we are ready with the environment, and it’s time to deploy our first application stack.

We will take the WordPress application as an example and deploy it in the Kontena grid.

We need to create a Kontena.yml file, which contains all the attributes regarding the application.

Check Figures 3 and 4 for the yml file.

Once the yml file is created, we can install and deploy our WordPress stack, as follows:

kontena stack install kontena.yml

It will take some time to finish this. Once it is over, we can check WordPress and the MySQL service to know whether it’s running or not.

kontena stack ls

By using the kontena stack command, we can see the entire configuration of each service.

Figure 4: Kontena yml Part 2

Figure 5: Kontena stack output

Figure 5 demonstrates the Kontena ‘service show’ output for WordPress stack.

To test the WordPress service, we need to use the public IP address mentioned in the Kontena ‘service show’ command along with TCP port 80.