0

When updating a Kubernetes RollingUpdate deployment, kubectl get pods shows some of the pods spend a few minutes in the ContainerCreating state before moving to Running. Unfortunately, the official documentation on pod states doesn't include this as a documented state. Even the kubernetes codebase has only two mentions of the term, and neither has any sort of explanatory comment.

I've been doing some adjustments to the rolling update deployment configuration value (maxUnavailable and maxSurge) and the probe configuration (initialDelaySeconds), and I'm unsure if the container startup time that these values are affecting is part of ContainerCreating or another state.

  • Could you add the k8s version that is applicable? – 030 Jul 27 '17 at 19:13
  • Right now we're using kubernetes 1.6.4, but it'd be interesting to know if it changes in any recent versions. – Xiong Chiamiov Jul 27 '17 at 21:15
2

The ContainerCreating state is applicable when the number of containers equals or is smaller than 0.

Comprehensive

According to the code snippet that is defined in the question the ContainerCreating status seems to be the default waiting state. Only if the hasInitContainers is true the defaultWaitingState will become PodInitializing. This is also indicated by the test that is mentioned as well in the question. In case of without-old-record, with-old-record or something else the ContainerState will be Reason: startWaitingReason, i.e. "ContainerCreating"

hasInitContainers

https://github.com/kubernetes/kubernetes/blob/427dfd5ce1483ead29568bf7c05a98c4c0ad081c/pkg/kubelet/kubelet_pods.go#L1256

  apiPodStatus.ContainerStatuses = kl.convertToAPIContainerStatuses(
      pod, podStatus,
      pod.Status.ContainerStatuses,
      pod.Spec.Containers,
      len(pod.Spec.InitContainers) > 0,
      false,
  )
  apiPodStatus.InitContainerStatuses = kl.convertToAPIContainerStatuses(
      pod, podStatus,
      pod.Status.InitContainerStatuses,
      pod.Spec.InitContainers,
      len(pod.Spec.InitContainers) > 0,
      true,
)
  • Thanks. That's interesting, but it's still not clear to me if the initialDelaySeconds time falls under ContainerCreating or comes after it, and if it's not part of it, what types of things would be happening during it (so I can attempt to decrease the time they take). – Xiong Chiamiov Aug 2 '17 at 21:10
  • from my understanding, initialDelaySeconds starts once the container hits a Running state. I use this setting to delay my health checks from killing a Java application while it starts. The check is set to 120 seconds, and the container enters a Ready state exactly 120 seconds after it enters Running. I have experienced slow pulls from the registry causing excessive ContainerCreating, and have not seen an impact on the timing of the health checks. YMMV – David Houde Aug 5 '17 at 0:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.