Installing Knative components using Operator

Knative provides an operator as a tool to install, configure and manage Knative. The Knative operator leverages custom objects in the cluster to define and manage the installed Knative software. This guide explains how to install and uninstall Knative using Knative operator.

Before you begin

Knative installation using the Operator requires the following:

  • A Kubernetes cluster v1.16 or newer, as well as a compatible kubectl. This guide assumes that you’ve already created a Kubernetes cluster. If you have only one node for your cluster, set CPUs to at least 6, Memory to at least 6.0 GB, Disk storage to at least 30 GB. If you have multiple nodes for your cluster, set CPUs to at least 2, Memory to at least 4.0 GB, Disk storage to at least 20 GB for each node.
  • The Kubernetes cluster must be able to access the internet, since the Knative operator downloads images online.
  • Download and install Istio.

Limitations of Knative Operator:

Knative Operator is still in Alpha phase. It has not been tested in a production environment, and should be used for development or test purposes only.

Install Knative with the Knative Operator

You can find the release information of Knative Operator on the Releases page.

Installing the Knative Operator

From releases:

Install the latest Knative operator with the following command:

  1. kubectl apply -f https://github.com/knative/operator/releases/download/v0.16.0/operator.yaml

From source code:

You can also install Knative Operator from source using ko.

  1. Install the ko build tool.
  2. Download the source code using the following command:
  1. git clone https://github.com/knative/operator.git
  1. Install the operator in the root directory of the source using the following command:
  1. ko apply -f config/

Verify the operator installation

Verify the installation of Knative Operator using the command:

  1. kubectl get deployment knative-operator

If the operator is installed correctly, the deployment should show a Ready status. Here is a sample output:

  1. NAME READY UP-TO-DATE AVAILABLE AGE
  2. knative-operator 1/1 1 1 19h

Track the log

Use the following command to track the log of the operator:

  1. kubectl logs -f deploy/knative-operator

Installing the Knative Serving component

  1. Create and apply the Knative Serving CR:
  1. cat <<-EOF | kubectl apply -f -
  2. apiVersion: v1
  3. kind: Namespace
  4. metadata:
  5. name: knative-serving
  6. ---
  7. apiVersion: operator.knative.dev/v1alpha1
  8. kind: KnativeServing
  9. metadata:
  10. name: knative-serving
  11. namespace: knative-serving
  12. EOF
  1. Verify the Knative Serving deployment:
  1. kubectl get deployment -n knative-serving

If Knative Serving has been successfully deployed, all deployments of the Knative Serving will show READY status. Here is a sample output:

  1. NAME READY UP-TO-DATE AVAILABLE AGE
  2. activator 1/1 1 1 18s
  3. autoscaler 1/1 1 1 18s
  4. autoscaler-hpa 1/1 1 1 14s
  5. controller 1/1 1 1 18s
  6. istio-webhook 1/1 1 1 12s
  7. networking-istio 1/1 1 1 12s
  8. webhook 1/1 1 1 17s
  1. Check the status of Knative Serving Custom Resource:
  1. kubectl get KnativeServing knative-serving -n knative-serving

If Knative Serving is successfully installed, you should see:

  1. NAME VERSION READY REASON
  2. knative-serving <version number> True

Installing the Knative Eventing component

  1. Create and apply the Knative eventing CR:
  1. cat <<-EOF | kubectl apply -f -
  2. apiVersion: v1
  3. kind: Namespace
  4. metadata:
  5. name: knative-eventing
  6. ---
  7. apiVersion: operator.knative.dev/v1alpha1
  8. kind: KnativeEventing
  9. metadata:
  10. name: knative-eventing
  11. namespace: knative-eventing
  12. EOF
  1. Verify the Knative Eventing deployment:
  1. kubectl get deployment -n knative-eventing

If Knative Eventing has been successfully deployed, all deployments of the Knative Eventing will show READY status. Here is a sample output:

  1. NAME READY UP-TO-DATE AVAILABLE AGE
  2. broker-controller 1/1 1 1 63s
  3. broker-filter 1/1 1 1 62s
  4. broker-ingress 1/1 1 1 62s
  5. eventing-controller 1/1 1 1 67s
  6. eventing-webhook 1/1 1 1 67s
  7. imc-controller 1/1 1 1 59s
  8. imc-dispatcher 1/1 1 1 59s
  9. mt-broker-controller 1/1 1 1 62s
  1. Check the status of Knative Eventing Custom Resource:
  1. kubectl get KnativeEventing knative-eventing -n knative-eventing

If Knative Eventing is successfully installed, you should see:

  1. NAME VERSION READY REASON
  2. knative-eventing <version number> True

Uninstall Knative

Removing the Knative Serving component

Remove the Knative Serving CR:

  1. kubectl delete KnativeServing knative-serving -n knative-serving

Removing Knative Eventing component

Remove the Knative Eventing CR:

  1. kubectl delete KnativeEventing knative-eventing -n knative-eventing

Knative operator prevents unsafe removal of Knative resources. Even if the Knative Serving and Knative Eventing CRs are successfully removed, all the CRDs in Knative are still kept in the cluster. All your resources relying on Knative CRDs can still work.

Removing the Knative Operator:

If you have installed Knative using the Release page, remove the operator using the following command:

  1. kubectl delete -f https://github.com/knative/operator/releases/download/v0.16.0/operator.yaml

If you have installed Knative from source, uninstall it using the following command while in the root directory for the source:

  1. ko delete -f config/

What’s next