Knative

On this page 7

Knative is an open-source platform that adds serverless capabilities to Kubernetes, letting teams run containers that scale automatically with traffic, scale to zero when idle and react to events. In serverless computing, it fills the gap between fully managed function services and raw Kubernetes: developers deploy a container image, and Knative handles routing, revisions and autoscaling on a cluster the organization controls.

Knative originated at Google in 2018, was developed with contributors from IBM, Red Hat, VMware and others, and became a Cloud Native Computing Foundation project. Its serving API also inspired Google Cloud Run, which exposes a largely compatible resource model as a managed service.

How Knative works on top of Kubernetes

Knative works by installing custom resource definitions and controllers into a Kubernetes cluster. Developers create high-level Knative objects, and the controllers translate them into ordinary Deployments, Services and Pods, plus routing rules in a pluggable networking layer such as Kourier, Istio or Contour.

The platform consists of two main components. Knative Serving runs request-driven HTTP workloads, while Knative Eventing delivers events between producers and consumers using the CloudEvents specification. Each component can be installed independently, and the table below lists the core resources.

ResourceComponentPurpose
ServiceServingTop-level object that manages a workload’s configuration and routes
ConfigurationServingDesired state of the code and settings; each change creates a revision
RevisionServingImmutable snapshot of code and configuration at one point in time
RouteServingMaps a network endpoint to one or more revisions with traffic percentages
Broker and TriggerEventingEvent hub plus filters that forward matching events to subscribers
SourceEventingAdapter that imports events from an external system
Core Knative resources

Because every configuration change produces a new immutable revision, Knative supports traffic splitting natively. A route can send 90 percent of requests to the current revision and 10 percent to a new one, which makes canary and blue-green releases a matter of editing one field.

Autoscaling and scale to zero in Knative

Knative scales workloads with the Knative Pod Autoscaler (KPA), which reacts to concurrent requests or requests per second rather than CPU usage. A small queue-proxy sidecar in each pod reports metrics, and the autoscaler adjusts the replica count within seconds.

When traffic stops for a configurable grace period, the KPA reduces the revision to zero replicas. A component called the activator then receives new requests, buffers them, signals the autoscaler and forwards traffic once a pod is ready. This mechanism saves resources but introduces a cold start, whose length depends on image size, runtime and application initialization.

SettingTypical valueEffect
Container concurrency targetAbout 100 by defaultRequests per pod before more pods are added
Min scale0 or 1 and higherZero enables scale to zero; one or more avoids cold starts
Max scaleWorkload-dependent limitCaps cost and protects downstream systems
Stable windowAbout 60 secondsPeriod over which average load is calculated
Scale-to-zero grace periodAbout 30 secondsDelay before the last pod is removed
Key autoscaling settings

Teams can switch to the standard Horizontal Pod Autoscaler for CPU-bound workloads, but then lose scale to zero. Setting a minimum scale of one is the usual compromise for latency-sensitive services.

Knative compared with other serverless options

Knative differs from managed serverless services mainly in who operates the platform and how portable the workload remains. It runs the same way on any conformant Kubernetes cluster, in a public cloud or on premises, whereas managed offerings tie the workload to one provider.

PlatformUnit of deploymentOperated byPortability
KnativeContainer imageThe cluster ownerAny conformant Kubernetes cluster
Google Cloud RunContainer imageGoogleKnative-compatible service model
AWS LambdaFunction package or imageAWSProvider-specific runtime and triggers
OpenFaaSFunction in a containerThe cluster ownerKubernetes or a lightweight host
AWS FargateContainer taskAWSNo scale to zero by request
Knative and related serverless platforms

Compared with function as a service products, Knative imposes fewer runtime constraints: any language, any HTTP server and long-lived connections such as WebSockets or gRPC streams work. The price is operational responsibility for the cluster, the networking layer and upgrades.

When to use Knative and how to configure it

Knative is a strong choice when an organization already runs Kubernetes and wants serverless behavior for many small services, internal APIs or event processors without adopting a provider-specific function platform. It is also common in hybrid and on-premises environments where managed serverless is not available.

  • Keep container images small and startup code lean to shorten cold starts.
  • Set min scale to one for user-facing endpoints with strict latency targets.
  • Tune the concurrency target to the real capacity of one pod, measured under load.
  • Use tagged revisions to test a new version on a private URL before shifting traffic.
  • Prefer a lightweight ingress such as Kourier unless a service mesh is already required.

For event-driven designs, a Broker with filtered Triggers decouples producers from consumers, while Channels and Subscriptions suit simple fan-out pipelines. Production brokers usually rely on a durable backend such as Apache Kafka rather than the in-memory default.

Limitations and common mistakes with Knative

Knative does not remove infrastructure work; it moves serverless operations onto the team that runs the cluster. The control plane, networking layer and eventing backends add components to monitor and upgrade, and idle nodes still cost money unless the cluster autoscaler also shrinks the node pool.

ProblemLikely causeFix
Slow first requestRevision scaled to zero with a large imageReduce image size or set min scale to one
Overloaded databaseNo max scale limit on a busy serviceSet max scale and connection pooling
Lost eventsIn-memory channel used in productionUse a durable Kafka-backed broker
No savings at nightNodes stay running after pods scale downEnable cluster node autoscaling
Frequent problems, causes and fixes

A frequent misconception is that Knative is a function framework. It runs containers, not functions; the separate Knative Functions tooling only helps build such containers from source code.

In simple terms

Knative is an add-on that makes a Kubernetes cluster behave like a pay-as-you-go service. A team hands it a packaged application, and Knative gives it a web address, starts copies when visitors arrive and switches everything off when nobody is using it.

Think of an office building where the lights in each room turn on when someone walks in and turn off after everyone leaves. The building is still there and still needs maintenance, but energy is spent only where people are working. Knative does the same for software running on the organization’s own computers.

A practical example

A regional bank runs a private Kubernetes platform in its own data centers because regulations limit the use of public serverless services for customer data. Its developers maintain about 120 small internal services, such as document converters and report generators, many of which receive only a few requests per hour.

The platform team installs Knative Serving with Kourier and migrates these services from always-on Deployments. Rarely used services scale to zero, while the loan-quote API keeps a minimum of two pods to meet a 300-millisecond response target. New releases go out as revisions with 10 percent canary traffic for one hour before full rollout.

After three months, the number of continuously running pods falls by roughly 60 percent, freeing enough capacity to postpone a planned hardware purchase, and failed releases are rolled back by reassigning traffic in seconds rather than redeploying.