使用 client-go 验证是否删除了 kubernetes pod
Verifying that a kubernetes pod is deleted using client-go
我试图确保在继续另一个 Kubernetes 操作之前删除 pod。所以我的想法是调用Pod Delete函数,然后调用Pod Get函数。
// 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?
err != nil && errors.IsNotFound(err)
这也很愚蠢,你不应该这样做。
我试图确保在继续另一个 Kubernetes 操作之前删除 pod。所以我的想法是调用Pod Delete函数,然后调用Pod Get函数。
// 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?
err != nil && errors.IsNotFound(err)
这也很愚蠢,你不应该这样做。