capabilities.work

Quarantine a Failing Pod for Inspection

A 4-step recipe with Kubernetes. We can help you get access.

Recipe · 4 steps

Quarantine a Failing Pod for Inspection

Relabel a pod out of its controller's selector so it survives for debugging.

  1. Read the pod to capture its node, phase, and resourceVersion before the relabel, and to record the labels that currently bind it to its owner.
  2. Replace the pod with labels that no longer match the controller's selector. The ReplicaSet treats the pod as gone and creates a replacement, while this pod keeps running for inspection. The node assignment is preserved so the pod is not res
  3. List the pods still matching the app selector to confirm the controller scheduled a healthy replacement for the pod that was labelled away.
  4. Read the quarantined pod's log now that it is out of rotation and no longer under time pressure from the controller.
What you'll need to have ready
  • namespace: The namespace containing the pod.
  • podName: The name of the pod to quarantine.
  • appName: The app label value the pod currently carries and will be moved off.
  • image: Container image to preserve on the replaced pod object.
  • containerName: Container to preserve and to read logs from.
  • quarantineReason: Reason recorded as an annotation on the quarantined pod.
  • labelSelector: Label selector matching the app's healthy pods (e.g. app=nginx).
  • tailLines: Number of log lines to capture from the quarantined pod.
For your developer

Arazzo workflow kubernetes:quarantine-pod, 4 operations: getNamespacedPod → replaceNamespacedPod → listNamespacedPods → readNamespacedPodLog. Specs on APIs.io.