Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/kubernetes/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Azure 检查Kubernetes在CI/CD管道中的部署是否成功_Azure_Kubernetes_Deployment_Continuous Integration_Azure Aks - Fatal编程技术网

Azure 检查Kubernetes在CI/CD管道中的部署是否成功

Azure 检查Kubernetes在CI/CD管道中的部署是否成功,azure,kubernetes,deployment,continuous-integration,azure-aks,Azure,Kubernetes,Deployment,Continuous Integration,Azure Aks,我有一个带有Kubernetes版本1.14.7的AKS集群 我已经构建了CI/CD管道来将新创建的映像部署到集群 $ ./kubediff Usage: kubediff [options] <dir/file>... Compare yaml files in <dir> to running state in kubernetes and print the differences. This is useful to ensure you have appli

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

我已经构建了CI/CD管道来将新创建的映像部署到集群

$ ./kubediff
Usage: kubediff [options] <dir/file>...

Compare yaml files in <dir> to running state in kubernetes and print the
differences.  This is useful to ensure you have applied all your changes to the
appropriate environment.  This tools runs kubectl, so unless your
~/.kube/config is configured for the correct environment, you will need to
supply the kubeconfig for the appropriate environment.
我正在使用kubectl apply使用新映像更新特定部署。有时,由于许多原因,部署失败,例如ImagePullBackOff


在kubectl apply命令之后是否有命令运行,以检查pod的创建和部署是否成功

您可以通过jq解析输出:

kubectl get pod -o=json | jq '.items[]|select(any( .status.containerStatuses[]; .state.waiting.reason=="ImagePullBackOff"))|.metadata.name'

为此,Kubernetes有
kubectl卷展栏
,您应该使用选项
状态

默认情况下,“卷展栏状态”将查看最新卷展栏的状态,直到完成。如果不想等待卷展栏完成,则可以使用--watch=false。请注意,如果新卷展栏在这两者之间开始,则“卷展栏状态”将继续查看最新版本。如果要固定到某个特定版本,并在该版本被另一个版本覆盖时中止,请使用--revision=N,其中N是需要注意的版本

你可以阅读完整的描述

如果使用
kubect apply-f myapp.yaml
并选中
卷展栏状态
,您将看到:

$ 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
看起来该工具非常适合您的任务:

Kubediff是Kubernetes的一个工具,用于向您展示运行配置和版本控制配置之间的差异

该工具可以从命令行使用,也可以作为集群中的一个Pod,用于连续比较已配置存储库中的YAML文件与集群的当前状态

$ ./kubediff
Usage: kubediff [options] <dir/file>...

Compare yaml files in <dir> to running state in kubernetes and print the
differences.  This is useful to ensure you have applied all your changes to the
appropriate environment.  This tools runs kubectl, so unless your
~/.kube/config is configured for the correct environment, you will need to
supply the kubeconfig for the appropriate environment.
$。/kubediff
用法:kubediff[选项]。。。
将中的yaml文件与kubernetes中的运行状态进行比较,并打印
差异。这对于确保已将所有更改应用于
适当的环境。此工具运行kubectl,因此除非
~/.kube/config是为正确的环境配置的,您需要
为适当的环境提供kubeconfig。
kubediff
发现差异时,将状态返回到
stdout
和非零退出代码。可以使用命令行参数更改此行为

您可能还想查看关于验证YAML文件的好文章:


还有另一种方法可以通过配置的超时等待部署可用,如

kubectl wait--for=condition=available--timeout=60s deploy/myapp


否则可以使用
kubectl卷展状态
,但在某些罕见的情况下,它可能会永远卡住,如果发生这种情况,则需要手动取消管道。

运行命令后检查事件部分:kubectl-n[您的命名空间]description pod[您的pod name]然后检查图像回调的原因,在我看来,首先尝试解决您遇到的问题。