While dealing with Kubernetes client kubectl, we may get confused with a set of questions like.
What is the need of these command options if they do similar operations ? Is there any specific use-case in which each need to be used ? . Is there any difference in the internal functioning of each of these commands ?
kubectl create = Creates a new k8s resource in the cluster
kubectl replace = Updates a resource in the live cluster
kubectl apply = If I want to do create + replace
In Kubernetes, there are different ways to manage Kubernetes objects.
The create, delete, replace is an option that is part of the imperative approach. This means we will have to instruct the Kubernetes client to do what needs to be performed. So it is like a user guided approach.
In case of apply option, Kubernetes will take care of everything what we need. We do not have to instruct and deal with the individual steps. This is the Declarative approach.
In simple words, the imperative approach is similar to cooking food and declarative approach is like ordering ready to eat food.
I hope this explanation is clear. Feel free to comment if you have any questions or suggestions.