Containerization

How to use Docker, Kubernetes, and Helm Charts to deploy your VLINGO XOOM platform services.

The following shows how to set up a Reactive, scalable, event-driven application based for VLINGO XOOM, being deployed on Kubernetes and packaged by Helm Chart.

Quick start with VLINGO XOOM

First, we need a project structure that allows us to start building our application. That's when XOOM Designerarrow-up-right comes to play. It saves a lot of effort providing a web/graphical user interface to generate initial development resources such as application files, directory structure, Dockerfile and much more. Once it is installedarrow-up-right, you can use the project generator wizard running the following command:

$ ./xoom gui

This command will open your preferred browser. Just fill in the wizard stepsarrow-up-right so the project will be generated and ready to start the development.

Building the Docker image

If you choose either Docker or Kubernetes on the deployment steparrow-up-right, a Dockerfile will be placed in the root folder:

FROM adoptopenjdk/openjdk11-openj9:jdk-11.0.1.13-alpine-slim
COPY target/xoom-example-*.jar xoom-example.jar
EXPOSE 8080
CMD java -Dcom.sun.management.jmxremote -noverify ${JAVA_OPTS} -jar xoom-example.jar

That means the image is ready to be built along with the executable jar. Both tasks are performed through a single Starter CLI command:

$ ./xoom docker package

Now, let's tag and publish this local image into Docker Hubarrow-up-right.

$ ./xoom docker push

You can find more information on xoom docker push and other containerization shortcut commands herearrow-up-right.

Alternative Without VLINGO XOOM

The previous steps are pretty similar for a VLINGO XOOM service or application without VLINGO XOOM. The executable jar, including the dependency jars, can be generated with the following plugin configuration:

The Dockerfile requires the jar with dependencies:

Now, besides the application itself, the Docker image is ready to be built and published:

Kubernetes Deployment

Kubernetes is the chosen tool for container orchestration. In this scenario, it will run a single node cluster serving the VLINGO XOOM application. Whereas kubeadm is installedarrow-up-right, the cluster initialization is showed below:

Secondly, the settings folder should be mapped:

Kubernetes supports multiple networking modelarrow-up-right implementations. For now, we choose Calicoarrow-up-right. Its network policy configuration file can be added using kubectl, the command line tool for controlling Kubernetes clusters:

Considering the single node cluster is the option for this example, the last step is to prepare the master node by removing taints which, in short, prevents a deployable unit (Podsarrow-up-right) to run on it.

Management and Deployment With Helm Chart

At this point, we need to tell Kubernetes what is the application desired statearrow-up-right and how we want to expose our services, number of replicas, allocated resources... The simpler way is through Helmarrow-up-right, a special tool for Kubernetes application management. It simplifies installation, upgrade, scaling and other common tasks. Getting started, let's create a chart, which is a collection of files inside of a directory. This is how it's made:

The output looks like the following structure:

In this basic scenario, all we need to do is editing values.yaml , informing the Docker image repository, service type / port and number of replicas:

Using lint, we can check if the chart is well-formed after the addition:

With template command, we can see all files that Helm will generate and install into Kubernetes:

We finish the deployment step executing the install command:

A new Pod is created by Kubernetes to hold the xoom-example app. You should check if it's running fine:

Also, it is recommended to check the application logs:

Helm also supports a packaging and versioning mechanism, that is, a set of commands that allows us to package the Chart structure and files to make it collaborative. First, an index.yaml file should be created based on a Git repository, that will be the chart repository:

Next, the remote repository is added:

At last, enable the chart installation from the repository:

More information

Find a complete code example on GitHubarrow-up-right, built on a DDD microservices architecture, combining Kubernetes, Helm Chart and VLINGO XOOM.

Last updated