Kubernetes deployment failure due to invalid command syntax
Symptom
Kubernetes POD in "RunContainerError" status after deployment and constantly restarts after deletion
Error Message
Warning Failed 16s (x3 over 36s) kubelet, node01 Error: failed to start container "nginx": Error response from daemon: OCI runtime create failed: container_linux.go:345: starting container process caused "exec: \"generator=run-pod/v1\": stat generator=run-pod/v1: no such file or directory": unknown Warning BackOff 4s kubelet, node01 Back-off restarting failed container
Cause
If you create a pod using the kubectl run
command and forget to use "--" in front of generator=run-pod/v1
run will cause a no such file or directory
unknown error message.
Resolution
Locate the deployment for the created POD by running kubectl get deployments --all-namespaces
$ kubectl get deployments --all-namespaces NAMESPACE NAME READY UP-TO-DATE AVAILABLE AGE default nginx 0/1 1 0 6m7s
Delete the deployment that is failing by running kubectl delete -n NAMESPACE deployment DEPLOYMENT
:
$ kubectl delete -n default deployment nginx deployment.apps "nginx" deleted
Rerun the deployment by running kubectl run --image= --generator=run-pod/v1
:
$ kubectl run nginx --image=nginx --generator=run-pod/v1 pod/nginx created