Knative Serving on OpenShift Container Platform builds on Kubernetes and Kourier to support deploying and managing serverless applications.

It creates a set of Kubernetes custom resource definitions (CRDs) that are used to define and control the behavior of serverless workloads on an OpenShift Container Platform cluster.

These CRDs are building blocks to address complex use cases, for example:

  • Rapidly deploying serverless containers.

  • Automatically scaling pods.

  • Viewing point-in-time snapshots of deployed code and configurations.

Knative Serving resources

The resources described in this section are required for Knative Serving to be configured and run correctly.

Knative service resource

The resource automatically manages the whole lifecycle of a serverless workload on a cluster. It controls the creation of other objects to ensure that an app has a route, a configuration, and a new revision for each update of the service. Services can be defined to always route traffic to the latest revision or to a pinned revision.

Knative route resource

The resource maps a network endpoint to one or more Knative revisions. You can manage the traffic in several ways, including fractional traffic and named routes.

Knative configuration resource

The resource maintains the required state for your deployment. Modifying a configuration creates a new revision.

Knative revision resource

The resource is a point-in-time snapshot of the code and configuration for each modification made to the workload. Revisions are immutable objects and can be retained for as long as needed. Cluster administrators can modify the resource to enable automatic scaling of Pods in your OpenShift Container Platform cluster.

Serverless applications using Knative services

To deploy a serverless application using OpenShift Serverless, you must create a Knative service. Knative services are Kubernetes services, defined by a route and a configuration, and contained in a YAML file.

Example Knative service YAML
kind: Service
  name: helloworld-go (1)
  namespace: default (2)
        - image: (3)
            - name: TARGET (4)
              value: "Go Sample v1"
1 The name of the application.
2 The namespace the application will use.
3 The image of the application.
4 The environment variable printed out by the sample application.

You can create a serverless application by using one of the following methods:

  • Create a Knative service from the OpenShift Container Platform web console.

  • Create a Knative service using the kn CLI.

  • Create and apply a YAML file.

Next steps