Install by using the Knative Operator

Knative provides a Kubernetes Operator to install, configure and manage Knative. You can install the Serving component, Eventing component, or both on your cluster.

The following table describes the supported versions of Serving and Eventing for the Knative Operator:

OperatorServingEventing
v1.16v1.16.0
v1.15.0, v1.15.1 and v1.15.2
v1.14.0, v1.14.1 and v1.14.2
v1.13.0, v1.13.1 and v1.13.2
v1.16.0
v1.15.0, v1.15.1, v1.15.2 and v1.15.3
v1.14.0, v1.14.1, v1.14.2, v1.14.3, v1.14.4, v1.14.5, v1.14.6 and v1.14.7
v1.13.0, v1.13.1, v1.13.2, v1.13.3, v1.13.4, v1.13.5, v1.13.6, v1.13.7 and v1.13.8

Prerequisites

Before installing Knative, you must meet the following prerequisites:

  • For prototyping purposes, Knative works on most local deployments of Kubernetes. For example, you can use a local, one-node cluster that has 3 CPUs and 4 GB of memory.

    Tip

    You can install a local distribution of Knative for development purposes using the Knative Quickstart plugin

  • For production purposes, it is recommended that:

    • If you have only one node in your cluster, you need at least 6 CPUs, 6 GB of memory, and 30 GB of disk storage.
    • If you have multiple nodes in your cluster, for each node you need at least 2 CPUs, 4 GB of memory, and 20 GB of disk storage.
    • You have a cluster that uses Kubernetes v1.28 or newer.
    • You have installed the kubectl CLI.
    • Your Kubernetes cluster must have access to the internet, because Kubernetes needs to be able to fetch images. To pull from a private registry, see Deploying images from a private container registry.

Caution

The system requirements provided are recommendations only. The requirements for your installation might vary, depending on whether you use optional components, such as a networking layer.

Verifying image signatures

Knative releases from 1.9 onwards are signed with cosign.

  1. Install cosign and jq.

  2. Extract the images from a manifeset and verify the signatures.

  1. curl -sSL https://github.com/knative/serving/releases/download/knative-v1.16.0/serving-core.yaml \
  2. | grep 'gcr.io/' | awk '{print $2}' | sort | uniq \
  3. | xargs -n 1 \
  4. cosign verify -o text \
  5. --certificate-identity=signer@knative-releases.iam.gserviceaccount.com \
  6. --certificate-oidc-issuer=https://accounts.google.com

Note

Knative images are signed in KEYLESS mode. To learn more about keyless signing, please refer to Keyless Signatures Our signing identity(Subject) for our releases is signer@knative-releases.iam.gserviceaccount.com and the Issuer is https://accounts.google.com

Install the Knative Operator

Before you install the Knative Serving and Eventing components, first install the Knative Operator.

Warning

Knative Operator 1.5 is the last version that supports CRDs with both v1alpha1 and v1beta1. If you are upgrading an existing Operator install from v1.2 or earlier to v1.3 or later, run the following command to upgrade the existing custom resources to v1beta1 before installing the current version:

  1. kubectl create -f https://github.com/knative/operator/releases/download/knative-v1.5.1/operator-post-install.yaml

To install the latest stable Operator release, run the command:

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

You can find information about the released versions of the Knative Operator on the releases page.

Verify your Knative Operator installation

  1. Because the Operator is installed to the default namespace, ensure you set the current namespace to default by running the command:

    1. kubectl config set-context --current --namespace=default
  2. Check the Operator deployment status by running the command:

    1. kubectl get deployment knative-operator

    If the Operator is installed correctly, the deployment shows a Ready status:

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

Track the log

To track the log of the Operator, run the command:

  1. kubectl logs -f deploy/knative-operator

Install Knative Serving

To install Knative Serving you must create a custom resource (CR), add a networking layer to the CR, and configure DNS.

Create the Knative Serving custom resource

