Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to analyze the Internal structure of Pod with K8S Source Code

Shulou Source: shulou.com Published: 2022-05-31 19:41:38 11月14日 Update

In this issue, Xiaobian will bring you about how to use K8S source code to analyze the internal structure of Pod. The article is rich in content and analyzed and described from a professional perspective. After reading this article, I hope you can gain something.

Pod is the basic unit of K8S scheduling. A Pod contains a Pause container (root container) and multiple user containers. The state of the Pause container represents the state of the Pod, and containers in the same pod share the same ip and data volume.

Therefore, the creation of a Pod starts with building a Sandbox that contains the pause container and initializes a series of resources such as networks/data volumes.

1. Sandbox construction

To create a Pod, you must first build a Sandbox. The process is as follows:

createPodSandbox is the entry method for creation, which consists of two steps:

generatePodSandboxConfig -config for constructing a sandbox, which involves generating a sandbox cgroupParent through Kubelet

RunPodSandBox -Create a sandbox container and launch it via Docker Service(dockershim). There are four main steps: 1. pull image; 2. create container; 3. start container; 4. init network

After the above two steps, the sandbox required by the pod is running, and the network/data volume and other resources are initialized.

2. User Container Creation

Once the SandBox is up and running, you can create a user Container and add it to the Pod. The main process is as follows:

There are three main steps:

EnsureImageExists -Pull Mirrors

CreateContainer -Create container instances with CRI & dockershim

StartContainer -Run Instance

The above is how to use K8S source code to analyze the internal structure of Pod, if there is a similar doubt, you may wish to refer to the above analysis to understand. If you want to know more about it, please pay attention to the industry information channel.

Tags: Container analysis step data user run source code two content instance process status network resource same three professional small and medium representative entrance Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Shulou Information MariaDB Linux vpn