CKAD-exercises icon indicating copy to clipboard operation
CKAD-exercises copied to clipboard

"--restart=Never" Still needed?

Open tech2blog opened this issue 4 years ago • 5 comments

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.

tech2blog avatar Nov 29 '20 18:11 tech2blog

It was necessary for k8s lower than 1.18, not anymore. kubectl run only creates pods. For deployment do kubectl create deployment.

nicoclau avatar Dec 03 '20 14:12 nicoclau

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 avatar Dec 15 '20 06:12 shubhamrajvanshi

@shubhamrajvanshi Can you expand this? Why does it come in handy when working with busybox or alpine?

srikanthsrs avatar Mar 22 '21 06:03 srikanthsrs

@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)

janekmichalik avatar Apr 27 '21 15:04 janekmichalik

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.

netserf avatar Apr 29 '21 16:04 netserf