K8S resources and working mode

Application Orchestration and Management

The resource object of Kubernetes mainly includes two parts, Spec and Status. The Spec part is used to describe the expected state, and the Status part is used to describe the observed state. These belong to the part of the resource object of Kubernetes, and Kubernetes also contains A Metadata section, that is, the metadata section. Metadata mainly includes Labels used to identify resources, used to describe the annotations of resources and the relationship between resources.

Among them, Label is one of the most important metadata, the content it represents is the resource label, and the resource label is an identifying KEY:VALYE key-value pair. The main function of this label is to filter resources and combine resources, so that users can query related resource content according to the Label.

The second is the Kubernetes service selection Selector, which can also be called a label selector. This is the core grouping mechanism of Kubernetes. Through the label selector, clients/users can identify a set of resource objects with common characteristics or attributes, including those based on Value-equal query conditions and subset equality-based query conditions.

The role of Selector: 1. The
kube-controller process filters the number of Pod replicas to be monitored through the Label Selector defined on the resource object RC, so as to realize the fully automatic control process that the number of Pod replicas always meets the expected settings

2. The kupe-proxy process selects the corresponding Pod through the Label Selector of the Service, and automatically builds a routing table for forwarding requests from each Service to the corresponding Pod, thereby realizing the intelligent load balancing mechanism of the Service

3. By defining specific Labels for some Nodes and using the label scheduling strategy of NodeSelector in the Pod definition file, the Kube-scheduler process can realize the feature of Pod-directed scheduling

Another important metadata is: annotations. It is generally used by systems or tools to store non-indicative information of resources, and can be used to expand the description of the spec/status of resources

control loop mode

控制循环模式是控制型模型的核心,在控制循环中包括了控制器,被控制的系统,以及能够观测系统的传感器这三个逻辑组件。
这些组件都是逻辑上的,外部系统可以通过修改spec来控制资源,控制器会比较资源的spec和status,从而判断两个资源的区别,也就是diff,diff会决定最终对系统进行什么样的控制操作,控制操作将会产生全新的输出,传感器将会将当前应用的状态向上层转发,最终系统的各个组件都是独立运行的,系统将会最终趋向于稳定的状态。

Declarative API

而声明式API是指通过设置目标等方式向目标系统设置要求,让目标系统以自治的方式达成目标,最终实现系统的任务,而我们的Kubernetes就是采用的声明式API实现调用。

Imperative API

命令式API是指我们需要向系统发出明确的指令,告诉吸引同要做什么,从而实现我们要完成的任务的具体细节。

Guess you like

Origin blog.csdn.net/qq_27180763/article/details/123825123