CKAD-exercises
CKAD-exercises copied to clipboard
"--restart=Never" Still needed?
I don't think we need --restart=Never
option anymore with the latest K8s version as no deployment is created when we run
kubectl run nginx --image=nginx
k8s@k8s-m:~$ kubectl run nginx --image=nginx
pod/nginx created
k8s@k8s-m:~$ kubectl get po
NAME READY STATUS RESTARTS AGE
nginx 1/1 Running 0 4s
k8s@k8s-m:~$
k8s@k8s-m:~$ kubectl get deployments.apps
No resources found in default namespace.
It was necessary for k8s lower than 1.18, not anymore. kubectl run only creates pods. For deployment do kubectl create deployment.
Well while this is true but having restart=Never comes in handy when you are working with pods that have images like busybox, alpine etc.
@shubhamrajvanshi Can you expand this? Why does it come in handy when working with busybox or alpine?
@srikanthsrs because mentioned images without i.e. sleep infinity command will exit with 0 exit code (container exits) and then will be restarted. Nginx image has infinity process running inside so it wont exit - wont be restarted (container is running)
If --restart=Never
is only relevant to busybox and alpine pods, then shouldn't this option be removed in examples using other images such as nginx? This should help clarify usage.