Serverless computing is one of the new hot things so I wanted to check out OpenFaas. It worked as advertised during some experimentation on MicroK8s. The Kubernetes requirement makes sense for scalability and robustness, but adds a lot of overhead and complexity. It’s overkill if you just want to do some simple some simple experiments. Enter faasd.

Faasd is “git push” for functions and is much simpler to run than the full OpenFaas. It took a little effort to get running on an Ubuntu 20.04 server on Hetzner Cloud when I did it manually. To make it repeatable, I put it into a Terraform configuration. I could have done it as a script but wanted a change of pace and to work on my Terraform skills.

I based it on the directions for installing on multipass with some minor changes to account for the server running in the cloud and not as a local VM.

The code is on github. You will need to have a Hetzner API key and SSH key already set up. To run the repository, clone it and add in the directory a terraform.tfvars file that contains your API key. It should look something like this:

hcloud_token = "<your-token-here>"

You will want to update vars.tf to your preferred server name, server type and SSH key.

After those file modifications, run terraform init and terraform plan to see what is going to be created. If it looks good, run terraform apply to create the server.

After terraform apply returns the IP address, login in to that server using ssh and get the generated password with cat /var/lib/faasd/secrets/basic-auth-password. With the password, login as user admin to http:<ip-address>:8080\ui

The OpenFaas UI lets you create functions and you can also use the faas-cli. When you are done, you can delete the server with terraform destroy.