When I run ‘kubectl create deployment myredis –image=redis:latest’ does this mean the application is running in the cluster? I see is as deployed when I enter ‘kubectl get deployment’ . If so, then why do we need the ‘kubectl run ‘ command? What is the difference?
Not having a background in Kubernetes, I’ve done a quick Google search, and my answer comes from the Kubectl Reference Docs – Commands. Where
kubectl create will create a resource,
kubectl run will create and run the resource.
Anyone else with knowledge or experience in Kubernetes, feel free to correct me in this!
Using Generators (Run, Expose)
Using Imperative way (Create)
Using Declarative way (Apply)
All of the above ways have a different purpose and simplicity. For instance, If you want to check quickly whether the container is working as you desired then you might use Generators .
If you want to version control the k8s object then it’s better to use declarative way which helps us to determine the accuracy of data in k8s objects.
kubectl create is used to create variety of objects other than pods and kubectl run us used to create only pods as per version 1.18.
kubectl run –generator=deployment/apps.v1 is DEPRECATED and will be removed in a future version. Use kubectl run –generator=run-pod/v1 or kubectl create instead.
i got this when i run kubectl run