These are imperative commands :
kubectl run
= kubectl create deployment
Advantages:
- Simple, easy to learn and easy to remember.
- Require only a single step to make changes to the cluster.
Disadvantages:
- Do not integrate with change review processes.
- Do not provide an audit trail associated with changes.
- Do not provide a source of records except for what is live.
- Do not provide a template for creating new objects.
These are imperative object config:
kubectl create -f your-object-config.yaml
kubectl delete -f your-object-config.yaml
kubectl replace -f your-object-config.yaml
Advantages compared to imperative commands:
- Can be stored in a source control system such as Git.
- Can integrate with processes such as reviewing changes before push and audit trails.
- Provides a template for creating new objects.
Disadvantages compared to imperative commands:
- Requires basic understanding of the object schema.
- Requires the additional step of writing a YAML file.
Advantages compared to declarative object config:
- Simpler and easier to understand.
- More mature after Kubernetes version 1.5.
Disadvantages compared to declarative object configuration:
- Works best on files, not directories.
- Updates to live objects must be reflected in configuration files, or they will be lost during the next replacement.
These are declarative object config
kubectl diff -f configs/
kubectl apply -f configs/
Advantages compared to imperative object config:
- Changes made directly to live objects are retained, even if they are not merged back into the configuration files.
- Better support for operating on directories and automatically detecting operation types (create, patch, delete) per-object.
Disadvantages compared to imperative object configuration:
- Harder to debug and understand results when they are unexpected.
- Partial updates using diffs create complex merge and patch operations.