Setting Up OpenFaaS in Kubernetes
Serverless computing has revolutionized how we build and deploy applications, allowing developers to focus on code without managing underlying infrastructure. OpenFaaS brings this power to your Kubernetes cluster, providing a flexible and powerful platform for deploying functions.
In this guide, we'll walk you through the process of setting up OpenFaaS locally, and prepare to deploy your first function.
Choosing Your Kubernetes Environment
Cloud Kubernetes Options
For production-ready, scalable environments, cloud providers offer managed Kubernetes services
- Azure Kubernetes Service (AKS)
- Amazon Elastic Kubernetes Service (EKS)
- DigitalOcean Kubernetes Service (DOKS)
- Google Kubernetes Engine (GKE)
Local Kubernetes Options
For development and testing purposes, setting up a local Kubernetes cluster can be incredibly efficient.
- Minikube: The original "local Kubernetes" solution. Minikube provisions a single-node Kubernetes cluster within a virtual machine (VM), but there is also an option for
- Docker Desktop: It includes a "Kubernetes" checkbox, allowing you to run a full Kubernetes cluster directly within the same VM used for your Docker builds.
- MicroK8s: Lightweight, production-grade Kubernetes distribution designed for developers, edge, and IoT. It integrates directly with and requires Ubuntu.
- k3d: A lightweight wrapper to run K3s.- This is a very fast and resource-efficient way to spin up local Kubernetes clusters.
- Kind (Kubernetes in Docker): A tool for running local Kubernetes clusters using Docker containers as "nodes". Kind is primarily designed for testing Kubernetes itself, but it can also be used for local development and testing of applications.
Installing OpenFaaS
Once you have your Kubernetes cluster up and running, installing OpenFaaS is straightforward. We'll primarily focus on installation using arkade
, a powerful CLI tool for installing developer tools and Kubernetes applications.
Install with arkade
First, you need to install arkade:
$ curl -sSL https://get.arkade.dev | sudo -E sh
[sudo] password for fedora:
x86_64
Downloading package https://github.com/alexellis/arkade/releases/download/0.11.39/arkade as /tmp/arkade
Download complete.
Running with sufficient permissions to attempt to move arkade to /usr/local/bin
New version of arkade installed to /usr/local/bin
There is already a command 'ark' in the path, NOT creating alias
_ _
__ _ _ __| | ____ _ __| | ___
/ _` | '__| |/ / _` |/ _` |/ _ \
| (_| | | | < (_| | (_| | __/
\__,_|_| |_|\_\__,_|\__,_|\___|
Open Source Marketplace For Developer Tools
Version: 0.11.39
Git Commit: bc4fbb9d00a4aedf7ffd2e991c5b593b272a7eea
👏 Say thanks for arkade and sponsor Alex via GitHub: https://github.com/sponsors/alexellis
Install OpenFaaS using arkade:
Following the instructions from the output above, get faas-cli:
$ curl -sSL $ arkade install openfaas Using Kubeconfig: /home/fedora/.kube/config Client: x86_64, Linux 2025/05/25 21:07:35 User dir established as: /home/fedora/.arkade/ 2025/05/25 21:07:35 Looking up version for: helm 2025/05/25 21:07:35 Found: v3.18.0 Downloading: https://get.helm.sh/helm-v3.18.0-linux-amd64.tar.gz /tmp/arkade-2055899785/helm-v3.18.0-linux-amd64.tar.gz written. 2025/05/25 21:07:37 Extracted: /tmp/arkade-2055899785/helm 2025/05/25 21:07:37 Copying /tmp/arkade-2055899785/helm to /home/fedora/.arkade/bin/helm Downloaded to: /home/fedora/.arkade/bin/helm helm "openfaas" has been added to your repositories Hang tight while we grab the latest from your chart repositories... ...Successfully got an update from the "openfaas" chart repository ...Successfully got an update from the "prometheus-community" chart repository Update Complete. ⎈Happy Helming!⎈ VALUES values.yaml Command: /home/fedora/.arkade/bin/helm [upgrade --install openfaas openfaas/openfaas --namespace openfaas --values /tmp/charts/openfaas/values.yaml --set gateway.replicas=1 --set dashboard.enabled=false --set serviceType=NodePort --set openfaasImagePullPolicy=IfNotPresent --set faasnetes.imagePullPolicy=Always --set queueWorker.replicas=1 --set queueWorker.maxInflight=1 --set basic_auth=true --set gateway.directFunctions=false --set ingressOperator.create=false --set basicAuthPlugin.replicas=1 --set autoscaler.enabled=false --set dashboard.publicURL=http://127.0.0.1:8080 --set clusterRole=false --set operator.create=false] Release "openfaas" does not exist. Installing it now. NAME: openfaas LAST DEPLOYED: Sun May 25 21:07:39 2025 NAMESPACE: openfaas STATUS: deployed REVISION: 1 TEST SUITE: None NOTES: To verify that openfaas has started, run: kubectl -n openfaas get deployments -l "release=openfaas, app=openfaas" To retrieve the admin password, run: echo $(kubectl -n openfaas get secret basic-auth -o jsonpath="{.data.basic-auth-password}" | base64 --decode) ======================================================================= = OpenFaaS has been installed. = ======================================================================= # Get the faas-cli curl -SLsf https://cli.openfaas.com | sudo sh # Forward the gateway to your machine kubectl rollout status -n openfaas deploy/gateway kubectl port-forward -n openfaas svc/gateway 8080:8080 & # If basic auth is enabled, you can now log into your gateway: PASSWORD=$(kubectl get secret -n openfaas basic-auth -o jsonpath="{.data.basic-auth-password}" | base64 --decode; echo) echo -n $PASSWORD | faas-cli login --username admin --password-stdin faas-cli store deploy figlet faas-cli list # For Raspberry Pi faas-cli store list \ --platform armhf faas-cli store deploy figlet \ --platform armhf # Find out more at: # https://github.com/openfaas/faas 👏 Say thanks for arkade and sponsor Alex via GitHub: https://github.com/sponsors/alexellisYou can get this message again at any time with arkade info openfaas.
$ curl -SLsf https://cli.openfaas.com | sudo sh Finding latest version from GitHub 0.17.4 Downloading package https://github.com/openfaas/faas-cli/releases/download/0.17.4/faas-cli as /tmp/faas-cli Download complete. Running with sufficient permissions to attempt to move faas-cli to /usr/local/bin New version of faas-cli installed to /usr/local/bin ___ _____ ____ / _ \ _ __ ___ _ __ | ___|_ _ __ _/ ___| | | | | '_ \ / _ \ '_ \| |_ / _` |/ _` \___ \ | |_| | |_) | __/ | | | _| (_| | (_| |___) | \___/| .__/ \___|_| |_|_| \__,_|\__,_|____/ |_| CLI: commit: 30655b0cc01d71956e8eb1a8d40920199e9b066d version: 0.17.4
$ faas-cli store deploy figletHandling connection for 8080Deployed. 202 Accepted.URL: http://127.0.0.1:8080/function/figlet$ faas-cli listHandling connection for 8080Function Invocations Replicasfiglet 0 1
faas-cli store deploy figlet and faas-cli list. The first command deploys an ASCII generator function from the Function Store and the second command lists the deployed functions, you should see figlet listed.
Now, forw
ard the OpenFaaS gateway to your local machine so you can access it:
$ kubectl port-forward -n openfaas svc/gateway 8080:8080 & [1] 17311 $ Forwarding from 127.0.0.1:8080 -> 8080 Forwarding from [::1]:8080 -> 8080Retrieve the admin password and log in with the
faas-cli
:
PASSWORD=$(kubectl get secret -n openfaas basic-auth -o jsonpath="{.data.basic-auth-password}" | base64 --decode; echo)
echo -n $PASSWORD | faas-cli login --username admin --password-stdin
Calling the OpenFaaS server to validate the credentials...
Handling connection for 8080credentials saved for admin http://127.0.0.1:8080
$ echo $PASSWORD
Troubleshooting
If you encounter any issues, the OpenFaaS troubleshooting guide is an excellent resource:
You can also use standard kubectl
commands to inspect your OpenFaaS deployments, pods, and services within the openfaas
namespace:
$ kubectl -n openfaas get deployments
NAME READY UP-TO-DATE AVAILABLE AGE
alertmanager 1/1 1 1 17h
gateway 1/1 1 1 17h
nats 1/1 1 1 17h
prometheus 1/1 1 1 17h
queue-worker 1/1 1 1 17h
Alternative Installation: Using Helm Directly
arkade
simplifies the process, you can also install OpenFaaS directly using Helm.First, ensure you have Helm installed. You can get it with arkade:
$ arkade get helmOr, use the Helm installation script:
curl -sSLf https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 |
bash
arkade
, this step was handled automatically.)this will create openfaas
and openfaas-fn
namespaces.
$ helm repo add openfaas https://openfaas.github.io/faas-netes/
Update your Helm repositories and deploy OpenFaaS Community Edition (CE):
$ helm repo update \
&& helm upgrade openfaas \
--install openfaas/openfaas \
--namespace openfaas
Finally, retrieve the OpenFaaS admin password:
PASSWORD=$(kubectl -n openfaas get secret basic-auth -o jsonpath="{.data.basic-auth-password}" | base64 --decode) && \
echo "OpenFaaS admin password: $PASSWORD"
Conclusion
We successfully set up OpenFaaS on Kubernetes cluster locally, and deployed our first function (figlet). Start exploring the OpenFaaS documentation and the vast array of functions available in the store to build your next innovative application!
Comments
Post a Comment