I tried to find useful information when should i use --record
. I created 3 commands:
k set image deployment web1 nginx=lfccncf/nginx:latest --record
k rollout undo deployment/web1 --record
k -n kdpd00202 edit deployment web1 --record
Could anyone tell me if I need to use --record
in each of these 3 commands?
When is it necessary to use --record
and when is it useless?
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.
Imperative commands are used to create, update and delete objects on Kubernetes clusters without having to specify any manifest files beforehand. They are a godsend for Kubernetes application developers and administrators because they are very easy to remember and let you get things done more efficiently!
A Kubernetes object is a "record of intent"--once you create the object, the Kubernetes system will constantly work to ensure that object exists. By creating an object, you're effectively telling the Kubernetes system what you want your cluster's workload to look like; this is your cluster's desired state.
It is one of the key components of Kubernetes which runs on the workstation on any machine when the setup is done. It has the capability to manage the nodes in the cluster. Kubectl commands are used to interact and manage Kubernetes objects and the cluster. In this chapter, we will discuss a few commands used in Kubernetes via kubectl.
This is a method commonly used in CICD pipelines where YAMLs usually present. Imperative commands are used to create, update and delete objects on Kubernetes clusters without having to specify any manifest files beforehand.
Kubectl stands for “Kubernetes Command-line interface”. It is a command-line tool for the Kubernetes platform to perform API calls. Kubectl is the main interface that allows users to create (and manage) individual objects or groups of objects inside a Kubernetes cluster. As a user, Kubectl helps you to control Kubernetes as a cockpit.
kubectl rollout − It is capable of managing the rollout of deployment. kubectl run − Run command has the capability to run an image on the Kubernetes cluster. kubectl scale − It will scale the size of Kubernetes Deployments, ReplicaSet, Replication Controller, or job.
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.
kubectl rollout history deployment.v1.apps/nginx-deployment
The output is similar to this:
deployments "nginx-deployment"
REVISION CHANGE-CAUSE
1 kubectl apply --filename=https://k8s.io/examples/controllers/nginx-deployment.yaml --record=true
2 kubectl set image deployment.v1.apps/nginx-deployment nginx=nginx:1.16.1 --record=true
3 kubectl set image deployment.v1.apps/nginx-deployment nginx=nginx:1.161 --record=true
So it's not mandatory for any of the commands and but is recommended for kubectl set image
because you will not see anything in CHANGE-CAUSE
section as above if you skip --record
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With