Skip to content

No need of "--restart=Never" flag to create a pod#197

Open
parth-pandit wants to merge 1 commit into
dgkanatsios:mainfrom
parth-pandit:patch-13
Open

No need of "--restart=Never" flag to create a pod#197
parth-pandit wants to merge 1 commit into
dgkanatsios:mainfrom
parth-pandit:patch-13

Conversation

@parth-pandit

Copy link
Copy Markdown
Contributor

No description provided.

@dgkanatsios

Copy link
Copy Markdown
Owner

thanks! Is --restart=Never deprecated? It's mentioned in the official kubectl docs https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands

@chirangaalwis

chirangaalwis commented Oct 31, 2021

Copy link
Copy Markdown

thanks! Is --restart=Never deprecated? It's mentioned in the official kubectl docs https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands

@dgkanatsios this is not deprecated but there is no real reason for using this and AFAIU that is what @parth-pandit is suggesting. In other words it is not mandatory.

+1 for this change.

@leonK-DI

leonK-DI commented Feb 7, 2022

Copy link
Copy Markdown

it is necessary if you want to run a temp pod, otherwise you are not going to get the logs, e.g.

kubectl run busybox --image=busybox --rm -it --restart=Never --labels=access=granted -- wget -O- http://nginx:80 --timeout 2`

But I am not sure why that is the case...

@pacozaa

pacozaa commented Oct 16, 2022

Copy link
Copy Markdown
Contributor

@leonK-DI
According to this doc https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#run

Because --rm means your pod will be deleted(?) as soon as the command wget -O- http://nginx:80 --timeout 2 finishes

and as far as Kube is concerned it will keep your pod up all the time which means when the pod is terminated after finishing the wget command it will restart the pod again.

--restart=Never prevents the mentioned scenario from happening.

I know this might not be 100% correct because the document stated that --rm means delete the pod after it exits but I am not sure if in this case, it's equivalent to pod delete. (I suppose not if it's equivalent to pod delete it wouldn't be restarted again.)

@dgkanatsios Please confirm if my speculation is correct.

@pacozaa

pacozaa commented Oct 16, 2022

Copy link
Copy Markdown
Contributor

Also there is something similar here #167

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants