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 analyze the key modules of Kubelet with K8S source code

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article will explain in detail how to use K8S source code to analyze the key modules of Kubelet. The content of the article is of high quality, so the editor will share it for you as a reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

1. Operation mechanism

In a k8s cluster, a kubelet process runs on each node node. The process handles tasks issued by master, periodically synchronizes its own status and manages Pod. Overall, the kubelet process mainly completes the following parts:

Node management-synchronizes the status information of this node to the Api Server at regular intervals.

Pod management-synchronizes pod information from files, Http endpoints, and API Server to create and manage all pod on the node.

Container health check-two types of probes, Liveness & Readiness, are provided to monitor and check the container.

Resource monitoring-use cAdvisor to achieve CPU, memory and other resource statistics and monitoring.

two。 Key module

The core modules and interactions contained in kubelet can be simply shown in the figure on the right:

2.1 CRI & Dockershim

K8s proposes a concept called CRI (Container Runtime Interface) to support multiple container runtimes (currently mainly docker,rkt). CRI is a set of gRPC interfaces that contain all the operations of container lifecycle management. K8s all operations on the container are done through CRI, which achieves the two goals of "container runtime replaceability" and "isolating container runtime iterative changes".

CRI mainly contains two core interfaces: RuntimeService and ImageManagerService, which are used to manage containers and images, respectively. The most common implementation of CRI is dockershim. Dockershim implements RuntimeService and ImageManagerService interfaces, which are exposed by gRPC protocol. In the internal implementation, dockershim uses the interface provided by libdocker, communicates with docker daemon with HTTP (s) protocol, and translates CRI protocol into docker protocol.

The / pkg/kubelet/kuberuntime package of K8s provides a KubeGenericRuntime interface with a built-in kubecontainer.Runtime interface that encapsulates the operation of the container-image. The internal structure kubeGenericRuntimeManager provides the implementation of this interface and interacts with cri-shim through CRI client.

2.2 introduction to Modul

The complete package names and functions of other modules in the figure are briefly described as follows:

Module

Packet path

Action

Status.Manager/pkg/kubelet/status maintains status information of all pod and synchronizes with API Server ImageManager/pkg/kubelet/images only provides EnsureImageExists method, pulls image ImageGCManager/pkg/kubelet/images with ImageService API, deletes image, reclaims disk space ContainerGC/pkg/kubelet/container and deletes dead containers Reclaim disk space ConfigMapManager/pkg/kubelet/configmap management configmapOOMWatcher/pkg/kubelet monitor OOM events in cAdvisor prober.Manager/pkg/kubelet/prober management liveness and readiness probe ContainerManager/pkg/kubelet/cm manage containers on contacts, mainly responsible for the management of resources such as cgroup ResourceAnalyzer/pkg/kubelet/server/status provides resource statistics on nodes when eviction.Manager/pkg/kubelet/eviction reaches the resource threshold Ensure node stability through kill pods the NetworkPlugin/pkg/kubelet/network network plug-in PodLifecycleEventGenerator/pkg/kubelet/pleg periodically checks for surviving container and issues pod lifecycle events VolumeManager/pkg/kubelet/volumemanager volume manager pod.Manager/pkg/kubelet/pod to maintain all pod information on the node

On how to use K8S source code analysis of Kubelet key modules 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

Servers

Wechat

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

12
Report