To create the custom resource for the latest available Knative Serving in the Operator:

  1. Copy the following YAML into a file:

    1. apiVersion: v1
    2. kind: Namespace
    3. metadata:
    4. name: knative-serving
    5. ---
    6. apiVersion: operator.knative.dev/v1beta1
    7. kind: KnativeServing
    8. metadata:
    9. name: knative-serving
    10. namespace: knative-serving

    Note

    When you don’t specify a version by using spec.version field, the Operator defaults to the latest available version.

  2. Apply the YAML file by running the command:

    1. kubectl apply -f <filename>.yaml

    Where <filename> is the name of the file you created in the previous step.

Install the networking layer

Knative Operator can configure the Knative Serving component with different network layer options. Istio is the default network layer if the ingress is not specified in the Knative Serving CR. If you choose to use the default Istio network layer, you must install Istio on your cluster. Because of this, you might find it easier to configure Kourier as your networking layer.

Click on each of the following tabs to see how you can configure Knative Serving with different ingresses:

Kourier (Choose this if you are not sure)Istio (default)Contour

The following steps install Kourier and enable its Knative integration:

  1. To configure Knative Serving to use Kourier, add spec.ingress.kourier and spec.config.network to your Serving CR YAML file as follows:

    1. apiVersion: operator.knative.dev/v1beta1
    2. kind: KnativeServing
    3. metadata:
    4. name: knative-serving
    5. namespace: knative-serving
    6. spec:
    7. # ...
    8. ingress:
    9. kourier:
    10. enabled: true
    11. config:
    12. network:
    13. ingress-class: "kourier.ingress.networking.knative.dev"
  2. Apply the YAML file for your Serving CR by running the command:

    1. kubectl apply -f <filename>.yaml

    Where <filename> is the name of your Serving CR file.

  3. Fetch the External IP or CNAME by running the command:

    1. kubectl --namespace knative-serving get service kourier

    Save this for configuring DNS later.

The following steps install Istio to enable its Knative integration:

  1. Install Istio.

  2. If you installed Istio under a namespace other than the default istio-system:

    1. Add spec.config.istio to your Serving CR YAML file as follows:

      1. apiVersion: operator.knative.dev/v1beta1
      2. kind: KnativeServing
      3. metadata:
      4. name: knative-serving
      5. namespace: knative-serving
      6. spec:
      7. # ...
      8. config:
      9. istio:
      10. local-gateways: |
      11. - name: knative-local-gateway
      12. namespace: <local-gateway-namespace>
      13. service: knative-local-gateway.<istio-namespace>.svc.cluster.local

      Where:

      • <local-gateway-namespace> is the local gateway namespace, which is the same as Knative Serving namespace knative-serving.
      • <istio-namespace> is the namespace where Istio is installed.
    2. Apply the YAML file for your Serving CR by running the command:

      1. kubectl apply -f <filename>.yaml

      Where <filename> is the name of your Serving CR file.

  3. Fetch the External IP or CNAME by running the command:

    1. kubectl get svc istio-ingressgateway -n <istio-namespace>

    Save this for configuring DNS later.

The following steps install Contour and enable its Knative integration:

  1. Install a properly configured Contour:

    1. kubectl apply --filename https://github.com/knative/net-contour/releases/download/knative-v1.16.0/contour.yaml
  2. To configure Knative Serving to use Contour, add spec.ingress.contour spec.config.network to your Serving CR YAML file as follows:

    1. apiVersion: operator.knative.dev/v1beta1
    2. kind: KnativeServing
    3. metadata:
    4. name: knative-serving
    5. namespace: knative-serving
    6. spec:
    7. # ...
    8. ingress:
    9. contour:
    10. enabled: true
    11. config:
    12. network:
    13. ingress-class: "contour.ingress.networking.knative.dev"
  3. Apply the YAML file for your Serving CR by running the command:

    1. kubectl apply -f <filename>.yaml

    Where <filename> is the name of your Serving CR file.

  4. Fetch the External IP or CNAME by running the command:

    1. kubectl --namespace contour-external get service envoy

    Save this for configuring DNS later.

Verify the Knative Serving deployment

  1. Monitor the Knative deployments:

    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. domain-mapping 1/1 1 1 12s
    7. domainmapping-webhook 1/1 1 1 12s
    8. webhook 1/1 1 1 17s
  2. 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

