riff is for functions

riff is for functions

  • Docs
  • Blog
  • GitHub
  • Slack

›Getting Started

Version (v0.6 snapshot)

  • v0.5.x
  • v0.4.x
  • v0.3.x

Getting Started

  • Pick your environment
  • GKE
  • Minikube
  • Docker for Mac
  • Docker for Windows
  • kind

Runtimes

  • Core
  • Knative
  • Streaming

Function Invokers

  • Java
  • Node.js
  • Command

CLI Reference

  • riff
  • riff doctor
  • riff completion
  • Credential

    • riff credential
    • riff credential apply
    • riff credential delete
    • riff credential list

    Build

    • riff function
    • riff function create
    • riff function delete
    • riff function list
    • riff function status
    • riff function tail
    • riff application
    • riff application create
    • riff application delete
    • riff application list
    • riff application status
    • riff application tail
    • riff container
    • riff container create
    • riff container delete
    • riff container list
    • riff container status

    Knative Runtime

    • riff knative
    • riff knative adapter
    • riff knative adapter create
    • riff knative adapter delete
    • riff knative adapter list
    • riff knative adapter status
    • riff knative deployer
    • riff knative deployer create
    • riff knative deployer delete
    • riff knative deployer list
    • riff knative deployer status
    • riff knative deployer tail

    Core Runtime

    • riff core
    • riff core deployer
    • riff core deployer create
    • riff core deployer delete
    • riff core deployer list
    • riff core deployer status
    • riff core deployer tail

    Streaming Runtime

    • riff streaming
    • riff streaming stream
    • riff streaming stream create
    • riff streaming stream delete
    • riff streaming stream list
    • riff streaming stream status
    • riff streaming processor
    • riff streaming processor create
    • riff streaming processor delete
    • riff streaming processor list
    • riff streaming processor status
    • riff streaming processor tail
    • riff streaming gateway
    • riff streaming gateway list
    • riff streaming gateway status

    In-memory Gateway

    • inmemory-gateway
    • inmemory-gateway create
    • inmemory-gateway delete
    • inmemory-gateway list
    • inmemory-gateway status

    Kafka Gateway

    • kafka-gateway
    • kafka-gateway create
    • kafka-gateway delete
    • kafka-gateway list
    • kafka-gateway status

    Pulsar Gateway

    • pulsar-gateway
    • pulsar-gateway create
    • pulsar-gateway delete
    • pulsar-gateway list
    • pulsar-gateway status
Edit

Getting started on Minikube

The following will help you get started running a riff function with Knative on Minikube.

To get started with streaming or with the core runtime, follow these steps first, and then continue with the Streaming or Core runtime docs. Runtimes can be used separately or together.

Install Minikube

v0.6 of riff requires Kubernetes v1.15 or later.

Minikube is a Kubernetes environment which runs in a single virtual machine. See the Getting Started page for installation information.

Minikube uses a hypervisor driver that varies by operating system. Some drivers are provided with Minikube while others requires an extra installation step. See the Driver page for details.

For macOS we recommend using Hyperkit as the vm-driver and for Linux we suggest using the KVM (kvm2) driver. You can select what driver to use as default using the minikube config set vm-driver command. Newer versions of Minikube seem to default to usig the hyperkit driver for MacOS and it is provided with Minikube, so no extra install needed. The kvm2 driver for Linux does require an extra install step.

Install Docker

Installing Docker Community Edition is the easiest way get started with Docker. Since Minikube includes its own Docker daemon, you actually only need the docker CLI to run docker login for --local-path function builds. This means that if you want to, you can shut down the Docker Desktop app and depend on the Minikube Docker daemon by running eval $(minikube docker-env).

Install kubectl

kubectl is the Kubernetes CLI. It is used to manage minikube as well as hosted Kubernetes clusters.

Create a Minikube cluster

minikube config set memory 5192
minikube config set cpus 4

minikube start

Confirm that your kubectl context is pointing to the new cluster:

kubectl config current-context

monitor your cluster

At this point it is useful to monitor your cluster using a utility like watch. To install on a Mac:

brew install watch

Watch pods in a separate terminal.

watch -n 1 kubectl get pod --all-namespaces

Install kapp

