Install Apps on Kubernetes with Arkade

Arkade is a really cool tool developed by Alex Ellis, which allow you to deploy applications on your Kubernetes Cluster.

Install Arkade

Installing arkade is as easy as:

$ curl -sLS | sudo sh
Downloading package as /tmp/arkade-darwin  
Download complete.

Running with sufficient permissions to attempt to move arkade to /usr/local/bin  
New version of arkade installed to /usr/local/bin  
Creating alias 'ark' for 'arkade'.  
            _             _
  __ _ _ __| | ____ _  __| | ___
 / _` | '__| |/ / _` |/ _` |/ _ \
| (_| | |  |   < (_| | (_| |  __/
 \__,_|_|  |_|\_\__,_|\__,_|\___|

Get Kubernetes apps the easy way

Version: 0.3.3  
Git Commit: 519c056683d63bb90cfae60b83c8e136138a7644  

To view all available applications that can be installed:

$ arkade install --help                                                                                                                                           130 ↵
Install Kubernetes apps from helm charts or YAML files using the "install"  
command. Helm 3 is used by default unless you pass --helm3=false, then helm 2  
will be used to generate YAML files which are applied without tiller.

You can also find the post-install message for each app with the "info"  

  arkade install [flags]
  arkade install [command]

  arkade install
  arkade install openfaas --helm3 --gateways=2
  arkade install inlets-operator --token-file $HOME/do-token

Available Commands:  
  argocd                  Install argocd
  cert-manager            Install cert-manager
  chart                   Install the specified helm chart
  cron-connector          Install cron-connector for OpenFaaS
  crossplane              Install Crossplane
  docker-registry         Install a Docker registry
  docker-registry-ingress Install registry ingress with TLS
  grafana                 Install grafana
  info                    Find info about a Kubernetes app
  ingress-nginx           Install ingress-nginx
  inlets-operator         Install inlets-operator
  istio                   Install istio
  jenkins                 Install jenkins
  kafka-connector         Install kafka-connector for OpenFaaS
  kube-state-metrics      Install kube-state-metrics
  kubernetes-dashboard    Install kubernetes-dashboard
  linkerd                 Install linkerd
  metrics-server          Install metrics-server
  minio                   Install minio
  mongodb                 Install mongodb
  openfaas                Install openfaas
  openfaas-ingress        Install openfaas ingress with TLS
  portainer               Install portainer to visualise and manage containers
  postgresql              Install postgresql
  tekton                  Install Tekton pipelines and dashboard
  traefik2                Install traefik2

Installing OpenFaas

Let's install openfaas with arkade. But first, let's ensure we can reach our kubernetes cluster:

$ kubectl get nodes -o wide
rpi-06   Ready    master   18h   v1.18.2+k3s1   <none>        Raspbian GNU/Linux 10 (buster)   4.19.97-v7l+     containerd://1.3.3-k3s2  

Now install openfaas:

$ arkade install openfaas

You can run this to wait until the deployment is complete:

$ kubectl rollout status -n openfaas deploy/gateway

When everything is done, it should look like this:

$ kubectl get pods -n openfaas
NAME                               READY   STATUS    RESTARTS   AGE  
queue-worker-85dc5d8dc8-4jm9t      1/1     Running   4          17h  
nats-7df64f5d8-lf864               1/1     Running   2          17h  
alertmanager-6dbd9cbddf-b6hgb      1/1     Running   2          17h  
basic-auth-plugin-d4c78979-4ztgn   1/1     Running   2          17h  
prometheus-c7ddf7c44-9vdxv         1/1     Running   2          17h  
gateway-55868bdf74-wtfwv           2/2     Running   5          17h  
faas-idler-796d96f964-cnb2q        1/1     Running   6          17h  

Deploy a Traefik Ingress

Since we k3s ships with Traefik by default, let's create a ingress so that we can access the openfaas gateway on openfaas.rpi.local:

$ cat openfaas_ingress.yml
apiVersion: extensions/v1beta1  
kind: Ingress  
  name: openfaas-gateway-ingress
  namespace: openfaas
  annotations: traefik
  - host: openfaas.rpi.local
      - backend:
          serviceName: gateway
          servicePort: 8080

Deploy the ingress:

$ kubectl apply -f openfaas_ingress.yml
ingress.extensions/openfaas-gateway-ingress created  

Access OpenFaas

Get the password:

$ kubectl get secret -n openfaas basic-auth -o jsonpath="{.data.basic-auth-password}" | base64 --decode; echo

Now using the username admin and the received password string, you will be able to login to the openfaas gateway:


Get the OpenFaas CLI

Get the openfaas cli:

$ curl -SLsf | sudo sh

Before we login to the openfaas gateway, let's set the openfaas endpoint:

$ export OPENFAAS_URL="http://openfaas.rpi.local"

Then save the openfaas secret as an environment variable:

$ PASSWORD=$(kubectl get secret -n openfaas basic-auth -o jsonpath="{.data.basic-auth-password}" | base64 --decode; echo)

Then authorize the cli:

$ echo -n $PASSWORD | faas-cli login --username admin --password-stdin

List your functions using the cli:

$ faas-cli list
Function                          Invocations     Replicas  

To list the available functions in the store for ARM architecture:

$ faas-cli store list --platform armhf

FUNCTION                    DESCRIPTION  
NodeInfo                    Get info about the machine that you'r...  
Figlet                      Generate ASCII logos with the figlet CLI  
SSL/TLS cert info           Returns SSL/TLS certificate informati...  
YouTube Video Downloader    Download YouTube videos as a function  
OpenFaaS Text-to-Speech     Generate an MP3 of text using Google'...  
nslookup                    Uses nslookup to return any IP addres...  
Docker Image Manifest Query Query an image on the Docker Hub for ...  
Left-Pad                    left-pad on OpenFaaS  
Identicon Generator         Create an identicon from a provided s...  

Let's deploy the nodeinfo function:

$ faas-cli store deploy nodeinfo --platform armhf

Deployed. 202 Accepted.  
URL: http://openfaas.rpi.local/function/nodeinfo  

Invoking the function via the cli:

$ echo -n "" | faas-cli invoke nodeinfo
Hostname: nodeinfo-768577f7b5-pwmtd

Arch: arm  
CPUs: 4  
Total mem: 3956MB  
Platform: linux  
Uptime: 30448  

Invoking the function via the api:

$ curl http://openfaas.rpi.local/function/nodeinfo
Hostname: nodeinfo-768577f7b5-pwmtd

Arch: arm  
CPUs: 4  
Total mem: 3956MB  
Platform: linux  
Uptime: 30484  

Create your Own Function

$ faas-cli new --lang python3-armhf --prefix-ruanbekker helloworld

Then we will have the following layout:

$ tree .
├── helloworld
│   ├──
│   ├──
│   └── requirements.txt
└── helloworld.yml

Open up the helloworld.yml file and you will see the prefix that I set is used for my dockerhub user, in my case:

$ cat helloworld.yml
version: 1.0  
  name: openfaas
  gateway: http://openfaas.rpi.local
    lang: python3-armhf
    handler: ./helloworld
    image: ruanbekker/helloworld-function

Deploy the standard function:

$ faas-cli up -f helloworld.yml

Deploying: helloworld.  
Deployed. 202 Accepted.  
URL: http://openfaas.rpi.local/function/helloworld  

If you want to customise your function:

$ cat helloworld/
def handle(req):  
    """handle a request to the function
        req (str): request body

    return req

Then to update your function, you can just run the following again:

$ faas-cli up -f helloworld.yml