This is an end-to-end example of Roleypoly's OpenFaaS gRPC system.
This is system is a proof of concept. Not used at scale or in production.
The design goals here are
- One FaaS deployment per gRPC method
- Scale-to-Zero (comes with OpenFaaS)
- Touch as little Kubernetes as possible.
Two projects help this succeed:
- openfaas-grpc-controller
- Kubernetes observer for pods that OpenFaaS deploys, and creates ingress routes for them.
- golang-grpc
- OpenFaaS template for wiring up gRPC methods.
Required:
- kubectl
- a kubernetes cluster (for local, try k3d.)
- k3sup
- faas-cli
- golang
Optional:
- nodejs (for webapp example)
# Install OpenFaaS
k3sup app install openfaas --set=faasIdler.dryRun=false
# Install Ingress Controller
k3sup app install nginx-ingress # --host-mode optional
# Install ingress-operator and grpc-controller
kubectl apply -f ./k8s/bootstrap
# Need OpenFaaS gateway to deploy
kubectl port-forward -n openfaas svc/gateway 8080:8080 &
# Need ingress controller to use the magic!!
kubectl port-forward svc/nginx-ingress-controller 8081:80 & # testers assume localhost:8081
faas login --password $(kubectl get secret -n openfaas basic-auth -o jsonpath="{.data.basic-auth-password}" | base64 --decode; echo)
cd functions
faas deploy stack.yml
(fyi, you'll need to change image paths in ./functions/stack.yml
to deploy changes)
CLI (not currently working. HTTPS is required.)
go run ./tester SayHello Taylor
go run ./tester SayHelloAgain Taylor
Web App (yeah this shit works in your browser too)
cd tester-webapp
npm start
./proto/greeter
is generated by tooling inside Roleypoly RPC repo. If you wish to change the definitions, copy that folder into that repo, then run go generate
or yarn generate
, and copy it back. My personal recommendation is your RPC defs living in another repo like this, which enables offline-ish builds.