riff is for functions

riff is for functions

  • Docs
  • Blog
  • GitHub
  • Slack

›Getting Started

Version (v0.3.x)

  • v0.6.x (snapshot)
  • v0.5.x
  • v0.4.x

Getting Started

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

CLI Reference

  • riff
  • riff version
  • riff completion
  • System

    • riff system
    • riff system install
    • riff system uninstall

    Namespace

    • riff namespace
    • riff namespace cleanup
    • riff namespace init

    Functions

    • riff function
    • riff function build
    • riff function create
    • riff function update

    Services

    • riff service
    • riff service create
    • riff service delete
    • riff service invoke
    • riff service list
    • riff service status
    • riff service update

    Subscriptions

    • riff subscription
    • riff subscription create
    • riff subscription delete
    • riff subscription list

    Channels

    • riff channel
    • riff channel create
    • riff channel delete
    • riff channel list
Edit

Getting started on Minikube

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

TL;DR

  1. install kubectl, Minikube, and Docker
  2. install the latest riff CLI
  3. create a Minikube cluster for Knative
  4. install Knative using the riff CLI
  5. create a function
  6. invoke the function

install kubectl

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

install Minikube

Minikube is a Kubernetes environment which runs in a single virtual machine. See the latest release for installation, and the readme for more detailed information.

For macOS we recommend using Hyperkit as the vm driver. To install Hyperkit, first install Docker Desktop (Mac), then run:

curl -LO https://storage.googleapis.com/minikube/releases/latest/docker-machine-driver-hyperkit \
&& sudo install -o root -m 4755 docker-machine-driver-hyperkit /usr/local/bin/

For Linux we suggest using the kvm2 driver.

For additional details see the minikube driver installation docs.

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

create a Minikube cluster

minikube start \
  --memory=4096 --cpus=4 \
  --vm-driver=hyperkit

To use the kvm2 driver for Linux specify --vm-driver=kvm2. Omitting the --vm-driver option will use the default driver.

Confirm that your kubectl context is pointing to the new cluster

kubectl config current-context

install the riff CLI

The riff CLI is available to download from our GitHub releases page. Once installed, check that the riff CLI version is 0.3.0 or later.

riff version
Version
  riff cli: 0.3.1 (1ff6c6d7a708e52eb6843e89f9a618fcbfebbb9f)

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 Knative using the riff CLI

Install Knative, watching the pods until everything is running (this could take a couple of minutes). The --node-port option replaces LoadBalancer type services with NodePort.

riff system install --node-port

You should see pods running in namespaces istio-system, knative-build, knative-serving, and knative-eventing as well as kube-system when the system is fully operational.

NAMESPACE          NAME                                            READY   STATUS      RESTARTS   AGE
istio-system       cluster-local-gateway-547467ccf6-xbh9m          1/1     Running     0          3m34s
istio-system       istio-citadel-7d64db8bcf-ljd5r                  1/1     Running     0          3m35s
istio-system       istio-cleanup-secrets-pw842                     0/1     Completed   0          3m36s
istio-system       istio-egressgateway-6ddf4c8bd6-k7bjr            1/1     Running     0          3m35s
istio-system       istio-galley-7dd996474-467xc                    1/1     Running     0          3m35s
istio-system       istio-ingressgateway-84b89d647f-76z5g           1/1     Running     0          3m35s
istio-system       istio-pilot-54b76645df-xdszt                    2/2     Running     0          3m21s
istio-system       istio-policy-5c4d9ff96b-htd5h                   2/2     Running     0          3m35s
istio-system       istio-sidecar-injector-6977b5cf5b-fh7mr         1/1     Running     0          3m35s
istio-system       istio-statsd-prom-bridge-b44b96d7b-htrgk        1/1     Running     0          3m35s
istio-system       istio-telemetry-7676df547f-b4vdw                2/2     Running     0          3m35s
knative-build      build-controller-7b8987d675-8vph5               1/1     Running     0          59s
knative-build      build-webhook-74795c8696-xwwld                  1/1     Running     0          59s
knative-eventing   eventing-controller-864657d8d4-hj7xz            1/1     Running     0          57s
knative-eventing   in-memory-channel-controller-f794cc9d8-nb59s    1/1     Running     0          56s
knative-eventing   in-memory-channel-dispatcher-8595c7f8d7-qzn9c   2/2     Running     1          56s
knative-eventing   webhook-5d76776d55-jb56d                        1/1     Running     0          57s
knative-serving    activator-7c8b59d78-2jrpk                       2/2     Running     1          58s
knative-serving    autoscaler-666c9bfcc6-vwcrq                     2/2     Running     1          58s
knative-serving    controller-799cd5c6dc-sbpzr                     1/1     Running     0          58s
knative-serving    webhook-5b66fdf6b9-kqvjh                        1/1     Running     0          58s
kube-system        coredns-86c58d9df4-dtf4v                        1/1     Running     0          9m17s
kube-system        coredns-86c58d9df4-hpzlx                        1/1     Running     0          9m17s
kube-system        etcd-minikube                                   1/1     Running     0          8m30s
kube-system        kube-addon-manager-minikube                     1/1     Running     0          8m15s
kube-system        kube-apiserver-minikube                         1/1     Running     0          8m20s
kube-system        kube-controller-manager-minikube                1/1     Running     0          8m29s
kube-system        kube-proxy-fcbqc                                1/1     Running     0          9m17s
kube-system        kube-scheduler-minikube                         1/1     Running     0          8m9s
kube-system        storage-provisioner                             1/1     Running     0          9m16s

initialize the namespace and provide credentials for pushing images to DockerHub

Use the riff CLI to initialize your namespace (if you plan on using a namespace other than default then substitute the name you want to use). This will create a serviceaccount and a secret with the provided credentials and install a buildtemplate. Replace the ??? with your docker username.

export DOCKER_ID=???
riff namespace init default --docker-hub $DOCKER_ID

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 dockerhub repo.

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

If you're still watching pods, you should see something like the following

NAMESPACE       NAME                         READY   STATUS      RESTARTS   AGE
default         square-rqmsf-pod-2cd1ef      0/1     Init:3/7    0          20s

The 7 "Init" containers may take a while to complete the first time a function is built, but eventually that pod should show a status of completed, and a new square deployment pod should be running 3/3 containers.

NAMESPACE      NAME                                         READY   STATUS      RESTARTS   AGE
default        square-5ksdq-deployment-6d875d87bf-64fz4     3/3     Running     0          47s
default        square-rqmsf-pod-2cd1ef                      0/1     Completed   0          2m30s

invoke the function

riff service invoke square --json -- -w '\n' -d 8

result

curl http://192.168.64.46:31380/ -H 'Host: square.default.example.com' -H 'Content-Type: application/json' -w '\n' -d 8
64

delete the function

riff service delete square
← GKEDocker for Mac →
  • TL;DR
    • install kubectl
    • install Minikube
    • install Docker
  • create a Minikube cluster
  • install the riff CLI
  • install Knative using the riff CLI
    • initialize the namespace and provide credentials for pushing images to DockerHub
  • create a function
  • invoke the function
  • delete the function
riff is for functions
Docs
Versions
Community
BlogGitHubSlackKnativeTwitter
More
Privacy PolicyTerms of UseCode of Conduct
Deployed by Netlify
Copyright © 2021 VMware, Inc