gpt4 book ai didi

azure - 检查 CI/CD 管道中 Kubernetes 部署是否成功

转载 作者:行者123 更新时间:2023-12-02 16:40:43 29 4
gpt4 key购买 nike

我有一个 Kubernetes 版本为 1.14.7 的 AKS 集群。

我已经构建了 CI/CD 管道以将新创建​​的镜像部署到集群。

我正在使用 kubectl apply 使用新镜像更新特定部署。有时,由于多种原因,部署会失败,例如 ImagePullBackOff。

在 kubectl apply 命令之后是否需要运行命令来检查 Pod 创建和部署是否成功?

最佳答案

为此,Kubernetes 有 kubectl rollout,您应该使用选项 status

By default 'rollout status' will watch the status of the latest rollout until it's done. If you don't want to wait for the rollout to finish then you can use --watch=false. Note that if a new rollout starts in-between, then 'rollout status' will continue watching the latest revision. If you want to pin to a specific revision and abort if it is rolled over by another revision, use --revision=N where N is the revision you need to watch for.

您可以阅读完整说明here

如果您使用kubect apply -f myapp.yaml并检查rollout status,您将看到:

$ kubectl rollout status deployment myapp
Waiting for deployment "myapp" rollout to finish: 0 of 3 updated replicas are available…
Waiting for deployment "myapp" rollout to finish: 1 of 3 updated replicas are available…
Waiting for deployment "myapp" rollout to finish: 2 of 3 updated replicas are available…
deployment "myapp" successfully rolled out

关于azure - 检查 CI/CD 管道中 Kubernetes 部署是否成功,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61736888/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com