What I understood by the documentation is that:
We love Kubernetes is because once we give them what we want it goes on to figure out how to achieve it without our any involvement.
"create" is like playing GOD by taking things into our own hands. It is good for local debugging when you only want to work with the POD and not care abt Deployment/Replication Controller.
"apply" is playing by the rules. "apply" is like a master tool that helps you create and modify and requires nothing from you to manage the pods.
kubectl run
= kubectl create deployment
kubectl create -f your-object-config.yaml
kubectl delete -f your-object-config.yaml
kubectl replace -f your-object-config.yaml
kubectl diff -f configs/
kubectl apply -f configs/
The explanation below from the official documentation helped me understand kubectl apply
.
This command will compare the version of the configuration that you’re pushing with the previous version and apply the changes you’ve made, without overwriting any automated changes to properties you haven’t specified.
kubectl create
on the other hand will create (should be non-existing) resources.