I’ve been playing around with Knative Eventing and wanted to write my own post on how to get it up and running on a Kubernetes cluster. The docs are pretty straight forward but I always like to keep a record for myself, just so that it’s all in one place.
Hopefully this guide will help someone who is new to the world of Knative eventing get up and running on their local machine.
So let’s get started with our install.
Get Docker Desktop
First you will need to install Docker Desktop. I’m using a Mac so I followed the instructions from the Docker website, they also have for Windows.
Once Docker desktop is installed, go to Preferences > Kubernetes > Enable Kubernetes (this post assumes you have kubectl). Then under ‘Advanced’, you will need to change the settings to increase the resources available:
Install an Ingress controller (Istio)
Knative needs Istio in order to run for it’s ingress controller. You can also use Gloo, but in this example we will use the former.
I followed the instructions from the official Istio site:
You can also install a lighter version of Istio for Knative, for which you can find the instructions here. The installation uses Helm, despite Istio starting to move away from Helm. Also, I needed to remove all the comment lines from the helm template command that makes the istio-lean.yaml file, otherwise it wouldn’t run for me.
Install Knative Serving
Then to install Knative, I first installed Knative serving (as recommended for Docker Desktop users) as per the instructions from their site:
Install Knative Eventing CRDs
After this was installed, I then installed the CRDs for Knative eventing as per the instructions at the link below:
Once you have installed everything, run the following command and you should have something like this:
kubectl get pods --all-namespaces
Create a namespace with Knative Eventing
Now create a test namespace:
kubectl create namespace my-event-namespace
Then we need to add the resources that will be needed from Knative to manage events into the namespace we just created. This is done using the following command:
kubectl label namespace my-event-namespace knative-eventing-injection=enabled
Rather than deleting everything, you can just scale your pods down to zero when not in use. This way you can spin them back up when you want to use them again. To do this use the following command:
kubectl get deploy -n <namespace> -o name | xargs -I % kubectl scale % --replicas=0 -n <namespace>
So, for example so scale down any Knative-eventing pods I would use:
kubectl get deploy -n knative-eventing -o name | xargs -I % kubectl scale % --replicas=0 -n knative-eventing
Next steps would be to try out some of the examples listed on the Knative website. In the next few weeks I will be posting some more on using Knative eventing so stay tuned 🙂