Configure DNS

You can configure DNS to prevent the need to run curl commands with a host header.

The following tabs expand to show instructions for configuring DNS. Follow the procedure for the DNS of your choice:

Magic DNS (sslip.io)Real DNSNo DNS

Knative provides a Kubernetes Job called default-domain that configures Knative Serving to use sslip.io as the default DNS suffix.

  1. kubectl apply -f https://github.com/knative/serving/releases/download/knative-v1.16.0/serving-default-domain.yaml

Warning

This will only work if the cluster LoadBalancer Service exposes an IPv4 address or hostname, so it will not work with IPv6 clusters or local setups like minikube unless minikube tunnel is running.

In these cases, see the “Real DNS” or “No DNS” tabs.

To configure DNS for Knative, take the External IP or CNAME from setting up networking, and configure it with your DNS provider as follows:

  • If the networking layer produced an External IP address, then configure a wildcard A record for the domain:

    1. # Here knative.example.com is the domain suffix for your cluster
    2. *.knative.example.com == A 35.233.41.212
  • If the networking layer produced a CNAME, then configure a CNAME record for the domain:

    1. # Here knative.example.com is the domain suffix for your cluster
    2. *.knative.example.com == CNAME a317a278525d111e89f272a164fd35fb-1510370581.eu-central-1.elb.amazonaws.com
  • Once your DNS provider has been configured, add spec.config.domain into your existing Serving CR, and apply it:

    1. # Replace knative.example.com with your domain suffix
    2. apiVersion: operator.knative.dev/v1alpha1
    3. kind: KnativeServing
    4. metadata:
    5. name: knative-serving
    6. namespace: knative-serving
    7. spec:
    8. ...
    9. config:
    10. domain:
    11. "knative.example.com": ""
    12. ...

If you are using curl to access the sample applications, or your own Knative app, and are unable to use the “Magic DNS (sslip.io)” or “Real DNS” methods, there is a temporary approach. This is useful for those who wish to evaluate Knative without altering their DNS configuration, as per the “Real DNS” method, or cannot use the “Magic DNS” method due to using, for example, minikube locally or IPv6 clusters.

To access your application using curl using this method:

  1. Configure Knative to use a domain reachable from outside the cluster:

    1. kubectl patch configmap/config-domain \
    2. --namespace knative-serving \
    3. --type merge \
    4. --patch '{"data":{"example.com":""}}'
  2. After starting your application, get the URL of your application:

    1. kubectl get ksvc

    The output should be similar to:

    1. NAME URL LATESTCREATED LATESTREADY READY REASON
    2. helloworld-go http://helloworld-go.default.example.com helloworld-go-vqjlf helloworld-go-vqjlf True
  3. Instruct curl to connect to the External IP or CNAME defined by the networking layer mentioned in section 3, and use the -H "Host:" command-line option to specify the Knative application’s host name. For example, if the networking layer defines your External IP and port to be http://192.168.39.228:32198 and you wish to access the helloworld-go application mentioned earlier, use:

    1. curl -H "Host: helloworld-go.default.example.com" http://192.168.39.228:32198

    In the case of the provided helloworld-go sample application, using the default configuration, the output is:

    1. Hello Go Sample v1!

    Refer to the “Real DNS” method for a permanent solution.

Install Knative Eventing

To install Knative Eventing you must apply the custom resource (CR). Optionally, you can install the Knative Eventing component with different event sources.

Create the Knative Eventing custom resource

To create the custom resource for the latest available Knative Eventing in the Operator:

  1. Copy the following YAML into a file:

    1. apiVersion: v1
    2. kind: Namespace
    3. metadata:
    4. name: knative-eventing
    5. ---
    6. apiVersion: operator.knative.dev/v1beta1
    7. kind: KnativeEventing
    8. metadata:
    9. name: knative-eventing
    10. namespace: knative-eventing

    Note

    When you do not specify a version by using spec.version field, the Operator defaults to the latest available version.

  2. Apply the YAML file by running the command:

    1. kubectl apply -f <filename>.yaml

