<p>My approach is:</p>

<pre class="lang-golang prettyprint-override"><code>func restartPod(meta metav1.ObjectMeta, kubeClient kubernetes.Interface) error {
    err := kubeClient.CoreV1().Pods(meta.Namespace).Delete(meta.Name, deleteInForeground())
    if err != nil {
        return err
    }

    //time.Sleep(2 * time.Second)
    return wait.PollImmediate(5*time.Second, 5*time.Minute, func() (done bool, err error) {
        pod, err := kubeClient.CoreV1().Pods(meta.Namespace).Get(meta.Name, metav1.GetOptions{})
        if err != nil {
            return false, nil
        }

        return pod.Status.Phase == v1.PodRunning &amp;&amp; pod.Status.ContainerStatuses[0].Ready, nil
    })
}
</code></pre>

<p>It doesn't work because the deletion of pod is non-blocking, means it doesn't wait for the pod to be deleted. So the <code>Get</code> pod method returns the pod with running state. If I use <code>sleep</code> for some seconds after pod deletion then it works fine. Is there any better way to do this without using <code>sleep</code>?</p>

<p>In the metadata of every object there is UUID in a field called <code>uid</code>. You can compare and wait until the pod is Ready <em>and</em> has a different UUID. See <a href="https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids</a> for more details (though really that's about all there is to say).</p>
