Kubernetes desired state can be updated/mutated thru two paradigms :
- Either imperatively using kubectl adhoc commands (
k set
, k create
, k run
, k rollout
,..)
- Or declaratively using YAML manifests with a single
k apply
The declarative way is ideal for treating your k8s manifests as Code, then you can share this Code with the team, version it thru Git for example, and keep tracking its history leveraging GitOps practices ( branching models, Code Review, CI/CD ).
However, the imperative way cannot be reviewed by the team as these adhoc-commands will be run by an individual and no one else can easily find out the cause of the change after the change has been made.
To overcome the absence of an audit trail with imperative commands, the --record
option is there to bind the root cause of the change as annotation called kubernetes.io/change-cause
and the value of this annotation is the imperative command itself.
(note below is from the official doc)
Note: You can specify the --record flag to write the command executed in the resource annotation kubernetes.io/change-cause. The recorded change is useful for future introspection. For example, to see the commands executed in each Deployment revision.
As conclusion :
- Theoretically ,
--record
is not mandatory
- Practically, it's mandatory in order to ensure the changes leave a rudimentary audit trail behind and comply with SRE process and DevOps culture.