Voiced by Amazon Polly |
Introduction to Knative
Knative is a cross-platform service that provides a way for running your application in a serverless fashion. As the demand for serverless computing is increasing, knative makes the job easier for running Cloud-native and Kubernetes-native workloads. This helps in reducing capacity planning, and management overhead and increases productivity in a cost-optimized way. It helps to reduce the common Kubernetes common and routine tasks like creating the pods, maintaining their lifecycle, load balancing, auto-scaling, routing traffic, and networking. It also provides a way for traffic shifting routing to multiple versions etc. Knative helps in better adoption of the microservice-based approach. It favors better rollout strategies.
Freedom Month Sale — Upgrade Your Skills, Save Big!
- Up to 80% OFF AWS Courses
- Up to 30% OFF Microsoft Certs
Knative components
Serving:
Serving helps in deploying your workloads rapidly and scaling automatically concerning the number of traffic requests with a demand model. The Serving component includes,
1. Services: it manages the entire lifecycle workload, ensures the routes for each revision, updates the routes for every revision
2. Routes: Ensures network endpoints for one or more revisions and routing to different revisions for traffic management.
3. Configurations: It includes the state of a service, it is immutable and creates a new revision for each of the changes made.
4. Revisions: It is the snapshot of each version and will be updated for each new change in the code or configuration.
Eventing:
Eventing helps in making your tightly coupled applications into loosely coupled applications. The use case can be either related to your application logic or for any CICD purpose. It provides an Event-driven approach where the trigger source can be from a variety of sources, can be your apps, or from any of the multiple cloud providers or SAAS platforms. It helps to deliver the event asynchronously to other appropriate containers.
Installing Knative Serving
Prerequisites:
A Kubernetes cluster with a version greater than 1.23 with kubectl CLI installed
- Installing the serving component
a. Install the CRDs
kubectl apply -f https://github.com/knative/serving/releases/download/knative-v1.8.0/serving-crds.yaml
b. Install the core components
kubectl apply -f https://github.com/knative/serving/releases/download/knative-v1.8.0/serving-core.yaml
2. Installing a Network Layer
a. you can install layers like kourier, Istio, or contour, we are installing kourier here
kubectl apply -f https://github.com/knative/net-kourier/releases/download/knative-v1.8.0/kourier.yaml
- Configure the serving to use this layer by defaultkubectl patch configmap/config-network \
–namespace knative-serving \
–type merge \
–patch ‘{“data”:{“ingress-class”:”kourier.ingress.networking.knative.dev”}}’
c. Fetch the External IP or CNAME by the following command
kubectl –namespace kourier-system get service kourier
3. Configure DNS by magic DNS with sslip.io or real DNS or temporary DNS
kubectl apply -f https://github.com/knative/serving/releases/download/knative-v1.8.0/serving-default-domain.yaml
Installing Knative CLI
Knative cli or kn helps to simplify the management of knative resources.
- Download the appropriate binary for your system from this page https://github.com/knative/client/releases
- Change the name to kn and move the binary
mv <path-to-binary-file> kn
chmod +x kn
mv kn /usr/local/bin
3. Verify the installation
kn version
Run your image using knative
- Create a container image of your application and push it to a repository.
- You can automate the process of building the image and pushing it to the repository using any CICD setup or kaniko image builder etc
- Create the knative service using kn or using yaml files, and change the image:tag, port number, and environment variables if any, appropriately.
kn service create hello-python –image=image:v1 –port=8080 –env TARGET= “sample application”
4. Verify with kubectl and verify from the URL given
kubectl get pods
kubectl get ksvc hello-python
5. Same can be verified using kn
kn service describe hello-python -o url
6. Verify the autoscaling capability by sending more requests, or keep it idle to completely scale down
7. List, and describe the revisions and routes by the following commands
kn revisions list -s hello-python
kn revision describe hello-python-00001
kn routes list
kn routes describe hello-python
8. Update the service with the new version
kn service update hello-python –image=image:v2
9. Delete the service
kn service delete hello-python
Conclusion
You can modify the config maps located in the knative-serving namespace for global settings to modify default configurations like you can configure autoscaling using config-autoscaler config map etc. It also provides the ability to manage traffic shifting, gradual rollouts, load balancing, etc.
Freedom Month Sale — Discounts That Set You Free!
- Up to 80% OFF AWS Courses
- Up to 30% OFF Microsoft Certs
About CloudThat
CloudThat is an award-winning company and the first in India to offer cloud training and consulting services worldwide. As a Microsoft Solutions Partner, AWS Advanced Tier Training Partner, and Google Cloud Platform Partner, CloudThat has empowered over 850,000 professionals through 600+ cloud certifications winning global recognition for its training excellence including 20 MCT Trainers in Microsoft’s Global Top 100 and an impressive 12 awards in the last 8 years. CloudThat specializes in Cloud Migration, Data Platforms, DevOps, IoT, and cutting-edge technologies like Gen AI & AI/ML. It has delivered over 500 consulting projects for 250+ organizations in 30+ countries as it continues to empower professionals and enterprises to thrive in the digital-first world.
FAQs
1. Is knative helpful for long-running workloads?
ANS: – Knative is not the best option for long-running workloads.
2. When to use knative serving and knative eventing?
ANS: – Knative serving helps run your workload like a microservice or a function to do some specific job. Whereas knative eventing helps in making your applications talk asynchronously and removes tight coupling of your applications.

WRITTEN BY Dharshan Kumar K S
Dharshan Kumar is a Research Associate at CloudThat. He has a working knowledge of various cloud platforms such as AWS, Microsoft, ad GCP. He is interested to learn more about AWS's Well-Architected Framework and writes about them.
Comments