Installing Knative
The Knative project provides several options for installing the components such as YAML files, and operators. This section covers the installation of the Knative components in Kubernetes by using YAML files, and the installation of the Knative CLI.
Depending on your application’s workload, your system requirements might vary. Knative requires at least 2 CPUs and 4 GB of memory for prototyping purposes. To use Knative in a production environment, requires at least 6 CPUs, 6 GB of memory, and 30 GB of disk space.
For the installation process, ensure you have the kubectl
CLI, and administrative access to a Kubernetes cluster.
Installing the Knative Serving Component
The first step is to install the custom resource definitions (CRDs) required by the Knative Serving component. You can install the CRDs for the release v1.4.0 by running the following command:
kubectl apply -f https://github.com/knative/serving/releases/download/knative-v1.4.0/serving-crds.yaml
The next step is to install the core components of Knative Serving.
kubectl apply -f https://github.com/knative/serving/releases/download/knative-v1.4.0/serving-core.yaml
The preceding command creates a namespace called knative-serving
and deploys the core components in this namespace.
Installing a Networking Layer
Knative requires a networking layer to manage the traffic and request connections to your containerized applications. The Knative Serving component supports different network layers such as Kourier, Istio, or Contour. The following command installs Kourier v1.4.0:
kubectl apply -f https://github.com/knative/net-kourier/releases/download/knative-v1.4.0/kourier.yaml
After installing Kourier in your Kubernetes cluster, the following command configures Knative Serving, and sets Kourier as the default networking layer:
kubectl patch configmap/config-network \
--namespace knative-serving \
--type merge \
--patch '{"data":{"ingress.class":"kourier.ingress.networking.knative.dev"}}'
Verifying the Installation of Knative Serving
After installing the required CRDs, the core components of the Knative Serving component, and a network layer, you can execute the following command to monitor the installation process.
kubectl get pods -n knative-serving
In a successful installation, the STATUS
of all the pods created in the knative-serving
namespace is Running
or Completed
.
Configuring the DNS (optional)
To access your containerized applications you might need to configure the DNS in Knative, especially on local Kubernetes installations. Knative provides several ways to configure the DNS, you can use a magic DNS, a real DNS, or a temporary DNS.
The following command creates the required resources to use magic DNS with Knative:
kubectl apply -f https://github.com/knative/serving/releases/download/knative-v1.4.0/serving-default-domain.yaml
The preceding command creates a Job that configures Knative Serving to use sslip.io
as the DNS suffix.
Note |
If you are using Minikube, then you might have to execute the |
Installing the Knative Eventing Component
The first step is to install the custom resource definitions (CRDs) required by the Knative Eventing component. You can install the CRDs for the release v1.4.0 by running the following command:
kubectl apply -f https://github.com/knative/eventing/releases/download/knative-v1.4.0/eventing-crds.yaml
The next step is to install the core components of Knative Eventing.
kubectl apply -f https://github.com/knative/eventing/releases/download/knative-v1.4.0/eventing-core.yaml
The preceding command creates a namespace called knative-eventing
and deploys the core components in this namespace.
Verifying the Installation of Knative Eventing
After installing the required CRDs, and the core components of the Knative Eventing component, you can execute the following command to monitor the installation process.
kubectl get pods -n knative-eventing
In a successful installation, the STATUS
of all the pods created in the knative-eventing
namespace is Running
or Completed
.
Installing a Default Messaging Layer for Events
Knative Eventing uses events as the communication method between your cloud-native applications. The Knative Eventing component supports several types of messaging layers such as the Apache Kafka Channel, the Google Cloud Pub/Sub Channel, the In-memory Channel, and the NATS Channel. The following command installs an In-memory Channel as the default messaging layer:
kubectl apply -f https://github.com/knative/eventing/releases/download/knative-v1.4.0/in-memory-channel.yaml
Note |
The In-memory Channel is not recommended for production workloads. |
Installing a Broker Layer
Knative Eventing provides different event delivery methods such as channels and brokers. Depending on your application’s requirements, you can use brokers instead of channels to propagate events to other components of your distributed application. The Knative Eventing component supports several types of brokers, such as a Multi-tenant channel-based broker, a GCP broker, an Apache Kafka broker, and a RabbitMQ broker. The following command installs a Multi-tenant channel-based broker layer.
kubectl apply -f https://github.com/knative/eventing/releases/download/knative-v1.4.0/mt-channel-broker.yaml
Installing the Knative CLI
The kn
tool is a command-line interface (CLI) that creates and manages Knative resources. The following steps cover the installation of the Knative CLI on GNU/Linux by using a binary. For alternative installation methods, please refer to the official guide.
The first step is to download the binary for your operating system from the releases page.
After downloading the binary, you can rename the file to kn
.
mv kn-<os>-<arch> kn
Note |
In the preceding command |
The downloaded binary might not have execution permissions, so you can execute the following command to add that permission:
chmod +x kn
You can execute the kn
tool from the downloaded directory, or you can move the executable binary file to a directory in your PATH
.
mv kn /usr/local/bin
To verify the correct installation of the Knative CLI, you can execute the following command to obtain information about the version of the CLI binary:
kn version
Note |
The |