Skip to content
This repository has been archived by the owner on Mar 30, 2021. It is now read-only.

roleypoly/faas-rpc-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenFaaS gRPC Example

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:

prerequisites

Required:

  • kubectl
  • a kubernetes cluster (for local, try k3d.)
  • k3sup
  • faas-cli
  • golang

Optional:

  • nodejs (for webapp example)

bootstrap the cluster

# 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

port forward some stuff

# 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

login to openfaas

faas login --password $(kubectl get secret -n openfaas basic-auth -o jsonpath="{.data.basic-auth-password}" | base64 --decode; echo)

add the functions

cd functions
faas deploy stack.yml

(fyi, you'll need to change image paths in ./functions/stack.yml to deploy changes)

test it out

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

FYI

./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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published