Skip to content

Instantly share code, notes, and snippets.

@jezeniel
Last active February 6, 2019 08:03
Show Gist options
  • Save jezeniel/35a7367fcccf62297389ec3b3e3e2b50 to your computer and use it in GitHub Desktop.
Save jezeniel/35a7367fcccf62297389ec3b3e3e2b50 to your computer and use it in GitHub Desktop.
OpenFaas Local Setup

OpenFaas

export OPENFAAS_URL

# list available templates
faas new --list 

faas new --lang <template name> <function name>

faas build -f <yaml>
faas push -f <yaml>
faas deploy -f <yaml>

Kubernetes

# Use `-n` flag for namespaces
kubectl version
kubectl get nodes
kubectl get deployments
kubectl get ns
kubectl get svc
kubectl delete deployment
kubectl describe <resource>

# Create a deployment
kubectl run --image=<image_name>

# Create a service
kubectl expose deployment <deployment name> --type="<service type>" --port"<port >"

# Apply a label
kubectl label pods <pod name> key=value

# Exec to a pod
kubectl exec -it <pod name> <command>

Helm

# Download chart locally
helm fetch <repo>

# Install a chart
helm install <repo> --name <release name> -f <values file> --namespace <namespace>

# Delete a release
helm delete --purge <release name>

# List existing release
helm ls

# Check release status
helm status

Installation

Local Development

Currently tested on Docker For Desktop built-in kubernetes.

Install both kubectl and helm. kubectl should be configured to point to your local kubernetes cluster.

Create two namespaces for openfaas which are openfaas and openfaas-fn:

$ kubectl apply -f https://raw.githubusercontent.com/openfaas/faas-netes/master/namespaces.yml

Add the openfaas repo in helm:

$ helm repo add openfaas https://openfaas.github.io/faas-netes/

Download the chart so we could modify the values.yaml to be able to configure the openfaas deployment for local developent:

$ helm fetch openfaas/openfaas

The above command will download a .tgz file extract it and modify the following values in values.yaml inside the directory:

# values.yaml
rbac: false
basic_auth: false

faasnetesd:
  imagePullPolicy: "IfNotPresent"

Then install openfaas:

$ helm install openfaas/openfaas -f values.yaml --name openfaas-dev --namespace openfaas

A gateway-external NodePort service will be created for port 31112. To access openfaas ui visit http://localhost:31112 on your machine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment