Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Commit

Permalink
cluster operations
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanprodan committed Nov 27, 2017
1 parent f6eb142 commit c75b2b4
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 3 deletions.
6 changes: 4 additions & 2 deletions cluster-up.sh
Expand Up @@ -4,15 +4,17 @@ set -o errexit
set -o pipefail
set -o nounset

k8s_version=$(gcloud container get-server-config --format=json | jq -r '.validNodeVersions[0]')

gcloud container clusters create demo \
--cluster-version=1.8.3-gke.0 \
--cluster-version=${k8s_version} \
--zone=europe-west3-a \
--additional-zones=europe-west3-b,europe-west3-c \
--num-nodes=1 \
--machine-type=n1-standard-1 \
--scopes=default,storage-rw

gcloud container clusters get-credentials demo
gcloud container clusters get-credentials demo -z=europe-west3-a

kubectl create clusterrolebinding "cluster-admin-$(whoami)" \
--clusterrole=cluster-admin \
Expand Down
2 changes: 1 addition & 1 deletion faas-async-down.sh → openfaas-down.sh
Expand Up @@ -4,4 +4,4 @@ set -o errexit
set -o pipefail
set -o nounset

kubectl delete -f ./ns.yml
kubectl delete -f ./namespaces.yaml
44 changes: 44 additions & 0 deletions openfaas-up.sh
@@ -0,0 +1,44 @@
#!/usr/bin/env bash

set -o errexit
set -o pipefail
set -o nounset

get_gateway_ip() {
kubectl -n openfaas describe service caddy-lb | grep Ingress | awk '{ print $NF }'
}

# validate inputs
if [ -z "$basic_auth_user" ]; then
echo "basic_auth_user is required"
exit 1
fi

if [ -z "$basic_auth_password" ]; then
echo "basic_auth_password is required"
exit 1
fi

# create namespaces
kubectl apply -f ./namespaces.yaml

# create basic-auth secrets
kubectl -n openfaas create secret generic basic-auth \
--from-literal=user=${basic_auth_user} \
--from-literal=password=${basic_auth_password}

# deploy OpenFaaS
kubectl apply -f ./openfaas

# wait for the public IP to assigned
until [[ "$(get_gateway_ip)" ]]
do sleep 1;
echo -n ".";
done
echo "."
gateway_ip=$(get_gateway_ip)
echo "OpenFaaS Gateway IP: ${gateway_ip}"

# save OpenFaaS credentials
echo ${basic_auth_password} | faas-cli login -u ${basic_auth_user} --password-stdin --gateway=http://${gateway_ip}

0 comments on commit c75b2b4

Please sign in to comment.