All Projects → kelseyhightower → Riff Tutorial

kelseyhightower / Riff Tutorial

Licence: apache-2.0
How-to guide for testing the riff FaaS platform and Istio on Google Kubernetes Engine.

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Riff Tutorial

Docs
User documentation for Knative components.
Stars: ✭ 3,106 (+3037.37%)
Mutual labels:  serverless, faas, istio
Faasd
A lightweight & portable faas engine
Stars: ✭ 1,330 (+1243.43%)
Mutual labels:  serverless, faas, containers
Nuclio
High-Performance Serverless event and data processing platform
Stars: ✭ 4,213 (+4155.56%)
Mutual labels:  serverless, faas, containers
Knctl
Knative CLI
Stars: ✭ 163 (+64.65%)
Mutual labels:  serverless, faas, containers
Fn
The container native, cloud agnostic serverless platform.
Stars: ✭ 5,046 (+4996.97%)
Mutual labels:  serverless, faas, containers
Navagraha
Simple FaaS Framework
Stars: ✭ 15 (-84.85%)
Mutual labels:  serverless, faas
Saasify
The easiest way to monetize your API. 🚀
Stars: ✭ 912 (+821.21%)
Mutual labels:  serverless, faas
Openwhisk Runtime Nodejs
Apache OpenWhisk Runtime NodeJS supports Apache OpenWhisk functions written in JavaScript for NodeJS
Stars: ✭ 43 (-56.57%)
Mutual labels:  serverless, faas
Alagarr
🦍 Alagarr is a request-response helper library that removes the boilerplate from your Node.js (AWS Lambda) serverless functions and helps make your code portable.
Stars: ✭ 58 (-41.41%)
Mutual labels:  serverless, faas
Openwhisk Runtime Php
Apache OpenWhisk Runtime PHP supports Apache OpenWhisk functions written in PHP
Stars: ✭ 26 (-73.74%)
Mutual labels:  serverless, faas
Mongodb Function
OpenFaaS Function that makes use of a connection pool to access MongoDB
Stars: ✭ 44 (-55.56%)
Mutual labels:  serverless, faas
Pulumi
Pulumi - Developer-First Infrastructure as Code. Your Cloud, Your Language, Your Way 🚀
Stars: ✭ 10,887 (+10896.97%)
Mutual labels:  serverless, containers
Microless
Using docker and nodejs to build Microservice
Stars: ✭ 14 (-85.86%)
Mutual labels:  serverless, faas
Serverless Faas Workbench
FunctionBench
Stars: ✭ 32 (-67.68%)
Mutual labels:  serverless, faas
K8s On Raspbian
Kubernetes on Raspbian (Raspberry Pi)
Stars: ✭ 839 (+747.47%)
Mutual labels:  serverless, faas
Openwhisk Apigateway
Apache OpenWhisk API Gateway service for exposing actions as REST interfaces.
Stars: ✭ 56 (-43.43%)
Mutual labels:  serverless, faas
Openwhisk Cli
Apache OpenWhisk Command Line Interface (CLI)
Stars: ✭ 73 (-26.26%)
Mutual labels:  serverless, faas
Community Cluster
OpenFaaS Cloud Cluster for Community
Stars: ✭ 59 (-40.4%)
Mutual labels:  serverless, faas
Hook.io
Open-Source Microservice Hosting Platform
Stars: ✭ 1,201 (+1113.13%)
Mutual labels:  serverless, faas
Faast.js
Serverless batch computing made simple.
Stars: ✭ 1,323 (+1236.36%)
Mutual labels:  serverless, faas

Riff Tutorial

The riff tutorial walks you through installing the riff FaaS platform and Istio on Google Kubernetes Engine. The resulting environment is great for demos and exploring riff and Istio, but should not be considered production ready.

Be sure to watch Mark Fisher's SpringOne riff announcement keynote and live demo to get up to speed on riff.

In addition to the environment Mark demo'd in his keynote, this tutorial integrates Istio and riff to provide traffic management for the riff http gateway and runs each function managed by riff in the Istio service mesh.

Tutorial

Create a Kubernetes cluster large enough to host the riff and istio components:

gcloud container clusters create riff \
  --cluster-version 1.9.2-gke.1 \
  --machine-type n1-standard-4 \
  --num-nodes 5

Smaller clusters should work, but only the configuration above has been tested.

