Home > database >  Pod is not found when trying to delete, however, can be patched
Pod is not found when trying to delete, however, can be patched

Time:04-06

I have a pod that I can see on GKE. But if I try to delete them, I got the error:

kubectl delete pod my-pod --namespace=kube-system --context=cluster-1 

Error from server (NotFound): pods "my-pod" not found

However, if I try to patch it, the operation was completed successfully:

kubectl patch deployment my-pod --namespace kube-system -p "{\"spec\":{\"template\":{\"metadata\":{\"annotations\":{\"secrets-update\":\"`date  '%s'`\"}}}}}" --context=cluster-1

deployment.apps/my-pod patched

Same namespace, same context, same pod. Why kubectl fails to delete the pod?

CodePudding user response:

kubectl patch deployment my-pod --namespace kube-system -p "{\"spec\":{\"template\":{\"metadata\":{\"annotations\":{\"secrets-update\":\"`date  '%s'`\"}}}}}" --context=cluster-1

You are patching the deployment here, not the pod.

Additionally, your pod will not be called "my-pod" but would be called the name of your deployment plus a hash (random set of letters and numbers), something like "my-pod-ace3g"

To see the pods in the namespace use

kubectl get pods -n {namespace}

Since you've put the deployment in the "kube-system" namespace, you would use

kubectl get pods -n kube-system

Side note: Generally don't use the kube-system namespace unless your deployment is related to the cluster functionality. There's a namespace called default you can use to test things

  • Related