One of the points in the kubectl best practices section in Kubernetes Docs state below:
Pin to a specific generator version, such as
kubectl run --generator=deployment/v1beta1
But then a little down in the doc, we get to learn that except for Pod, the use of --generator option is deprecated and that it would be removed in future versions.
Why is this being done? Doesn't generator make life easier in creating a template file for resource definition of deployment, service, and other resources? What alternative is the kubernetes team suggesting? This isn't there in the docs :(
kubectl create is the recommended alternative if you want to use more than just a pod (like deployment).
https://kubernetes.io/docs/reference/kubectl/conventions/#generators says:
Note:
kubectl run --generatorexcept forrun-pod/v1is deprecated in v1.12.
This pull request has the reason why generators (except run-pod/v1) were deprecated:
The direction is that we want to move away from
kubectl runbecause it's over bloated and complicated for both users and developers. We want to mimicdocker runwithkubectl runso that it only creates a pod, and if you're interested in other resourceskubectl createis the intended replacement.
For deployment you can try
kubectl create deployment hello-node --image=gcr.io/hello-minikube-zero-install/hello-nodeand
Note: kubectl run --generator except for run-pod/v1 is deprecated in v1.12.