kapp is a simple deployment tool for Kubernetes. The riff runtime and its dependencies are provided as standard Kubernetes yaml files, that can be installed with kapp.

You can install kapp using Homebrew on MacOS:

brew tap k14s/tap
brew install kapp

Alternatively, Download a recent binary for your platform from github. Move it into a directory on your path, and make it executable. Complete kapp installation instructions can be found here

Validate the installation.

kapp version
Client Version: 0.18.0

Succeeded

Install ytt

ytt is a tool for templating yaml. It can be used to apply changes to the distributed Kubernetes yamls files used to install riff.

You can install ytt using Homebrew on MacOS:

brew tap k14s/tap
brew install ytt

Alternatively, Download a recent binary for your platform from github. Move it into a directory on your path, and make it executable. Complete ytt installation instructions can be found here

Validate the installation.

ytt version
Version: 0.23.0

Install a snapshot build of the riff CLI

Recent snapshot builds of the riff CLI for macOS, Windows, or Linux, can be downloaded from GCS.

Alternatively, clone the riff CLI repo, and run make build install. This will require a recent go build environment. On macOS you can use brew install go.

Check that the riff CLI version is 0.6.0-snapshot.

riff --version
riff version 0.6.0-snapshot (443fc9125dd6d8eecd1f7e1a13fa93b88fd4f972)

Install riff Using kapp

riff can be installed with optional runtimes. The riff build system is always installed, and is required by each runtime.

NOTE: If you have riff v0.4.0 installed then you must first uninstall that version. See instructions in the v0.4.0 documentation.

Create a namespace for kapp to store configuration:

kubectl create ns apps

install riff Build

To install riff build and it's dependencies:

kapp deploy -n apps -a cert-manager -f https://storage.googleapis.com/projectriff/release/0.6.0-snapshot/cert-manager.yaml
kapp deploy -n apps -a kpack -f https://storage.googleapis.com/projectriff/release/0.6.0-snapshot/kpack.yaml
kapp deploy -n apps -a riff-builders -f https://storage.googleapis.com/projectriff/release/0.6.0-snapshot/riff-builders.yaml
kapp deploy -n apps -a riff-build -f https://storage.googleapis.com/projectriff/release/0.6.0-snapshot/riff-build.yaml

install Contour ingress controller

The Contour ingress controller can be used by both Knative and Core runtimes.

# ytt is used to convert the ingress service to NodePort because Minikube does not support `LoadBalancer` services.
ytt -f https://storage.googleapis.com/projectriff/release/0.6.0-snapshot/contour.yaml -f https://storage.googleapis.com/projectriff/charts/overlays/service-nodeport.yaml --file-mark contour.yaml:type=yaml-plain | kapp deploy -n apps -a contour -f - -y

install riff Knative Runtime

To optionally install riff Knative Runtime and it's dependencies:

kapp deploy -n apps -a knative -f https://storage.googleapis.com/projectriff/release/0.6.0-snapshot/knative.yaml
kapp deploy -n apps -a riff-knative-runtime -f https://storage.googleapis.com/projectriff/release/0.6.0-snapshot/riff-knative-runtime.yaml

verify riff installation

Resources may be missing if the corresponding runtime was not installed.

riff doctor
NAMESPACE     STATUS
default       ok
riff-system   ok

RESOURCE                                     NAMESPACE     NAME       READ      WRITE
configmaps                                   riff-system   builders   allowed   n/a
configmaps                                   default       *          allowed   allowed
secrets                                      default       *          allowed   allowed
pods                                         default       *          allowed   n/a
pods/log                                     default       *          allowed   n/a
applications.build.projectriff.io            default       *          allowed   allowed
containers.build.projectriff.io              default       *          allowed   allowed
functions.build.projectriff.io               default       *          allowed   allowed
deployers.core.projectriff.io                default       *          missing   missing
processors.streaming.projectriff.io          default       *          missing   missing
streams.streaming.projectriff.io             default       *          missing   missing
inmemoryproviders.streaming.projectriff.io   default       *          missing   missing
kafkaproviders.streaming.projectriff.io      default       *          missing   missing
pulsarproviders.streaming.projectriff.io     default       *          missing   missing
adapters.knative.projectriff.io              default       *          allowed   allowed
deployers.knative.projectriff.io             default       *          allowed   allowed

