计算沙箱与容器的变化

该阶段主要检测沙箱容器(pause)与其他容器(初始化容器、临时容器、常规容器)的变化,也就是pod期望运行状态与实际运行状态。

当对pod的操作为创建时,显然不存在实际运行状态。

podActions是一个记录pod期望运行状态与实际运行状态的对象

当新建pod时,以下字段取值如下:

  • KillPod: 是否停止pod所有容器(pause容器、初始化容器、临时容器、常规容器),该值为true
  • CreateSandbox: 是否创建沙箱,该值为true
  • Attempt: 尝试创建pod沙箱次数,该值为0
  • ContainersToStart: 一般容器数组,,该值对应podspec.containers[x]数组
  • NextInitContainerToStart: 下一个将启动的初始化容器,该值对应podspec.initContainers[0]
// podActions keeps information what to do for a pod.
type podActions struct {
    // Stop all running (regular, init and ephemeral) containers and the sandbox for the pod.
    KillPod bool
    // Whether need to create a new sandbox. If needed to kill pod and create
    // a new pod sandbox, all init containers need to be purged (i.e., removed).
    CreateSandbox bool
    // The id of existing sandbox. It is used for starting containers in ContainersToStart.
    SandboxID string
    // The attempt number of creating sandboxes for the pod.
    Attempt uint32

    // The next init container to start.
    NextInitContainerToStart *v1.Container
    // ContainersToStart keeps a list of indexes for the containers to start,
    // where the index is the index of the specific container in the pod spec (
    // pod.Spec.Containers.
    ContainersToStart []int
    // ContainersToKill keeps a map of containers that need to be killed, note that
    // the key is the container ID of the container, while
    // the value contains necessary information to kill a container.
    ContainersToKill map[kubecontainer.ContainerID]containerToKillInfo
    // EphemeralContainersToStart is a list of indexes for the ephemeral containers to start,
    // where the index is the index of the specific container in pod.Spec.EphemeralContainers.
    EphemeralContainersToStart []int
}
Copyright © weiliang 2021 all right reserved,powered by Gitbook本书发布时间: 2024-04-22 16:03:41

results matching ""

    No results matching ""