Removed old trick to create pods with kubectl run #167
+23
−23
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Before k8s 1.18, people would set the restart policy in their imperative commands to make
kubectl run
generate deployments, pods, or jobs depending on whether the restart policy was set to Always, OnFailure, or Never respectively. For example,kubectl run nginx --image=nginx --restart=Always
created a deployment, andkubectl run nginx --image=nginx --restart=Never
created a pod. The default behavior ofkubectl run
when a restart policy wasn't specified was also a deployment. You could even specify--schedule
to create cronjobs too. With k8s 1.18 and above,kubectl run
can now ONLY create pods, and people now have to use thekubectl create
commands to create the other objects, including deployments. The bad thing about this is that in 1.18,kubectl create deployment
doesn't support all the flags thatkubectl run
did, but with 1.19, some of these flags like--port
and--replicas
have been added to make the command more useful. With all of this in mind, this pull requests removes the--restart=Never
trick wherekubectl run
is used, since we no longer need it for forcing the command to create pods. In other words, how this flag is being used is redundant and only serves to override the default restart policy of a pod, which isAlways
and not why it was included originally. I feel this change will make things more consistent now and in line with the exam, which is based on k8s 1.19+ now.References:
https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG/CHANGELOG-1.18.md#kubectl
https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG/CHANGELOG-1.19.md#feature-3
https://alexellisuk.medium.com/kubernetes-1-18-broke-kubectl-run-heres-what-to-do-about-it-2a88e5fb389a