[Serverless Knative] Knative - Getting Started

Knative

Knative is the Enterprise-grade Serverless on your own terms, Kubernetes-based platform to deploy and manage modern serverless workloads.

Highlights

  • Stand up scalable, secure, stateless services in seconds.

  • Focused API with higher level abstractions for common app use-cases.

  • Pluggable components let you bring your own logging and monitoring, networking, and service mesh.

  • Run Knative anywhere Kubernetes runs, never worry about vendor lock-in.

  • Seamless developer experience, supports GitOps, DockerOps, ManualOps, etc…

  • Supports many common tools and frameworks such as Django, Ruby on Rails, Spring, and many more.

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

Prerequisites

Before installing Knative, you must meet the following prerequisites:

  • Kubernetes (K8S)

    Kubernetes (K8s) is an open-source system for automating deployment, scaling, and management of containerized applications.

    For more information about installing and using Kubernetes (K8s), see the Kubernetes (K8s) Docs.

About installing Knative

  • On your cluster

    You can install the Serving component, Eventing component, or both on your cluster by using one of the following deployment options:

    • Using a YAML-based installation:

      • Install Knative Serving by using YAML

      • Install Knative Eventing by using YAML

    • Using the Knative Operator.

  • Or Vendor managed Knative offerings

    Following the documentation for vendor managed Knative offerings - https://knative.dev/docs/install/knative-offerings/.

    Knative has a rich community with many vendors participating, and many of those vendors offer commercial Knative products. Please check with each of these vendors for what is or is not supported.

Installation

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

Install the latest stable Operator release:

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

Verify your installation

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

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
2
NAME               READY   UP-TO-DATE   AVAILABLE   AGE
knative-operator 1/1 1 1 19h

Track the log

Track the log of the operator:

1
$ kubectl logs -f deploy/knative-operator

Installing the Knative Serving component

Create and apply the Knative Serving CR:

You can install the latest available Knative Serving in the operator by applying a YAML file containing the following:

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

If you do not specify a version by using spec_version, the operator defaults to the latest available version.

Verify the Knative Serving deployment

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
2
3
4
5
6
7
8
NAME                   READY   UP-TO-DATE   AVAILABLE   AGE
activator 1/1 1 1 18s
autoscaler 1/1 1 1 18s
autoscaler-hpa 1/1 1 1 14s
controller 1/1 1 1 18s
domain-mapping 1/1 1 1 12s
domainmapping-webhook 1/1 1 1 12s
webhook 1/1 1 1 17s

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
2
NAME              VERSION             READY   REASON
knative-serving <version number> True

Installing Knative Serving with Istio

Knative Operator can configure 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.

The following commands install Istio and enable its Knative integration.

1. Install Istio

To configure Knative Serving to use Istio, copy the following YAML into a file:

1
2
3
4
5
apiVersion: operator.knative.dev/v1alpha1
kind: KnativeServing
metadata:
name: knative-serving
namespace: knative-serving

If Istio is installed under a namespace other than the default istio-system, add the spec.config.istio field to the YAML file as follows:

1
2
3
4
5
6
7
8
9
apiVersion: operator.knative.dev/v1alpha1
kind: KnativeServing
metadata:
name: knative-serving
namespace: knative-serving
spec:
config:
istio:
local-gateway.<local-gateway-namespace>.knative-local-gateway: "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.

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.

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.

References

[1] About installing Knative - Knative - https://knative.dev/docs/install/

[2] Knative Quickstart - Knative - https://knative.dev/docs/getting-started/

[3] Home - Knative - https://knative.dev/docs/