问题
I am creating a CI/CD pipeline.
I run helm install --wait --timeout 300 ...
. But that doesn't really wait, just returns when the "release" status is DEPLOYED
.
So then I see a few things in kubectl get pods --namespace default -l 'release=${TAG}' -o yaml
that could be used:
- kind: Pod
status:
conditions:
- lastProbeTime: null
lastTransitionTime: 2018-05-11T00:30:46Z
status: "True"
type: Initialized
- lastProbeTime: null
lastTransitionTime: 2018-05-11T00:30:48Z
status: "True"
type: Ready
So I guess I will look at when Ready
condition becomes "True".
It feels a bit wrong thing to do... Everyone solves this so I assume there is some feature of
kubectl
for that, is there?Is this the right thing to query? (See Kubernetes JSONPath reference)
kubectl get pods --namespace default -l 'release=sc8757070' -o jsonpath='{.items[*].status.conditions[?(@.type=="Ready")].status}'
回答1:
You could use kubectl rollout status
$ kubectl rollout status -h
Show the status of the rollout.
By default 'rollout status' will watch the status of the latest rollout until
it's done...
回答2:
There is a good option -n | --namespace NAMESPACE
that allow to wait deployments in different namespaces, for example in kube-system
:
kubectl rollout status deployment tiller-deploy -n kube-system
来源:https://stackoverflow.com/questions/50283456/helm-install-kubernetes-how-to-wait-for-the-pods-to-be-ready