Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check k8s deploy history?

I tried kubectl rollout history deployment/my-app, it returns only No rollout history found.

I think there exists a method to get all the deploy histories. It will be very helpful.

Reference official document: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/

like image 765
zseikyocho Avatar asked Aug 29 '18 10:08

zseikyocho


People also ask

How do I check my command history in Kubernetes?

One can use -o option to change output format. Examples: # View the last-applied-configuration annotations by type/name in YAML. kubectl apply view-last-applied deployment/nginx # View the last-applied-configuration annotations by file in JSON kubectl apply view-last-applied -f deploy.

How do I record Kubernetes deployment?

Creating a Deployment Setting the kubectl flag --record to true allows you to record current command in the annotations of the resources being created or updated. It will be useful for future introspection; for example, to see the commands executed in each Deployment revision.

How do I rollback to previous deployment in Kubernetes?

After the kubectl apply command you can check if the deployment rolled out successfully or not and then, if necessary, the kubectl rollout undo command can rollback to the previous revision. Also, you can use the sleep Linux command to wait some time before that.

How do I check pod logs?

When kubectl describe pod does not show any information about an error, we can use another kubectl command, that is, logs . The kubectl logs command allows us to print container logs, and we can also view them in real time as well.


1 Answers

Use --record while creating the deployment so that it will start recroding the deployment into the ReplicaSet.

$ kubectl create -f deploy.yaml --record=true

Whenever you deploy new version of deployment, the replica set preserves the previous configuration of the deployment. Check the track of deployment and even we can use this for automation. This should be the default option in the kuberentes deployment, but, by default it's set to false.

Then check the status and history using the below commands,

$ kubectl rollout status deploy myapp-deployment
$ kubectl rollout history deploy myapp-deployment

Hope this helps.

like image 116
mohan08p Avatar answered Sep 23 '22 00:09

mohan08p