OpenFaas on Docker Swarm on Raspberry Pi

OpenFaas is a server-less framework for running functions on docker containers. It's wicked easy to configure, and deploy functions. I was impressed to find out that you can deploy it to Docker Swarm on a Raspberry Pi! How neat.

Step 1) Install Docker
> curl -fsSL get.docker.com -o get-docker.sh && sh get-docker.sh
Step 2) Configure OpenFaas by following there really well done tutorial on OpenFaas.com

Step 3) Configure a registry. Since you already have docker swarm running, deploy a stack with a registry running. Note, make sure to create the directory /data/registry.
version: "3.3"
services:
repo:
image: registry:2
ports:
- 5000:5000
volumes:
- '/data/registry:/var/lib/registry'
and deploy with
> docker stack deploy -c docker-stack.yml infra
Step 4) Setup on Work Station. You only have have Docker and OpenFaaS CLI installed. Once you do that you should be good to go. Note that if you want to deploy to that registry you have to add it to your "insecure repositories" section in your settings.

Nice things to try

Create new function

> faas-cli new func-demo --lang python3-armhf --prefix raspberrypi:5000

Deploy function

faas-cli up -f func-demo.yml --gateway raspberrypi:8080

Test New Function

> curl -d "hello" http://raspberrypi:8080/function/func-demo
hello

Comments

Popular posts from this blog

How to use Google Tasks

How I used Eisenhower's matrix to tame the noise of Slack

Supporting People, Process, and Projects