Where <filename> is the name of the file you created in the previous step.

Installing a specific version of Eventing

Cluster administrators can install a specific version of Knative Eventing by using the spec.version field. For example, if you want to install Knative Eventing v1.7, you can apply the following KnativeEventing CR:

  1. apiVersion: operator.knative.dev/v1beta1
  2. kind: KnativeEventing
  3. metadata:
  4. name: knative-eventing
  5. namespace: knative-eventing
  6. spec:
  7. version: "1.7"

You can also run the following command to make the equivalent change:

  1. kn operator install --component eventing -v 1.7 -n knative-eventing

If spec.version is not specified, the Knative Operator installs the latest available version of Knative Eventing. If users specify an invalid or unavailable version, the Knative Operator will do nothing. The Knative Operator always includes the latest 3 minor release versions.

If Knative Eventing is already managed by the Operator, updating the spec.version field in the KnativeEventing CR enables upgrading or downgrading the Knative Eventing version, without requiring modifications to the Operator.

Note that the Knative Operator only permits upgrades or downgrades by one minor release version at a time. For example, if the current Knative Eventing deployment is version 1.4, you must upgrade to 1.5 before upgrading to 1.6.

Installing customized Knative Eventing

The Operator provides you with the flexibility to install Knative Eventing customized to your own requirements. As long as the manifests of customized Knative Eventing are accessible to the Operator, you can install them.

There are two modes available for you to install customized manifests: overwrite mode and append mode. With overwrite mode, under .spec.manifests, you must define all manifests needed for Knative Eventing to install because the Operator will no longer install any default manifests. With append mode, under .spec.additionalManifests, you only need to define your customized manifests. The customized manifests are installed after default manifests are applied.

Overwrite mode

Use overwrite mode when you want to customize all Knative Eventing manifests to be installed.

For example, if you want to install a customized Knative Eventing only, you can create and apply the following Eventing CR:

  1. apiVersion: v1
  2. kind: Namespace
  3. metadata:
  4. name: knative-eventing
  5. ---
  6. apiVersion: operator.knative.dev/v1beta1
  7. kind: KnativeEventing
  8. metadata:
  9. name: knative-eventing
  10. namespace: knative-eventing
  11. spec:
  12. version: $spec_version
  13. manifests:
  14. - URL: https://my-eventing/eventing.yaml

This example installs the customized Knative Eventing at version $spec_version which is available at https://my-eventing/eventing.yaml.

Attention

You can make the customized Knative Eventing available in one or multiple links, as the spec.manifests supports a list of links. The ordering of the URLs is critical. Put the manifest you want to apply first on the top.

We strongly recommend you to specify the version and the valid links to the customized Knative Eventing, by leveraging both spec.version and spec.manifests. Do not skip either field.

Append mode

You can use append mode to add your customized manifests into the default manifests.

For example, if you only want to customize a few resources but you still want to install the default Knative Eventing, you can create and apply the following Eventing CR:

  1. apiVersion: v1
  2. kind: Namespace
  3. metadata:
  4. name: knative-eventing
  5. ---
  6. apiVersion: operator.knative.dev/v1beta1
  7. kind: KnativeEventing
  8. metadata:
  9. name: knative-eventing
  10. namespace: knative-eventing
  11. spec:
  12. version: $spec_version
  13. additionalManifests:
  14. - URL: https://my-eventing/eventing-custom.yaml

This example installs the default Knative Eventing, and installs your customized resources available at https://my-eventing/eventing-custom.yaml.

Knative Operator installs the default manifests of Knative Eventing at the version $spec_version, and then installs your customized manifests based on them.

Installing Knative Eventing with event sources

Knative Operator can configure the Knative Eventing component with different event sources. Click on each of the following tabs to see how you can configure Knative Eventing with different event sources:

CephGitHubGitLabApache KafkaRabbitMQRedis

