In this complete guide, learn about Knative and how it can help complement your Kubernetes system.
What is Knative?
Kubernetes is a powerful tool for managing complex collections of software containers, but the plaform has configuration and management needs of its own. Enter Knative, an extension of Kubernetes that hides many of these tasks from you and adds serverless capabilities.
Google, in close collaboration with IBM, Red Hat, Pivotal, and SAP, developed Knative as an open source platform. It supports containers, a form of packaged applications that run in cloud environments. Knative runs on top of the Kubernetes container orchestration system, which controls large numbers of containers in a production environment.
Kubernetes is a complex product that needs a lot of configuration to run properly. Developers must log into individual worker nodes to carry out repetitive tasks, such as installing dependencies and configuring networking rules. They must generate configuration files, manage logging and tracing, and write their own CI/CD scripts using tools like Jenkins. Before they can deploy their containers, they have to go through multiple steps to containerize their source code in the first place.
Knative helps developers by hiding many of these tasks, simplifying container-based management and enabling you to concentrate on writing code. It also supports for serverless functions, which we'll get into further in the article.
For an overview of Knative, its components, and its capabilities, see "What is Knative?":
Knative consists of three main components: Build, Serve, and Event.
The Build component of Knative turns source code into cloud-native containers or functions. This process involves multiple steps, including the following:
- Pulling source code from a code repository
- Installing the underlying dependencies—such as environment variables and software libraries—that the code needs to run
- Building container images
- Putting them into a container registry for other developers to use
Knative uses Kubernetes’ underlying resources for its Build process. Keep in mind that Knative must know where to find the assets to complete these tasks, meaning that you still need to specify the underlying components supporting all these steps. Once you do, Knative can automate your container builds.
Knative offers a Serve component that runs containers as scalable services. Not only can it scale containers up to run in the thousands, but it can scale them down to the point where there are no instances of the container running at all.
Knative's Serve component offers two features that are important for container management. The first is configuration, which lets you create different versions of the same container-based service. Knative lets these different versions run concurrently, and this is where the other feature of its serving component comes into play.
The second feature is service routing. Let's say you have a new version of a software service that you want to offer to your users. You might not want to move them all over to use the new service yet. Instead, you might want to migrate a subset of users to ensure that the service works well for them. You can use Knative's routing capabilities to send a percentage of user requests to the new version of the service, while still sending most other requests to the old one. As you become more confident that the new version of the service works well, you can use Knative's routing to send more requests to the new service.
The Event component of Knative enables different events to trigger their container-based services and functions. Knative queues and delivers those events to your container-based service or function so that you don't have to write scripts or implement middleware to do that for you. It handles channels, which are queues of events that developers can choose from, and the bus, a messaging platform that delivers events to containers. It also enables developers to set up feeds, which connect an event to an action for their containers to perform.
Knative Event sources help automate creating connections to event producers by allowing you to express your interest in certain types of events, whereby Knative eventing will automatically create the connection to the event producer and route the generated events to your service. With this, you no longer need to figure out how to programmatically make these connections for each type of event producer—Knative will do it for you.
Knative and Kubernetes
Kubernetes is an orchestration platform for containers. It handles a large number of containers that can make up a cloud-native application infrastructure, providing scaling, load balancing, and health monitoring capabilities.
Knative extends Kubernetes by adding a range of extra services that simplify Kubernetes configuration and management, enabling developers to focus on writing application code.
For more info on Kubernetes, its capabilities, and how Knative can fit in, check out the video "Kubernetes Explained":
Benefits of Knative
Knative offers several benefits for Kubernetes users wanting to take their use of containers to the next level:
- Faster iterative development: Knative cuts valuable time out of the container building process, which enables you to develop and roll out new container versions more quickly. This makes it easier to develop containers in small, iterative steps, which is a key tenet of the agile development process.
- Focus on code: DevOps may empower developers to administer their own environments, but at the end of the day, coders want to code. You want to focus on building bug-free software and solving development problems, not on configuring message bus queues for event triggering or managing container scalability. Knative enables you to do that.
- Quick entry to serverless computing: Serverless environments can be daunting to set up and manage manually. Knative allows you to quickly set up serverless workflows. As far as the developers are concerned, they’re just building a container—it’s Knative that runs it as a service or a serverless function behind the scenes.
What challenges does Knative solve?
Knative's benefits can help solve a variety of real-world challenges facing today's developers, including the following:
- CI/CD set up: Continuous integration and deployment workflows are a linchpin of DevOps processes. Automated gating for software builds and deployments can reduce deployment times while increasing software quality. The problem is that these automated workflows can take time and expertise to set up, often involving many different products. Knative is a useful tool that can be used as part of a pipeline automation project to get DevOps teams up and running.
- Easier customer rollouts: The problem with a fast release cadence is that developers end up testing software on their users. Rolling out new releases to the customer base can expose software issues that may affect business processes. Knative's configuration and routing system allow you to expose new container revisions to a subset of the user base, gradually increasing that audience over time and quickly rolling back to older versions should problems arise.
Who should use Knative?
Server-side developers focused on cloud-native development will find Knative highly suitable when using Kubernetes as their base container platform. Development teams that want to embrace DevOps methodologies and automate CI/CD pipelines using automated building and deployment will find it a useful workflow tool. Anyone struggling with configuring Kubernetes to manage container-based environments is also a perfect candidate for Knative, as are those adopting a microservices-based approach using containers.
For Kubernetes users who want to adopt serverless computing in the enterprise, Knative is a valuable tool.
Knative offers different capabilities and benefits for different audiences. (Source: Welcome to Knative – www.knative.com/docs)
Knative and serverless
Serverless computing is a relatively new way of deploying code that can help make cloud-native software even more productive. Instead of having a long-running instance of your software waiting for new requests (which means you are paying for idle time), the hosting infrastructure will only bring up instances of your code on an "as-needed" basis. This means it will also scale it up and down as the demand for your code fluctuates. Infrequently-used software services can potentially waste computing power if left to run constantly when only serving the occasional query. Serverless computing helps reduce unnecessary computing power.
Knative breaks down the distinction between software services and functions by enabling developers to build and run their containers as both. Knative takes care of the details, and developers can concentrate on the code.
Knative and Istio
Knative's serving component incorporates Istio, which is an open-source tool developed by IBM, Google, and ridesharing company Lyft to help manage tiny, container-based software services known as microservices.
Istio provides a routing mechanism that allows services to access each other via URLs in what's known as a service mesh. It's essentially a switchboard for the vast, complex array of container-based services that can quickly develop in a microservice environment. It handles all of this routing without needing the developer to make any changes to their underlying application code.
Knative uses Istio’s service mesh routing capabilities to route calls between the services that it runs.
Istio manages authentication for service requests and automatic traffic encryption for secure communication between services. It can also gather detailed metrics about microservice operations to help developers and administrators plan infrastructure optimization.
The software can manage traffic routing and enforce policies across the whole mesh—setting parameters for rate limiting to avoid service overloads, for example. These features complement Knative, which is built on top of Istio, incorporating the service mesh management framework's functionality into its container serving component.
Read more about how Knative uses Istio in this blog, “Istio and Knative: Extending Kubernetes for a New Developer Experience”.
For a further overview of Istio, check out the video "What is Istio?":
Knative and IBM
Knative is a welcome addition to the world of container management. Installing it as a management layer atop Kubernetes will help you to turn your source code into effective, highly-productive container-based services and functions, all while taking many of the configuration and management headaches away. A Knative evaluation should be at the top of the to-do lists for both developers seeking to quickly roll out new code and administrators looking for new efficiencies in cloud operations
In its quest to make the development, deployment, and management of container-based software easier, developers can use managed cloud services to install and run Knative. A cloud-based service can provide Knative with the computing resources that it needs to scale large numbers of containers.
- Read more about the IBM Cloud Kubernetes Service.
- Check out IBM’s Managed Knative on IBM Cloud Kubernetes Service announcement.
- "Install Knative and Deploy an App on IBM Cloud"
- Introductory Knative tutorial
- Knative 101 tutorial
- The New Builders Podcast Ep. 44: Knative—It’s a Win-Win-Win
- To learn more about best practices to enable and expedite container deployment in production environments, see the report "Best Practices for Running Containers and Kubernetes in Production."
- For an overview of how managed Kubernetes can help you in your cloud journey, see our video, "Advantages of Managed Kubernetes":
To get started with Knative, sign up for an IBM Cloud account.
Subscribe to IBM Cloud News
IBM Cloud News connects you to insight and information you can put to work right away—straight from the minds of IBM Cloud experts, IBM customers, and business and IT leaders.Subscribe now