Kubernetes Deep Dive Room

Sign Up Free or Log In to participate!

What is the difference between kubectl run and kubectl create?

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?

Nilesh

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.

Nilesh

i got this when i run kubectl run

3 Answers

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. 

Reference: 

https://stackoverflow.com/questions/48015637/kubernetes-kubectl-run-vs-create-and-apply

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.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?