Helm install, Kubernetes - how to wait for the pods to be ready?

烈酒焚心 提交于 2021-02-16 06:33:05

问题


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".

  1. It feels a bit wrong thing to do... Everyone solves this so I assume there is some feature of kubectl for that, is there?

  2. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!