capabilities.work

Restart a Pod by Deleting It

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

Recipe · 3 steps

Restart a Pod by Deleting It

Delete a controller-owned pod so its controller recreates it.

  1. Read the pod and capture its ownerReferences. A pod with no owner will not be recreated after deletion, so this read is the safety check.
  2. Delete the pod. The kubelet sends SIGTERM and waits the grace period before forcing termination; the owning controller schedules a replacement.
  3. List the pods matching the same label selector to observe the replacement pod. A new uid distinguishes the replacement from the deleted pod.
What you'll need to have ready
  • namespace: The namespace containing the pod.
  • podName: The name of the pod to restart.
  • gracePeriodSeconds: Seconds to wait before forcefully terminating the pod.
  • labelSelector: Label selector matching the pod's siblings (e.g. app=nginx).
For your developer

Arazzo workflow kubernetes:restart-pod, 3 operations: getNamespacedPod → deleteNamespacedPod → listNamespacedPods. Specs on APIs.io.