when I run kubectl get deploy/my-deploy -o yaml > my-deployment.yaml
and modify only the container image tag, and run kubectl apply
with the fixed file, is there a command that I can check whether the configured deployment is ready or not?
When I create a new deployment by changing both the image tag AND the deployment name, I check the new deployment’s readiness by checking the .status.conditions[]
and selecting the reason MinimumReplicasAvailable
. However this is not possible in the case above because the MinimumReplicasAvailable already meets (As the original one before modifying the image tag is already alive).
Any helps or suggestions ?
If I understood the issue correctly, this command will do your job.
kubectl rollout status deployment/my-deploy
It will output you with the current deployment rollout status.
Waiting for rollout to finish: 2 out of 3 new replicas have been updated...
or
deployment "my-deploy" successfully rolled out
Reference: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/
The field that indicates how many pods are updated is the status.updatedReplicas
.
According to the documentation, this is the meaning of that field:
Total number of non-terminated pods targeted by this deployment that have the desired template spec.
This means you should be able to tell when a Deployment rollout is complete by comparing spec.Replicas
with status.updatedReplicas
. When they match the rollout is complete.