Knative: Benefits, Components, and a Quick Setup Guide

Discover Knative, the Google open source project that lets you set up serverless infrastructure based on Kubernetes in any cloud.

July 11, 2022

What Is Knative?

Knative is an open source project that enables you to deploy, run, and manage serverless applications on Kubernetes. A serverless architecture eliminates the need to manage the underlying infrastructure. A serverless platform like Knative can take pieces of code known as serverless functions, execute and scale them on demand with no user intervention.

Knative was initially created by Google. It is now a community project with contributions from over 50 companies, all striving to deliver the components needed to build and run serverless applications on Kubernetes. 

Here are key serverless-enabling features of Knative:

  • Scale-to-zero 
  • In-cluster builds
  • Auto scaling
  • Eventing framework 

In this article:

Benefits of Knative

Knative enables serverless Kubernetes, ensuring developers do not have to perform servers management and provisioning tasks. It eliminates the need to set up complex infrastructure, freeing time to focus on code. Instead of writing in-house components, you can use third-party Backend-as-a-Service (BaaS) components for the entire application.

Here are additional benefits:

  • Knative provides a serverless environment that lets you deploy code to a Kubernetes platform, such as the Red Hat OpenShift Container Platform.
  • Package your code as a container image to create a service and hand it to the system. Knative starts and stops instances automatically as needed while your code runs. 
  • Knative keeps resource consumption restricted only to the resources your code needs to perform. 
  • Knative enables you to reduce operations costs by paying for cloud-based compute time as needed.

Knative is an open source community project maintained by many companies, including Google, Red Hat, and IBM. The open source nature of the projects minimizes vendor lock-in, providing more control to the user.

Related content: Read our guide to serverless containers

How Does Knative Work?

Knative can be deployed on-premises, in public clouds, and in third-party data centers. The project codifies Kubernetes best practices and frameworks, providing reusable components that focus on solving various mundane tasks. Here are examples:

  • Building applications from source code to container images.
  • Auto-scaling workloads.
  • Routing and managing traffic during deployment. 
  • Binding running services to a growing ecosystem of event sources. 

In Knative, container images serve as the deployment unit, allowing developers to use any desired framework, language, or idiom. Knative supports common development patterns, including GitOps, ManualOps, and DockerOps, and tools and frameworks like Django, Spring, and Ruby on Rails.

You can easily plug Knative into your existing build and CI/CD toolchains. It enables developers to focus on open-source-first technologies that can run on any Kubernetes-supported cloud or infrastructure. As a result, developers can gain the flexibility and control needed to adapt the system to suit their unique requirements.

Knative Components

Knative Build 

The Knative Build component automates the process of converting source code into containers. This process works as follows:

  1. Knative retrieves source code from a code repository like GitHub.
  2. Knative installs low-level dependencies required to run your code, such as environment variables and software libraries.
  3. Knative builds container images and saves them to a registry where Kubernetes and developers can find it.

Knative uses the Kubernetes API and other tools for its build process. Developers can specify variables such as source code location and required dependencies by creating a manifest (typically a YAML file). Knative can use this manifest to automatically build the container.

Knative Serving

The Knative Serving component deploys and runs containers as extensible Knative services. Serving provides the following key capabilities:

  • Configurations that define service state. 
  • Version management for services, ensuring that when configuration changes, a new version of the service is created and the old version is saved.
  • Smart service routing, enabling dynamic traffic routing to different versions of the service (this enables deployment strategies such as blue/green and canary deployment). 
  • Service auto scaling up to thousands of container instances and down to zero (meaning there are no active instances of the service).

Knative Eventing

The Knative Eventing component makes it possible to trigger container-based services and functions on a variety of events. Knative queues these events and dispatches them to the appropriate container, so there is no need to write scripts or implement middleware.

In addition, Knative Eventing provides:

  • Channels—independent event queues
  • Buses—messaging platforms that deliver events to containers
  • Feeds—attach events to actions taken by a container.
  • Native event sourcing—allows developers to connect to third-party event producers. Knative Eventing automatically creates the connection and routes the events to containers. 

Installing Knative


  1. Run a minimal Kubernetes cluster on your local machine. There are several ways to do this—one is using the Docker Desktop Deploy on Kubernetes option. 
  2. Install KinD and kubectl using the Chocolatey package (on a Windows machine):

choco install kind

choco install kubernetes-cli

  1. Install the Knative CLI tool called kn. See instructions here

Installation using the quick start plugin

When all prerequisites are ready, you can proceed with installing Knative components. A Knative component is a collection of Kubernetes Custom Resource Definitions (CRDs) that you deploy to your native Kubernetes cluster. 

To make this process easier, Knative provides a quickstart plugin for development environments. This plugin lets you install a local Knative cluster on KinD using the Knative client. Get the quick start plugin here.

To install Knative in your local Kubernetes cluster using the quick start plugin, run this command:

kn-quickstart kind

The plugin does the following:

  • Creates a cluster called knative
  • Installs Knative Serving with Kourier as default networking layer and as DNS layer 
  • Installs Knative Eventing with an in-memory Broker and Channel

To make sure the quickstart plugin is installed correctly, query Kind clusters and see if there is a cluster called knative.

Knative Security with Aqua 

Knative is installed as a Kubernetes Application, Aqua Cloud Native Security Platform with the feature Kubernetes Security Posture Management (KSPM) ensures ongoing secure configuration with built-in CIS benchmarks, least privilege RBAC, pen-testing, and pod deployment policies