Docker has created a nice little demo app you can use to deploy to Swarm mode or Kubernates. You can find the instructionshere.

Note: The following command overrides the orchestrator for a single deployment by setting the variable at the start of the command itself:DOCKER_ORCHESTRATOR=swarm docker stack deploy --compose-file docker-compose.yml foo

Deploying OpenFaaS on Docker with Kubernetes

Now the fun part!

If you are not yet familiar with the concept of serverless or faas, I suggest reading up on it. Martin Fowler and others have quite a few write-ups on the subject.

If you want to try and take function-as-a-service for a spin, I suggest looking at OpenFaas.

There are quite a few FaaS implementations out there, most notable of which is AWS Lamda. However, OpenFaaS, in my opinion, is truly the most elegant solution out there. I'll be writing about it extensively in future blogs.

Just like Docker, the key to OpenFaas is its simplicity. Functions can be written in any language for Linux or Windows. It has the capability to autoscale on demand and can run on Kubernetes and Docker Swarm native.

Let's take a closer look:

You can find OpenFaaS on github. We are interested in faas-netes for Kubernetes schedule but feel free to use it with swarm mode too.

I have already cloned the repo and now I am going to build the framework.

Go inside of faas-netes directory and execute: ./build.sh.

When the build completes, run the following command

kubectl apply -f faas.yml,monitoring.yml,rbac.yml

or you can run

make install

While the command is running you should see something similar in your terminal