Search code examples
kuberneteskubernetes-podclient-go

Verifying that a kubernetes pod is deleted using client-go


I am trying to ensure that a pod is deleted before proceeding with another Kubernetes Operation. So the idea I have is to Call the Pod Delete Function and then call the Pod Get Function.

// Delete Pod
err := kubeClient.CoreV1().Pods(tr.namespace).Delete(podName, &metav1.DeleteOptions{})

if err != nil {
   ....
}

pod, err := kubeClient.CoreV1().Pods(tr.namespace).Get(podName, &metav1.DeleteOptions{})

// What do I look for to confirm that the pod has been deleted?


Solution

  • err != nil && errors.IsNotFound(err)

    Also this is silly and you shouldn't do it.