Grant cluster admin permissions to the current user. Admin permissions are required to create the necessary RBAC rules for riff and Istio.

kubectl create clusterrolebinding cluster-admin-binding \
  --clusterrole=cluster-admin \
  --user=$(gcloud config get-value core/account)

Install Istio

Install Istio into the istio-system namespace:

kubectl apply -f https://raw.githubusercontent.com/kelseyhightower/riff-tutorial/master/istio.yaml

The following addons are also installed: Prometheus, Grafana, Jaeger, and Istio Sidecar Injector.

Wait until each Istio component is running:

kubectl get pods -n istio-system
NAME                                      READY     STATUS    RESTARTS   AGE
grafana-6585bdf64c-8k45v                  1/1       Running   0          39s
istio-ca-7876b944bc-fx9r9                 1/1       Running   0          40s
istio-ingress-d8d5fdc86-4n6hr             1/1       Running   0          40s
istio-mixer-65bb55df98-b9gwb              3/3       Running   0          46s
istio-pilot-5cb545f47c-ppf6c              2/2       Running   0          40s
istio-sidecar-injector-6bb584c47d-xd6x6   1/1       Running   0          38s
jaeger-deployment-559c8b9b8-d4l9h         1/1       Running   0          39s
prometheus-5db8cc75f8-hxdc5               1/1       Running   0          40s

Install riff

Install riff into the riff namespace and enable Istio automatic sidecar injection:

kubectl apply -f https://raw.githubusercontent.com/kelseyhightower/riff-tutorial/master/riff.yaml

Wait until each riff component is running:

kubectl get pods -n riff
NAME                                   READY     STATUS    RESTARTS   AGE
function-controller-54f964dc6c-qv9cf   2/2       Running   0          47s
http-gateway-56d47d5dd-frgb4           2/2       Running   2          46s
kafka-broker-697bbbcbf8-j5mz2          2/2       Running   1          47s
topic-controller-54cbc965bc-nm7rr      2/2       Running   0          46s
zookeeper-77dbfc6cf8-zrlwp             2/2       Running   0          47s

Restarts of the http-gateway and kafka-broker are expected as kafka depends on zookeeper, and the http-gateway depends on kafka.

Creating and Executing Fuctions

Ensure the istio sidecar is injected into every riff function created in the default namespace.

kubectl label namespace default istio-injection=enabled

riff functions are packaged and deployed as pods which is why the istio injection works.

Create a topic that will trigger the helloriff function container:

kubectl apply -f https://raw.githubusercontent.com/kelseyhightower/riff-tutorial/master/topics/helloriff.yaml

Create the helloriff function:

kubectl apply -f https://raw.githubusercontent.com/kelseyhightower/riff-tutorial/master/functions/helloriff.yaml

You'll notice we are creating a function without writing any code. riff support using containers as "functions". In this case the gcr.io/hightowerlabs/helloriff:0.0.1 container will be mapped to events on the helloriff topic.

Once the function has been defined the riff function-controller will create a deployment with an initial replica count set to zero.

kubectl get deployment
NAME        DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
helloriff   0         0         0            0           12s

riff will scale up the number of pods based on the flow of incoming requests to the riff http-gateway.

Invoking the Function

Retrieve the IP address of the riff http-gateway ingress:

HTTP_GATEWAY_IP=$(kubectl get ingress http-gateway -n riff \
  -o jsonpath='{.status.loadBalancer.ingress[0].ip}')

Execute an HTTP request to the riff http-gateway to invoke the helloriff function:

curl http://${HTTP_GATEWAY_IP}/requests/helloriff

The curl command will take a few moments to complete while the function-controller scales up the helloriff deployment in the background:

kubectl get deployments helloriff
NAME        DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
helloriff   1         1         1            1           1m

Notice the helloriff function pod contains three containers: istio-sidecar, riff-sidecar, and the helloriff container defined in the function definition.

kubectl get pods
NAME                         READY     STATUS    RESTARTS   AGE
helloriff-747b8b5685-fhjf4   3/3       Running   1          11s

The helloriff pod restart is expected and maybe related to the interaction between the riff sidecar and kafka.

Cleanup

Delete all riff resources:

kubectl delete ns riff

Delete all istio resources:

kubectl delete ns istio-system

Delete the Kubernetes cluster:

gcloud container clusters delete riff
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].