{"id":14384207,"url":"https://github.com/kelseyhightower/riff-tutorial","last_synced_at":"2025-07-01T23:02:38.543Z","repository":{"id":65979077,"uuid":"121164688","full_name":"kelseyhightower/riff-tutorial","owner":"kelseyhightower","description":"How-to guide for testing the riff FaaS platform and Istio on Google Kubernetes Engine.","archived":false,"fork":false,"pushed_at":"2018-02-12T15:17:32.000Z","size":12,"stargazers_count":97,"open_issues_count":0,"forks_count":9,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-30T01:37:42.346Z","etag":null,"topics":["containers","faas","istio","kubernetes","riff","serverless"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kelseyhightower.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-02-11T20:35:55.000Z","updated_at":"2024-01-21T19:26:56.000Z","dependencies_parsed_at":"2023-02-19T18:31:06.590Z","dependency_job_id":null,"html_url":"https://github.com/kelseyhightower/riff-tutorial","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/kelseyhightower/riff-tutorial","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kelseyhightower%2Friff-tutorial","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kelseyhightower%2Friff-tutorial/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kelseyhightower%2Friff-tutorial/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kelseyhightower%2Friff-tutorial/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kelseyhightower","download_url":"https://codeload.github.com/kelseyhightower/riff-tutorial/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kelseyhightower%2Friff-tutorial/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263047659,"owners_count":23405280,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["containers","faas","istio","kubernetes","riff","serverless"],"created_at":"2024-08-28T18:01:12.727Z","updated_at":"2025-07-01T23:02:38.504Z","avatar_url":"https://github.com/kelseyhightower.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# Riff Tutorial\n\nThe riff tutorial walks you through installing the [riff FaaS platform](https://projectriff.io) and [Istio](https://istio.io/about/intro.html) on [Google Kubernetes Engine](https://cloud.google.com/kubernetes-engine). The resulting environment is great for demos and exploring riff and Istio, but should not be considered production ready.\n\nBe sure to watch Mark Fisher's SpringOne [riff announcement keynote and live demo](https://projectriff.io/video/mark-fisher-at-springone-platform-2017/) to get up to speed on riff.\n\n\u003e 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.\n\n## Tutorial\n\nCreate a Kubernetes cluster large enough to host the riff and istio components:\n\n```\ngcloud container clusters create riff \\\n  --cluster-version 1.9.2-gke.1 \\\n  --machine-type n1-standard-4 \\\n  --num-nodes 5\n```\n\n\u003e Smaller clusters should work, but only the configuration above has been tested.\n\nGrant cluster admin permissions to the current user. Admin permissions are required to create the necessary RBAC rules for riff and Istio.\n\n```\nkubectl create clusterrolebinding cluster-admin-binding \\\n  --clusterrole=cluster-admin \\\n  --user=$(gcloud config get-value core/account)\n```\n\n### Install Istio\n\nInstall Istio into the `istio-system` namespace:\n\n```\nkubectl apply -f https://raw.githubusercontent.com/kelseyhightower/riff-tutorial/master/istio.yaml\n```\n\n\u003e The following addons are also installed: [Prometheus](https://istio.io/docs/tasks/telemetry/metrics-logs.html), [Grafana](https://istio.io/docs/tasks/telemetry/using-istio-dashboard.html), [Jaeger](https://istio.io/docs/tasks/telemetry/distributed-tracing.html), and [Istio Sidecar Injector](https://istio.io/docs/setup/kubernetes/sidecar-injection.html#automatic-sidecar-injection).\n\nWait until each Istio component is running:\n\n```\nkubectl get pods -n istio-system\n```\n```\nNAME                                      READY     STATUS    RESTARTS   AGE\ngrafana-6585bdf64c-8k45v                  1/1       Running   0          39s\nistio-ca-7876b944bc-fx9r9                 1/1       Running   0          40s\nistio-ingress-d8d5fdc86-4n6hr             1/1       Running   0          40s\nistio-mixer-65bb55df98-b9gwb              3/3       Running   0          46s\nistio-pilot-5cb545f47c-ppf6c              2/2       Running   0          40s\nistio-sidecar-injector-6bb584c47d-xd6x6   1/1       Running   0          38s\njaeger-deployment-559c8b9b8-d4l9h         1/1       Running   0          39s\nprometheus-5db8cc75f8-hxdc5               1/1       Running   0          40s\n```\n\n### Install riff\n\nInstall riff into the `riff` namespace and enable [Istio automatic sidecar injection](https://istio.io/docs/setup/kubernetes/sidecar-injection.html#deploying-an-app):\n\n```\nkubectl apply -f https://raw.githubusercontent.com/kelseyhightower/riff-tutorial/master/riff.yaml\n```\n\nWait until each riff component is running:\n\n```\nkubectl get pods -n riff\n```\n```\nNAME                                   READY     STATUS    RESTARTS   AGE\nfunction-controller-54f964dc6c-qv9cf   2/2       Running   0          47s\nhttp-gateway-56d47d5dd-frgb4           2/2       Running   2          46s\nkafka-broker-697bbbcbf8-j5mz2          2/2       Running   1          47s\ntopic-controller-54cbc965bc-nm7rr      2/2       Running   0          46s\nzookeeper-77dbfc6cf8-zrlwp             2/2       Running   0          47s\n```\n\n\u003e Restarts of the `http-gateway` and `kafka-broker` are expected as kafka depends on zookeeper, and the http-gateway depends on kafka.\n\n### Creating and Executing Fuctions\n\nEnsure the istio sidecar is injected into every riff function created in the default namespace.\n\n```\nkubectl label namespace default istio-injection=enabled\n```\n\n\u003e riff functions are packaged and deployed as pods which is why the istio injection works.\n\nCreate a topic that will trigger the `helloriff` function container:\n\n```\nkubectl apply -f https://raw.githubusercontent.com/kelseyhightower/riff-tutorial/master/topics/helloriff.yaml\n```\n\nCreate the `helloriff` function:\n\n```\nkubectl apply -f https://raw.githubusercontent.com/kelseyhightower/riff-tutorial/master/functions/helloriff.yaml\n```\n\n\u003e 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.\n\nOnce the function has been defined the riff `function-controller` will create a deployment with an initial replica count set to zero.\n\n```\nkubectl get deployment\n```\n```\nNAME        DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE\nhelloriff   0         0         0            0           12s\n```\n\nriff will scale up the number of pods based on the flow of incoming requests to the riff `http-gateway`.\n\n### Invoking the Function\n\nRetrieve the IP address of the riff `http-gateway` ingress:\n\n\n```\nHTTP_GATEWAY_IP=$(kubectl get ingress http-gateway -n riff \\\n  -o jsonpath='{.status.loadBalancer.ingress[0].ip}')\n```\n\nExecute an HTTP request to the riff `http-gateway` to invoke the `helloriff` function:\n\n\n```\ncurl http://${HTTP_GATEWAY_IP}/requests/helloriff\n```\n\nThe `curl` command will take a few moments to complete while the `function-controller` scales up the `helloriff` deployment in the background:\n\n```\nkubectl get deployments helloriff\n```\n```\nNAME        DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE\nhelloriff   1         1         1            1           1m\n```\n\nNotice the `helloriff` function pod contains three containers: istio-sidecar, riff-sidecar, and the helloriff container defined in the [function definition](https://github.com/kelseyhightower/riff-tutorial/blob/master/functions/helloriff.yaml).\n\n```\nkubectl get pods\n```\n```\nNAME                         READY     STATUS    RESTARTS   AGE\nhelloriff-747b8b5685-fhjf4   3/3       Running   1          11s\n```\n\n\u003e The `helloriff` pod restart is expected and maybe related to the interaction between the riff sidecar and kafka.\n\n## Cleanup\n\nDelete all riff resources:\n\n```\nkubectl delete ns riff\n```\n\nDelete all istio resources:\n\n```\nkubectl delete ns istio-system\n```\n\nDelete the Kubernetes cluster:\n\n```\ngcloud container clusters delete riff\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkelseyhightower%2Friff-tutorial","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkelseyhightower%2Friff-tutorial","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkelseyhightower%2Friff-tutorial/lists"}