Integration anytime any place anywhere.

Running Interlok in Kubernetes

Deploying Interlok in Kubernetes via Minikube

The goal of this post is guide you through the steps of deploying Interlok containers in Kubernetes. Minikube is used, Minikube is a tool that makes it easy to run Kubernetes locally. As we all know; Kubernetes is an open-source platform for automating deployment, scaling, and operations of application containers across clusters of hosts, providing container-centric infrastructure.

Setting up your Minikube environment

You’ll already have docker installed so you can just follow the detailed instructions available to install from Minikube & kubectl. Once everything is installed you need to create a Minikube VM:

$ minikube start --kubernetes-version="v1.5.2" --vm-driver="hyperv" --memory=1024 --hyperv-virtual-switch="NATSwitch" --v=7 --alsologtostderr

The above command assumes the following:

Now we need to set the kubectl context to use Minikube and then verify everything is in working order.

$ kubectl config use-context minikube
$ kubectl cluster-info
$ minikube dashboard

Creating your Interlok Config

For testing purposes we will create an Interlok instance using a jetty-message-consumer that returns the text “Hello World”. First create a project directory called interlok-kubernetes within that create another directory config and create an adapter config file with the following contents:

      <consume-connection class="jetty-embedded-connection">
      <produce-connection class="null-connection" />
          <consumer class="jetty-message-consumer">
            <destination class="configured-consume-destination">
            <parameter-handler class="jetty-http-ignore-parameters"/>
            <header-handler class="jetty-http-headers-as-metadata"/>
          <service-collection class="service-list">
                <template><![CDATA[Hello World!]]></template>
          <producer class="jetty-standard-response-producer">
            <unique-id>Send HTTP Response</unique-id>
            <status-provider class="http-metadata-status">
            <response-header-provider class="jetty-metadata-response-headers">
              <filter class="remove-all-metadata-filter"/>
            <content-type-provider class="http-configured-content-type-provider">

It’s recommended to test the config is working as expected by starting your local Interlok instance and loading it.

Creating your Docker Container image

In the created directory (interlok-kubernetes) create a new Dockerfile:

FROM adaptris/interlok:snapshot-alpine

ADD config /opt/interlok/config

An image needs to created inside the minikube environment so let’s point docker at minikube and build the image.

$ eval $(minikube docker-env)
$ docker build -t hello-interlok:1.0.0 .

Of course you can customise how you build your docker image; since our hello-world application is very simple, we don’t need any other additional libraries; for different ways to customise your docker container image check out the git project docker-interlok-template.

Create a Deployment

Next we create a Kubernetes Pod. A Pod is group of one of more containers. We use the kubectl run commands

$ kubectl run hello-interlok --image=hello-interlok:1.0.0 --port=8080
$ kubectl get deployments

hello-interlok   1         1         1            1           2m

$ kubectl get pods

NAME                              READY     STATUS    RESTARTS   AGE
hello-interlok-1091946548-qr64v   1/1       Running   0          37s

Once it’s started, then we can view deployments using kubectl get deployments which gives you a list of all the deployments; view the pods using kubectl get pods. The output of both should reference hello-interlok in one way or another. The important one here is the pod name; you’ll be needing that later.

Create a Service and expose it.

$ kubectl expose deployment hello-interlok --type=LoadBalancer
$ kubectl get services
NAME             CLUSTER-IP   EXTERNAL-IP   PORT(S)          AGE
hello-interlok   <pending>     8080:30082/TCP   6s
kubernetes     <none>        443/TCP          3h

$ minikube service hello-node
$ kubectl logs <pod_name>

INFO  [hello-world] [StandardWorkflow] message [d5c1dfcd-404f-4695-b79e-18e1d2fec03f] processed in [2] ms