-
Notifications
You must be signed in to change notification settings - Fork 0
/
host.sh
executable file
·34 lines (30 loc) · 1.93 KB
/
host.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
open -a docker # get docker running in background
minikube start # starts a new Kubernetes local cluster
arkade install openfaas # install OpenFaaS in Helm
echo 'waiting for openfaas pod to get ready'
until $(kubectl get all -n openfaas | grep pod/gateway | grep -q Running); do
# may take a while to avoid "error: unable to forward port because pod is not running. Current status=Pending" and get the Pod (cluster) ready
echo -n '.'
sleep 10
done
echo 'done'
kubectl port-forward svc/gateway -n openfaas 8080:8080 &
# tunnel between local computer with the Kubernetes cluster
jobs # the tunnelling job should be running in background
echo 'waiting for openfaas URL to get ready'
until $(kubectl -n openfaas get pods | grep faas-idler | grep -q Running); do
# may take a while to avoid "Cannot connect to OpenFaaS on URL: http://xxx.xxx.xx.xxx:31112. Get http://xxx.xxx.xx.xxx:31112/system/functions: dial tcp xxx.xxx.xx.xxx:31112: connect: connection refused" and get the URL ready
echo -n '.'
sleep 10
done
echo 'done'
export OPENFAAS_URL=http://$(minikube ip):31112
# remember the hosted URL for OpenFaaS
PASSWORD=$(kubectl get secret -n openfaas basic-auth -o jsonpath="{.data.basic-auth-password}" | base64 --decode; echo)
# generate password for OpenFaaS and register it
echo -n $PASSWORD | faas-cli login --username admin --password-stdin -g $OPENFAAS_URL
# login to OpenFaaS
faas-cli list # success check
faas template pull "https://github.com/openfaas-incubator/node10-express-template"
faas template pull "https://github.com/openfaas-incubator/node10-express-service"
# add custom templates for building functions