Reputation: 7838
I was doing a practice exam on the website killer.sh , and ran into a question I feel I did a hacky solution to. Given a deployment that has had a bad rollout, revert to the last revision that didn't have any issues. If I check a deployment's rollout history, for example with the command:
kubectl rollout history deployment mydep
I get a small table with version numbers, and "change-cause" commands. Is there any way to check the changes made to the deployment's yaml file for a specific revision? Because I was stumped in figuring out which specific revision didn't have the error inside of it.
Upvotes: 1
Views: 2861
Reputation: 4571
You can also get some additional details by passing the --revision
flag:
kubectl rollout history deployment mydep --revision=26
Or even diff
two such revisions in bash
:
diff <(kubectl rollout history deployment mydep --revision=26) \
<(kubectl rollout history deployment mydep --revision=25)
Upvotes: 2
Reputation: 1301
You can record the last executed command that changed the deployment with --record option. When using --record you would see the last executed command executed(change-cause) to the deployment metadata.annotations. You will not see this in your local yaml file but when you try to export the deployment as yaml then you will notice the change.
--record option like below
kubectl create deployment <deployment name> --image=<someimage> > testdelpoyment.yaml
kubectl create -f testdeployment.yaml --record
or
kubectl set image deployment/<deploymentname> imagename=newimagename:newversion --record
Upvotes: 1
Reputation: 44637
Kubernetes does not store more than what is necessary for it to operate and most of the time that is just the desired state because kubernetes is not a version control system.
This is preciously why you need to have a version control system coupled with tools like helm or kustomize where you store the deployment yamls and apply them to the cluster with a new version of the software. This helps in going back in history to dig out details when things break.
Upvotes: 2
Reputation: 691
Behind the scenes a Deployment
creates a ReplicaSet
that has its metadata.generation
set to the REVISION
you see in kubectl rollout history deployment mydep
, so you can look at and diff old ReplicaSet
s associated with the Deployment
.
On the other hand, being an eventually-consistent system, kubernetes has no notion of "good" or "bad" state, so it can't know what was the last successful deployment, for example; that's why deployment tools like helm
, kapp
etc. exist.
Upvotes: 3