Skip to content

Example: Publish an OpenFaaS function

This example will create a Kubernetes cluster using KinD, deploy OpenFaaS using Helm, deploy a function, then invoke the function. There are some additional checks for readiness for Kubernetes and the OpenFaaS gateway.

You can adapt this example for any other Helm charts you may have for E2E testing.

We also recommend considering arkade for installing CLIs and common Helm charts for testing.

Docker CE is preinstalled in the actuated VM image, and will start upon boot-up.

Certified for:

  • x86_64
  • arm64

Use a private repository if you're not using actuated yet

GitHub recommends using a private repository with self-hosted runners because changes can be left over from a previous run, even when using Actions Runtime Controller. Actuated uses an ephemeral VM with an immutable image, so can be used on both public and private repos. Learn why in the FAQ.

Try out the action on your agent

Create a new GitHub repository in your organisation.

Add: .github/workflows/e2e.yaml

name: e2e

      - '*'
      - '*'

  actions: read
  contents: read

    runs-on: actuated-4cpu-12gb
      - uses: actions/checkout@master
          fetch-depth: 1
      - name: get arkade
        uses: alexellis/setup-arkade@v1
      - name: get kubectl and kubectl
        uses: alexellis/arkade-get@master
          kubectl: latest
          kind: latest
          faas-cli: latest
      - name: Install Kubernetes KinD
        run: |
          mkdir -p $HOME/.kube/
          kind create cluster --wait 300s
      - name: Add Helm chart, update repos and apply namespaces
        run: |
            kubectl apply -f
            helm repo add openfaas
            helm repo update
      - name: Install the Community Edition (CE)
        run: |
            helm repo update \
            && helm upgrade openfaas --install openfaas/openfaas \
                --namespace openfaas  \
                --set functionNamespace=openfaas-fn \
                --set generateBasicAuth=true
      - name: Wait until OpenFaaS is ready
        run: |
            kubectl rollout status -n openfaas deploy/prometheus --timeout 5m
            kubectl rollout status -n openfaas deploy/gateway --timeout 5m
      - name: Port forward the gateway
        run: |
            kubectl port-forward -n openfaas svc/gateway 8080:8080 &


            until $(curl --output /dev/null --silent --fail ); do
                if [ ${attempts} -eq ${max} ]; then
                echo "Max attempts reached $max waiting for gateway's health endpoint"
                exit 1

                printf '.'
                sleep 1
      - name: Login to OpenFaaS gateway and deploy a function
        run: |
           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 env

           faas-cli invoke env <<< ""

           curl -s -f -i

           faas-cli invoke --async env <<< ""

           kubectl logs -n openfaas deploy/queue-worker

           faas-cli describe env

If you'd like to deploy the function, check out a more comprehensive example of how to log in and deploy in Serverless For Everyone Else