Push a Docker DAB to a Kubernetes Cluster in Two Commands!

12 Sep 2016

Docker Distributed Application Bundles (DABs) are "an experimental open file format for bundling up all the artifacts required to ship and deploy multi-container apps." DABs contain a complete description of all the services required to run an application, along with details about which images to use, ports to expose, and networks used to link services.

A little over a month ago, I wrote about DABs and outlined how they can be used with multi-tier apps to develop locally with Docker Compose and then bundled for deployment to a Docker Swarm cluster.

In this post, I will expand on my previous post and show how DABs can be used to make an artifact that is deployable on a Kubernetes cluster.

Why? Because by doing this we can take advantage of the awesome develop experience that the Docker tools provide to deploy artifacts to a production-ready Kubernetes cluster without needing a whole bunch of Kubernetes experience. Win win.

Note: DAB files are still experimental as of Docker 1.12.

Converting DABs

So, how do we approach this?

Well, it turns out someone else has done most of the work for us!

Let me introduce Skippbox Kompose, a tool that helps people familiar with Docker Compose move to Kubernetes. And what's more, it supports Docker DAB files.

Let's work through an example to see what it does.

First, clone this example app:

$ [email protected]:lachie83/example-voting-app.git

Bundle the application:

$ cd example-voting-app
$ docker-compose pull
$ docker-compose bundle
Wrote bundle to examplevotingapp.dab

Now we can use Kompose to convert our DAB file to a Helm chart:

$ kompose convert --dab examplevotingapp.dab -chart -y

You should see output like this:

WARN[0000] Unsupported key networks - ignoring
WARN[0000] Unsupported key args - ignoring
WARN[0000] [db] Service cannot be created because of missing port.
WARN[0000] [worker] Service cannot be created because of missing port.
file "result-svc.yaml" created
file "vote-svc.yaml" created
file "redis-svc.yaml" created
file "vote-deployment.yaml" created
file "worker-deployment.yaml" created
file "db-deployment.yaml" created
file "redis-deployment.yaml" created
file "result-deployment.yaml" created
chart created in "./docker-compose/"

Installing the Helm Chart

Use Helm to install the converted chart into a Kubernetes namespace named vote:

$ helm install docker-compose/ --namespace=vote

Your app should now be up and running!

You can use kubectl to inspect the resources that were created:

$ kubectl get pods,svc,ep --namespace=vote

You should see output like this:

NAME                      READY                             STATUS        RESTARTS          AGE
db-1839173838-rdpxs       1/1                               Running       0                 6s
redis-2804528135-vrkyl    1/1                               Running       0                 6s
result-3778864494-e8opx   1/1                               Running       0                 6s
vote-1900461998-oh8qq     1/1                               Running       0                 5s
worker-1165402300-cd2tj   1/1                               Running       1                 6s
NAME                      CLUSTER-IP                        EXTERNAL-IP   PORT(S)           AGE
redis                                  <none>        6379/TCP          6s
result                                <none>        80/TCP,5858/TCP   6s
vote                                  <none>        80/TCP            5s
NAME                      ENDPOINTS                         AGE
redis                              6s
result          ,   5s
vote                                 5s

That's all there is to it.

Okay, Go!

In this post, we deployed a multi-tier application and all we needed to know how to use was the Docker toolset and Kompose.

Are you using DAB files, or do you plan to use them? Get in touch with us at @opendeis and let us know. I'm very interested to see where the community takes this.

Also, a big thank you to the team over at Skippbox. Kompose is a slick little tool.

Posted in Docker, DAB, Kubernetes, Kompose

triangle square circle

Did you enjoy this post?