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.
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 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.
Helping organizations transform their IT infrastructure with top-notch Cloud Computing services
- Cloud Migration
- AIML & IoT
Installing Knative Serving
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 \
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
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
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.
Get your new hires billable within 1-60 days. Experience our Capability Development Framework today.
- Cloud Training
- Customized Training
- Experiential Learning
CloudThat is also the official AWS (Amazon Web Services) Advanced Consulting Partner and Training partner and Microsoft gold partner, helping people develop knowledge of the cloud and help their businesses aim for higher goals using best in industry cloud computing practices and expertise. We are on a mission to build a robust cloud computing ecosystem by disseminating knowledge on technological intricacies within the cloud space. Our blogs, webinars, case studies, and white papers enable all the stakeholders in the cloud computing sphere.
Drop a query if you have any questions regarding Kubernetes and I will get back to you quickly.
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.