CKAD-exercises
CKAD-exercises copied to clipboard
Removed old trick to create pods with kubectl run
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, and kubectl run nginx --image=nginx --restart=Never
created a pod. The default behavior of kubectl 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 the kubectl 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 that kubectl 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 where kubectl 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 is Always
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