Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to build Knative in Minikube

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces you how to build Knative in Minikube, the content is very detailed, interested friends can refer to, hope to be helpful to you.

1. What is Serverless? What is Mnative?

What is Severless? here is the definition of Serverless architecture given by CNCF:

"Serverless computing refers to the concept of building and running applications that do not require server management. It describes a finer-grained deployment model where applications, bundled as one or more functions, are uploaded to a platform and then executed, scaled, and billed in response to the exact demand needed at the moment"

You can see from the definition that the Serverless architecture should have the following characteristics:

The infrastructure environment for building and running applications

No need for state management of the service

A sufficiently fine-grained deployment pattern

Scalable and paid by usage

With the exception of a sufficiently fine-grained deployment pattern, Kubernetes can provide very good support for the above features. Fortunately, whether it is to make Kubernetes fully support the Serverless architecture, or to make Google more attractive to developers on cloud, Google released Knative on Google Cloud Next 2018 and called it a "Kubernetes-based platform for building, deploying, and managing modern Serverless architectures." The main roles of Knative are described in the following figure:

Knative is committed to providing a reusable "common pattern and best practice portfolio" implementation, and currently available components include:

Build: Cloud-native source to container orchestration

Eventing: Management and delivery of events

Serving:Request-driven compute that can scale to zero

1.1 Build build system

The construction of Knative is designed to be done in Kubernetes and more closely integrated with the entire Kubernetes ecology; in addition, it aims to provide a common standardized build component that can be used in a wide range of scenarios. As stated in the official documentation, the Build build system is more about defining standardized, portable, reusable, and performance-efficient build methods. Knative provides a Build CRD object that allows users to define the build process through an yaml file. A typical Build configuration file is as follows:

ApiVersion: build.knative.dev/v1alpha1

Kind: Build

Metadata:

Name: kaniko-build

Spec:

ServiceAccountName: build-bot

Source:

Git:

Url: https://github.com/my-user/my-repo

Revision: master

Template:

Name: kaniko

Arguments:

-name: IMAGE

Value: us.gcr.io/my-project/my-app

one

two

three

four

five

six

seven

eight

nine

ten

eleven

twelve

thirteen

fourteen

fifteen

1.2 Serving: service system

The core function of Serving is to make applications run to provide services. The basic functions it provides include:

Automatic startup and destruction of containers

Generate Service, ingress and other objects related to network access according to the name

Monitor application requests and automatically expand and reduce capacity

Support blue and green release and rollback functions to facilitate the application of method flow

The Knative Serving function is developed based on Kubernetes and Istio. It uses Kubernetes to manage containers (deployment, pod) and Istio to manage network routing (VirtualService, DestinationRule).

The following figure shows the relationship between the components of Knative Serving.

1.3. Eventing: event system

Knative defines a number of event-related concepts. Introduce:

EventSource: event source, an external system capable of generating events.

Feed: bind some type of EventType and EventSource to the corresponding Channel.

Channel: a layer of abstraction of message implementation. The backend can use kafka, RabbitMQ, and Google PubSub as concrete implementations. Channel name is similar to topic in a message cluster and can be used to decouple event sources and functions. After the event, sink is sent to a channel, and then the data in the channel is consumed by the back-end function.

Subscription: by binding channel with back-end functions, a channel can be bound to multiple Knative Service.

Currently, there are three event sources supported: github (such as merge event, push event, etc.), Kubernetes (events), and Google PubSub (message system). More event sources will be connected later.

1.4 Auto-scaling

In fact, Auto-scaling is essentially used to improve the flexibility of using resources on the cloud and provide billing based on usage to provide users with cost-effective cloud services. It has the following two features:

Request-driving: dynamically scales according to the number of requests. Currently, the scaling decision is made by counting the current number of concurrent requests in the system and comparing it with the benchmark value in the configuration.

Scale to zero: completely release resources when there is no traffic, and wake up again when there is a request.

Knative Serving abstracts a series of resource objects used to define and control the behavior of applications, called Kubernetes Custom Resource Definitions (CRDs).

Service:app/function Lifecycle Management

Route: route management

Configuration: defines the expected running state

Revision: at some point code + configuration, Revision is an immutable object, modify the code or configure to generate a new Revision

The interaction between them is shown as follows:

There are three operational states in the Revision lifecycle:

Active:Revision startup, which can process requests

Reserve: after not requesting 0 for a period of time, the Revision is marked as Reserve, and the occupied resources are released and scaled to zero

Retired: Revision is obsolete and no longer receives requests

The specific process of auto-scaling, which will not be introduced here, can be understood by itself.

On how to build Knative in Minikube to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report