In Part 1 we deployed a Kubernetes cluster using RKE (Rancher Kubernetes Engine). Now that we have a working Kubernetes cluster, let’s deploy OpenFaaS (an open source serverless platform) on top of it!
This post is not going into details about OpenFaaS. For introductions related to OpenFaaS on Kubernetes, you should read “Getting started with OpenFaaS on minikube” written by Alex Ellis (the creator of OpenFaaS).
I’m assuming:
kubectl
is set to target the Kubernetes cluster you built on Part 1First, let’s setup Helm by first creating a service account for tiller:
kubectl -n kube-system create sa tiller \&& kubectl create clusterrolebinding tiller \--clusterrole cluster-admin \--serviceaccount=kube-system:tiller
# serviceaccount “tiller” created# clusterrolebinding “tiller” created
Then, install tiller:
helm init —-skip-refresh --upgrade --service-account tiller
# $HELM_HOME has been configured at /Users/fukuyamaken/.helm.
# Tiller (the Helm server-side component) has been installed into your Kubernetes Cluster.# Happy Helming!
After that, let’s clone the kubernetes extension repository for OpenFaaS called faas-netes
and cd
to that directory. The resources required for Helm are included in this repository.
git clone https://github.com/openfaas/faas-netes && \cd faas-netes
Finally, deploy OpenFaaS to the cluster. Note that we’re disabling rbac because this cluster’s rbac isn’t configured properly.
helm upgrade --install --debug --reset-values --set rbac=false --set async=false openfaas openfaas/
Confirm that Kubernetes Services and Deployments are running with kubectl get svc,deployments
:
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGEsvc/alertmanager ClusterIP 10.233.18.46 <none> 9093/TCP 4msvc/alertmanager-external NodePort 10.233.1.242 <none> 9093:31113/TCP 4msvc/faas-netesd ClusterIP 10.233.37.207 <none> 8080/TCP 4msvc/faas-netesd-external NodePort 10.233.26.167 <none> 8080:31111/TCP 4msvc/gateway ClusterIP 10.233.55.73 <none> 8080/TCP 4msvc/gateway-external NodePort 10.233.57.162 <none> 8080:31112/TCP 4msvc/kubernetes ClusterIP 10.233.0.1 <none> 443/TCP 2hsvc/prometheus ClusterIP 10.233.46.236 <none> 9090/TCP 4msvc/prometheus-external NodePort 10.233.15.159 <none> 9090:31119/TCP 4m
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGEdeploy/alertmanager 1 1 1 1 4mdeploy/faas-netesd 1 1 1 1 4mdeploy/gateway 1 1 1 1 4mdeploy/prometheus 1 1 1 1 4m
Now that OpenFaaS is running on Kubernetes let’s test it! Go to your worker node’s port 31112
(in my case it’s 203.104.227.60:31112
). You should see the gateway UI like the following capture:
OpenFaaS Gateway UI
Let’s deploy a new function via the Function Store. I love theFiglet
function made by Johnny Mkhael. Let’s select it and hit Deploy
.
OpenFaaS Function Store
After deploying and refreshing the UI, you should see figlet
on the function list. Let’s type some cool words and INVOKE
the function.
Invoking the Figlet Function
Awesome! OpenFaaS running on Kubernetes deployed by RKE (Rancher Kubernetes Engine). With 2 nodes that only have 1 core and 1GB RAM! Note that memory intensive and cpu intensive functions may not work because of lack of resources. In those cases, you should add some more hosts with resources.
This 2 part blog post showed how easily you can create a Kubernetes cluster via RKE and how easily you can deploy OpenFaaS on it. From here you can integrate other components with OpenFaaS as well, and this should be a good start point!