计算沙箱与容器的变化
该阶段主要检测沙箱容器(pause)与其他容器(初始化容器、临时容器、常规容器)的变化,也就是pod
期望运行状态与实际运行状态。
当对pod
的操作为创建
时,显然不存在实际运行状态。
podActions
是一个记录pod
期望运行状态与实际运行状态的对象
当新建pod
时,以下字段取值如下:
KillPod
: 是否停止pod
所有容器(pause
容器、初始化容器、临时容器、常规容器),该值为true
CreateSandbox
: 是否创建沙箱,该值为true
Attempt
: 尝试创建pod
沙箱次数,该值为0
、ContainersToStart
: 一般容器数组,,该值对应pod
的spec.containers[x]
数组NextInitContainerToStart
: 下一个将启动的初始化容器,该值对应pod
的spec.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
}