What I understood by the documentation is that:
kubectl create
Creates a new k8s resource in the clusterkubectl replace
Updates a resource in the live clusterkubectl apply
If I want to do create + replace (Reference)My questions are
Those are two different approaches:
kubectl create
is what we call Imperative Management. On this approach you tell the Kubernetes API what you want to create, replace or delete, not how you want your K8s cluster world to look like.
kubectl apply
is part of the Declarative Management approach, where changes that you may have applied to a live object (i.e. through scale
) are "maintained" even if you apply
other changes to the object.
You can read more about imperative and declarative management in the Kubernetes Object Management documentation.
They do different things. If the resource exists, kubectl create
will error out and kubectl apply
will not error out.