Created
January 20, 2019 06:57
-
-
Save burtonr/577379fbc9a67b21ad823088447fccf8 to your computer and use it in GitHub Desktop.
OpenFaaS on KinD quickstart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "> Be KinD with OpenFaaS" | |
# First, check if docker is available | |
docker version | 2>/dev/null | |
if [ $? -ne 0 ]; then | |
echo "> Docker is required for running OpenFaaS on KinD" | |
echo "> Install with: 'curl -sLS https://get.docker.com | sudo sh'" | |
exit 1 | |
fi | |
# Make sure kubectl is available | |
kubectl version | 2>/dev/null | |
if [ $? -ne 0 ]; then | |
echo "> kubectl is required for running KinD" | |
echo "> Install on macOS: 'brew install kubernetes-cli' most Linux: 'sudo snap install kubectl --classic'" | |
exit 1 | |
fi | |
# Make sure go is available | |
go version | 2>/dev/null | |
if [ $? -ne 0 ]; then | |
echo "> Go is required for running KinD" | |
echo "> Follow this link to download and install GoLang: https://golang.org/dl/" | |
exit 1 | |
fi | |
# Make sure helm is available | |
helm version | 2>/dev/null | |
if [ $? -ne 0 ]; then | |
echo "> Helm is recommended for running OpenFaaS on Kubernetes" | |
echo "> Install with: 'curl -sLSf https://raw.githubusercontent.com/helm/helm/master/scripts/get | sudo bash'" | |
exit 1 | |
fi | |
# Make sure faas-cli is available | |
faas-cli version | 2>/dev/null | |
if [ $? -ne 0 ]; then | |
echo "> faas-cli is recommended for working with OpenFaaS" | |
echo "> Install on macOS: 'brew install faas-cli' or with: 'curl -sLSf https://cli.openfaas.com | sudo sh'" | |
exit 1 | |
fi | |
echo "> 'go get'-ing KinD" | |
go get sigs.k8s.io/kind | |
echo "> creating new KinD cluster 'openfaas'" | |
kind create cluster --name openfaas | |
echo "> switching kubectl context to KinD cluster" | |
export KUBECONFIG="$(kind get kubeconfig-path --name="openfaas")" | |
echo "> creating Tiller ServiceAccount" | |
kubectl -n kube-system create sa tiller \ | |
&& kubectl create clusterrolebinding tiller \ | |
--clusterrole cluster-admin \ | |
--serviceaccount=kube-system:tiller | |
echo "> installing Tiller server component to the KinD cluster" | |
helm init --skip-refresh --upgrade --service-account tiller | |
echo "> creating OpenFaaS namespaces" | |
kubectl apply -f https://raw.githubusercontent.com/openfaas/faas-netes/master/namespaces.yml | |
# TODO: there should be a better way to know that tiller is ready to go... | |
echo "> sleeping for 30 seconds to give Tiller time to start" | |
sleep 30s | |
echo "> installing OpenFaaS via helm" | |
helm repo add openfaas https://openfaas.github.io/faas-netes && \ | |
helm repo update && \ | |
helm upgrade openfaas --install openfaas/openfaas \ | |
--namespace openfaas \ | |
--set basic_auth=false \ | |
--set functionNamespace=openfaas-fn \ | |
--set operator.create=true | |
echo "> verifying OpenFaaS is available" | |
kubectl --namespace=openfaas get deployments -l "release=openfaas, app=openfaas" | |
echo "> run the following command is OpenFaaS is not yet available" | |
echo "> kubectl --namespace=openfaas get deployments -l \"release=openfaas, app=openfaas\"" | |
echo | |
echo | |
echo "> Final steps:" | |
echo "> * forward the OpenFaaS gateway port to access the UI: 'kubectl port-forward svc/gateway -n openfaas 8080:8080'" | |
echo "> * Deploy a sample function from the store: 'faas-cli store deploy figlet'" | |
echo "> * Test the function: 'echo Hi! | faas-cli invoke figlet'" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Scripted from the steps listed (and explained) in Alex Ellis' blog post: https://blog.alexellis.io/get-started-with-openfaas-and-kind/