To configure Knative Eventing to install Ceph as the event source:

  1. Add spec.source.ceph to your Eventing CR YAML file as follows:

    1. apiVersion: operator.knative.dev/v1beta1
    2. kind: KnativeEventing
    3. metadata:
    4. name: knative-eventing
    5. namespace: knative-eventing
    6. spec:
    7. # ...
    8. source:
    9. ceph:
    10. enabled: true
  2. Apply the YAML file by running the command:

    1. kubectl apply -f <filename>.yaml

    Where <filename> is the name of the file you created in the previous step.

To configure Knative Eventing to install GitHub as the event source:

  1. Add spec.source.github to your Eventing CR YAML file as follows:

    1. apiVersion: operator.knative.dev/v1beta1
    2. kind: KnativeEventing
    3. metadata:
    4. name: knative-eventing
    5. namespace: knative-eventing
    6. spec:
    7. # ...
    8. source:
    9. github:
    10. enabled: true
  2. Apply the YAML file by running the command:

    1. kubectl apply -f <filename>.yaml

    Where <filename> is the name of the file you created in the previous step.

To configure Knative Eventing to install GitLab as the event source:

  1. Add spec.source.gitlab to your Eventing CR YAML file as follows:

    1. apiVersion: operator.knative.dev/v1beta1
    2. kind: KnativeEventing
    3. metadata:
    4. name: knative-eventing
    5. namespace: knative-eventing
    6. spec:
    7. # ...
    8. source:
    9. gitlab:
    10. enabled: true
  2. Apply the YAML file by running the command:

    1. kubectl apply -f <filename>.yaml

    Where <filename> is the name of the file you created in the previous step.

To configure Knative Eventing to install Kafka as the event source:

  1. Add spec.source.kafka to your Eventing CR YAML file as follows:

    1. apiVersion: operator.knative.dev/v1beta1
    2. kind: KnativeEventing
    3. metadata:
    4. name: knative-eventing
    5. namespace: knative-eventing
    6. spec:
    7. # ...
    8. source:
    9. kafka:
    10. enabled: true
  2. Apply the YAML file by running the command:

    1. kubectl apply -f <filename>.yaml

    Where <filename> is the name of the file you created in the previous step.

To configure Knative Eventing to install RabbitMQ as the event source,

  1. Add spec.source.rabbitmq to your Eventing CR YAML file as follows:

    1. apiVersion: operator.knative.dev/v1beta1
    2. kind: KnativeEventing
    3. metadata:
    4. name: knative-eventing
    5. namespace: knative-eventing
    6. spec:
    7. # ...
    8. source:
    9. rabbitmq:
    10. enabled: true
  2. Apply the YAML file by running the command:

    1. kubectl apply -f <filename>.yaml

    Where <filename> is the name of the file you created in the previous step.

To configure Knative Eventing to install Redis as the event source:

  1. Add spec.source.redis to your Eventing CR YAML file as follows:

    1. apiVersion: operator.knative.dev/v1beta1
    2. kind: KnativeEventing
    3. metadata:
    4. name: knative-eventing
    5. namespace: knative-eventing
    6. spec:
    7. # ...
    8. source:
    9. redis:
    10. enabled: true
  2. Apply the YAML file by running the command:

    1. kubectl apply -f <filename>.yaml

    Where <filename> is the name of the file you created in the previous step.

Verify the Knative Eventing deployment

  1. Monitor the Knative deployments:

    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. eventing-controller 1/1 1 1 43s
    3. eventing-webhook 1/1 1 1 42s
    4. imc-controller 1/1 1 1 39s
    5. imc-dispatcher 1/1 1 1 38s
    6. mt-broker-controller 1/1 1 1 36s
    7. mt-broker-filter 1/1 1 1 37s
    8. mt-broker-ingress 1/1 1 1 37s
    9. pingsource-mt-adapter 0/0 0 0 43s
    10. sugar-controller 1/1 1 1 36s
  2. 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

Uninstalling Knative

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 Serving component

To remove the Knative Serving CR run the command:

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

Removing Knative Eventing component

To remove the Knative Eventing CR run the command:

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

Removing the Knative Operator:

If you have installed Knative using the release page, remove the operator by running the command:

  1. kubectl delete -f https://github.com/knative/operator/releases/download/knative-v1.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