CKAD doubts on readinessProbe, rollout and sidecar

  1. Can a readinessProbe or LivenessProve be added to an initContainer?
  2. When a question asks to: Update the deployment env property. Set image as xyz . Roll back the deployment. Does that mean we should do the update of env and image together and then roll back OR first update env → save the deploy → update image → save deployment → then do rollout undo
  3. Does a sidecar needs to be added to initContainers ( the K8s doc says so) but couple of places they are in containers section.
  1. It’s allowed in the syntax; I’m not sure what a livenessProbe means in an initContainer, since it is generally speaking not a long lived process; I’d need to see what lab/question you are actually doing.
  2. Really need a real question here: a link to it would help a lot.
  3. Really need a real question here: a link to it would help a lot.
  1. As Rob says
  2. If you do the env and image updates separately, you will create 2 new revisions. Do them together, you will generate one. Either way you need a new revision to be able to roll back anything.
  3. Sidecars make no sense in initContainers. Recall that initContainers are executed in the order they are defined. One must complete successfully before the next one starts, therefore there is no concept of sidecar (two containers running simultaneously) here. Which documentation are you referring to (link please)? There may be some edge case in the newer versions of Kube, but that will not feature in CKA or CKAD exam.
  1. There was a question on updating the pod with readinessProbe using /healthz but the pod has an InitContainer and a main container. I wanted to know how to know in which one to add the readinessProbe

  2. Actually , as you have mentioned that case-1 will create 2 revisions and case-2 will create 1 revision, but then when we do a rollback both of them will rollback to a different revisions. I just needed advise in case of such question is there key word to understand if the 2 changes should be made separated or together

  3. K8s doc stating sidecar defined inside initContainer: Sidecar Containers | Kubernetes .

Thanks @rob_kodekloud @Alistair_KodeKloud

  1. This is a newer feature “sidecar containers” and are identified by having restartPolicy: Always. A regular initContainer defaults to restartPolicy: Never as it is supposed to run then exit. They are as far as I know currently not in scope for CKAD. You would generally put the readiness probe on the main container, such that it indicates that the application in the main container is ready to receive traffic. To be fair, I’m not sure what the reasoning behind allowing initContainers to be sidecars is. They work perfectly well as a main container - unless it’s to ensure the sidecar is running before the main one starts. In that case, the readiness probe on the sidecar may be used by kubelet to determine when to start the main container.
  2. In the real exam it should be clear. If the question says to roll back to revision 1, then it won’t matter how many other revisions there are.
  3. Covered by #1