0
0
Kubernetesdevops~5 mins

Deployment status and history in Kubernetes - Commands & Configuration

Choose your learning style9 modes available
Introduction
When you update your app in Kubernetes, you want to see if the new version is running well and check past updates. Deployment status and history help you track these changes and fix problems quickly.
When you want to confirm that your app update was successful and is running without errors.
When you need to see what changes were made in previous app versions to understand issues.
When you want to roll back to a previous version after a bad update.
When you want to monitor how many times your app has been updated and when.
When you want to check if Kubernetes is still updating your app or if it finished.
Commands
This command shows the current status of the deployment named 'my-app'. It tells you if the update is complete or still in progress.
Terminal
kubectl rollout status deployment/my-app
Expected OutputExpected
deployment "my-app" successfully rolled out
This command lists the history of all updates made to the 'my-app' deployment, showing revision numbers and change causes if available.
Terminal
kubectl rollout history deployment/my-app
Expected OutputExpected
deployment.apps/my-app REVISION CHANGE-CAUSE 1 Initial deployment 2 Updated image to v2
This command shows details of the first revision of the 'my-app' deployment, helping you see what was changed in that update.
Terminal
kubectl rollout history deployment/my-app --revision=1
Expected OutputExpected
deployment.apps/my-app with revision #1 Pod Template: Containers: my-app: Image: my-app-image:v1 Ports: - 80/TCP
--revision - Shows details for a specific revision number
This command rolls back the 'my-app' deployment to the previous working version if the current update has problems.
Terminal
kubectl rollout undo deployment/my-app
Expected OutputExpected
deployment.apps/my-app rolled back
This command shows the current state of the 'my-app' deployment including how many pods are ready and available.
Terminal
kubectl get deployment my-app
Expected OutputExpected
NAME READY UP-TO-DATE AVAILABLE AGE my-app 3/3 3 3 10m
Key Concept

If you remember nothing else from this pattern, remember: use 'kubectl rollout status' to check if your app update finished successfully and 'kubectl rollout history' to see past changes.

Common Mistakes
Running 'kubectl get pods' only to check deployment status
This shows pod states but not if the deployment update is complete or rolled out correctly.
Use 'kubectl rollout status deployment/my-app' to get accurate deployment update status.
Not specifying the deployment name correctly in commands
Commands fail or show no results if the deployment name is wrong or missing.
Always use the exact deployment name, for example 'my-app', in rollout commands.
Trying to view rollout history without any revisions
If the deployment has never been updated, history will be empty or show only initial deployment.
Make sure the deployment has at least one update before checking history.
Summary
Use 'kubectl rollout status deployment/my-app' to check if your deployment update finished successfully.
Use 'kubectl rollout history deployment/my-app' to see all past updates and their revision numbers.
Use 'kubectl rollout undo deployment/my-app' to roll back to the previous working version if needed.