apply build credentials

Use the riff CLI to apply credentials for a container registry. If you plan on using a namespace other than default add the --namespace flag. Replace the ??? with your docker username.

DOCKER_ID=???
riff credential apply my-creds --docker-hub $DOCKER_ID --set-default-image-prefix

You will be prompted to provide the password.

Create a function

This step will pull the source code for a function from a GitHub repo, build a container image based on the node function invoker, and push the resulting image to your Docker Hub repo.

riff function create square \
  --git-repo https://github.com/projectriff-samples/node-square  \
  --artifact square.js \
  --tail

After the function is created, you can see the built image by listing functions.

riff function list
NAME     LATEST IMAGE                                                                                           ARTIFACT    HANDLER   INVOKER   STATUS   AGE
square   index.docker.io/jldec/square@sha256:527053273ec98697dbdd88951f77edf82a9a46767125cd1e4348422fe5b8e09f   square.js   <empty>   <empty>   Ready    4m3s

Create a Knative deployer

The Knative Runtime is only available on clusters with Knative installed. Knative deployers run riff workloads using Knative resources which provide auto-scaling (including scale-to-zero) based on HTTP request traffic, and routing.

riff knative deployer create knative-square --function-ref square --ingress-policy External --tail

After the deployer is created, you can see the hostname by listing deployers.

riff knative deployer list
NAME             TYPE       REF      HOST                                 STATUS   AGE
knative-square   function   square   knative-square.default.example.com   Ready    19s

invoke the function

Knative configures HTTP routes on the ingress controller. Requests are routed by hostname.

Look up the nodePort for the ingress gateway; you should see a port value like 30195.

MINIKUBE_IP=$(minikube ip)
INGRESS_PORT=$(kubectl get svc envoy  --namespace contour-external --output 'jsonpath={.spec.ports[?(@.port==80)].nodePort}')
echo $MINIKUBE_IP:$INGRESS_PORT

Invoke the function by POSTing to the ingress gateway, passing the hostname and content-type as headers.

curl http://$MINIKUBE_IP:$INGRESS_PORT/ -w '\n' \
-H 'Host: knative-square.default.example.com' \
-H 'Content-Type: application/json' \
-d 7
49

Delete the function and deployer

riff knative deployer delete knative-square
riff function delete square

Uninstalling riff

You can delete your Minikube cluster and then recreate it (this will remove all state including riff).

minikube delete
minikube start --memory=4096 --cpus=4

Alternatively, you can use the following commands to uninstall riff:

remove any riff resources

kubectl delete riff --all-namespaces --all

remove riff Streaming Runtime

kapp delete -n apps -a riff-streaming-runtime
kapp delete -n apps -a keda

remove riff Core Runtime (if installed)

kapp delete -n apps -a riff-core-runtime

remove riff Knative Runtime (if installed)

kubectl delete knative --all-namespaces --all
kapp delete -n apps -a riff-knative-runtime
kapp delete -n apps -a knative

remove Contour

kapp delete -n apps -a contour

remove riff Build

kapp delete -n apps -a riff-build
kapp delete -n apps -a riff-builders
kapp delete -n apps -a kpack
kapp delete -n apps -a cert-manager
← GKEDocker for Mac →
  • Install Minikube
  • Install Docker
  • Install kubectl
  • Create a Minikube cluster
    • monitor your cluster
  • Install kapp
  • Install ytt
  • Install a snapshot build of the riff CLI
  • Install riff Using kapp
    • install riff Build
    • install Contour ingress controller
    • install riff Knative Runtime
    • verify riff installation
    • apply build credentials
  • Create a function
  • Create a Knative deployer
    • invoke the function
  • Delete the function and deployer
  • Uninstalling riff
    • remove any riff resources
    • remove riff Streaming Runtime
    • remove riff Core Runtime (if installed)
    • remove riff Knative Runtime (if installed)
    • remove Contour
    • remove riff Build
riff is for functions
Docs
Versions
Community
BlogGitHubSlackKnativeTwitter
More
Privacy PolicyTerms of UseCode of Conduct
Deployed by Netlify
Copyright © 2021 VMware, Inc