Installing TriggerMesh and Knative in Minikube

Posted on Sat 05 February 2022 in Tech • 3 min read

One under-appreciated benefit of virtualization and containerization is the ability to completely destroy an entire environment and build it again in a repeatable fashion. Back in the days of physical servers, reloading an operating system would take hours or days, and it was difficult to make sure the setup was exactly the same as last time. Now, I can run entire virtual clusters on my laptop within minutes. This makes development, demos, and just playing with cool technology much easier than it used to be.

Recently, I've been working on deploying TriggerMesh on my own testing Kubernetes cluster. I was using Amazon EKS for this initially. I found that if I got to a point where I needed to completely wipe the environment and start over, standing up a new EKS environment was taking about 25 minutes. If I said this to myself 20 years ago, I'd be amazed! That said, I thought I could do it faster, since my laptop has enough memory and CPU cores to handle most things I throw at it. Also, if I left an EKS cluster running, it was costing real money. I was OK with this, but wanted to avoid it where possible.

I found that Minikube solves those problems for me by running an entire cluster inside of a Docker container on my laptop. It deploys in about 2 minutes and costs me nothing (except excess laptop heat!). I've set up this environment so many times that I started to write a shell script to auto-deploy a bunch of things for me that I need each time. I first found this amazing installation script by Carlos Santana, so I took what he made and extended it to work with TriggerMesh. Let's walk through the script to show what it's doing, but first, some definitions:

  • Minikube deploys and manages an entire virtual Kubernetes cluster inside of a VM or container. There are installation options for all OS and architectures. I used brew install minikube to install to my ARM64-based Macbook Pro and it was fairly painless.

  • Knative enables you to run serverless APIs on top of Kubernetes. This will be installed as part of the script

  • TriggerMesh extends Knative to make it an event-driven platform with more sources, targets, an optional UI, and an HCL-based language for making YAML. This will also be installed as part of the script.

The Full Script

minikube start --cpus 4 --memory 8096 --driver=docker

# Knative Serving installation
kubectl apply -f https://github.com/knative/serving/releases/download/knative-v1.2.0/serving-crds.yaml
kubectl wait --for=condition=Established --all crd
kubectl apply -f https://github.com/knative/serving/releases/download/knative-v1.2.0/serving-core.yaml
kubectl wait pod --timeout=-1s --for=condition=Ready -l '!job-name' -n knative-serving > /dev/null

# Kourier for networking
kubectl apply -f https://github.com/knative/net-kourier/releases/download/knative-v1.2.0/kourier.yaml
kubectl wait pod --timeout=-1s --for=condition=Ready -l '!job-name' -n kourier-system
kubectl wait pod --timeout=-1s --for=condition=Ready -l '!job-name' -n knative-serving

# Networking setup assuming 127.0.0.1 and using nip,io
sleep 5
EXTERNAL_IP=127.0.0.1
KNATIVE_DOMAIN="$EXTERNAL_IP.nip.io"
kubectl patch configmap -n knative-serving config-domain -p "{\"data\": {\"$KNATIVE_DOMAIN\": \"\"}}"

kubectl patch configmap/config-network \
  --namespace knative-serving \
  --type merge \
  --patch '{"data":{"ingress.class":"kourier.ingress.networking.knative.dev"}}'

# Knative Eventing installation
kubectl apply -f https://github.com/knative/eventing/releases/download/knative-v1.2.0/eventing-crds.yaml
kubectl wait --for=condition=Established --all crd
kubectl apply -f https://github.com/knative/eventing/releases/download/knative-v1.2.0/eventing-core.yaml
kubectl wait pod --timeout=-1s --for=condition=Ready -l '!job-name' -n knative-eventing
kubectl apply -f https://github.com/knative/eventing/releases/download/knative-v1.2.0/in-memory-channel.yaml
kubectl wait pod --timeout=-1s --for=condition=Ready -l '!job-name' -n knative-eventing
kubectl apply -f https://github.com/knative/eventing/releases/download/knative-v1.2.0/mt-channel-broker.yaml
kubectl wait pod --timeout=-1s --for=condition=Ready -l '!job-name' -n knative-eventing


# TriggerMesh installation
kubectl apply -f https://github.com/triggermesh/triggermesh/releases/latest/download/triggermesh-crds.yaml
kubectl wait --for=condition=Established --all crd
kubectl apply -f https://github.com/triggermesh/triggermesh/releases/latest/download/triggermesh.yaml
kubectl wait pod --timeout=-1s --for=condition=Ready -l '!job-name' -n triggermesh

Notes, Comments, and Assumptions

  • In order to connect to anything you deploy in this cluster, you'll need to have a terminal window open running minikube tunnel, then enter your sudo password when asked. Usually when something appears broken, it's because I forgot to do this.

  • To stop the cluster, run minikube delete.

  • At the time of writing this, Knative was version 1.2.0. The URLs may need to be updated if you're trying to use a later version.

  • I'm running this on my laptop using docker as the driver because Hyperkit and VirtualBox don't currently work on ARM64. I'm assuming that you could change the first minikube start... line to use a different driver, but I wasn't able to test those. You can also set a lot of the settings as persistent configuration.

  • This setup installs TriggerMesh, so you can go through any of the guides to start creating bridges and integrations.