I have several deployments that consist on my application. I would like to perform an custom action on the end of successful deployment of my app, this equal all deployments went well. How can I determine all my kubernetes deployments finished successfully?
Maybe with a basic watch
command on all deployments ?
watch kubectl get deployments
And check the READY column.
Or am I missing the point here ?
It's not exactly clear what do You mean.
As pointed by @Marc ABOUCHACRA, you can use watch
. This can be done in more k8s way by using -w
flag like so kubectl get deployments -w
.
But this only provides the information about the state Desired/Current/Up-to-date/Available.
$ kubectl get deployments
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
nginx-1 1 1 1 1 27h
You might Define Readiness probe.
Sometimes, applications are temporarily unable to serve traffic. For example, an application might need to load large data or configuration files during startup, or depend on external services after startup. In such cases, you don’t want to kill the application, but you don’t want to send it requests either. Kubernetes provides readiness probes to detect and mitigate these situations. A pod with containers reporting that they are not ready does not receive traffic through Kubernetes Services.
Note: Readiness probes runs on the container during its whole lifecycle.
readinessProbe:
exec:
command:
- cat
- /tmp/healthy
initialDelaySeconds: 5
periodSeconds: 5
Or just use Deployment status,
A Deployment enters various states during its lifecycle. It can be progressing while rolling out a new ReplicaSet, it can be complete, or it can fail to progress.
$ kubectl rollout status deployment nginx-1
deployment "nginx-1" successfully rolled out