Azure DevOps + helm chart = ##[警告]捕获部署元数据失败,出现错误:类型错误:无法读取 null 的属性'kind'



我使用helm chart通过Azure Devops部署在AKS集群上。一切都很好,但我在部署步骤结束时看到了一个警告:

Starting: Deploy Helm chart to qa3 environment
==============================================================================
Task         : Package and deploy Helm charts
Description  : Deploy, configure, update a Kubernetes cluster in Azure Container Service by running helm commands
Version      : 0.201.0
Author       : Microsoft Corporation
Help         : https://aka.ms/azpipes-helm-tsg
==============================================================================
/usr/local/bin/helm upgrade --namespace qa3 --install --values /home/vsts/work/1/s/invitation/values.yaml --set deployment.image.tag=***,deployment.environment=qa3,cluster.name=dev,azure.region=westus2,azure.appInsightsKey=***,deployment.deployedBy='cd',application.publicJwtValidationCertPemBase64=***,application.endpointPath=invitational,application.sendGridTemplateId=***,application.twillioFromPhoneNumber=***,secret.AuthToken=***,secret.AccountSid=***,secret.SendGridApiKey=*** --wait --install --reuse-values q5id-app-invitation /home/vsts/work/1/s/invitation
Release "q5id-app-invitation" has been upgraded. Happy Helming!
NAME: q5id-app-invitation
LAST DEPLOYED: Wed Aug 10 14:53:19 2022
NAMESPACE: qa3
STATUS: deployed
REVISION: 3
TEST SUITE: None
/usr/local/bin/kubectl cluster-info
Kubernetes control plane is running at https://***:443
CoreDNS is running at https://***:443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
Metrics-server is running at https://***:443/api/v1/namespaces/kube-system/services/https:metrics-server:/proxy
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
##[warning]Capturing deployment metadata failed with error: TypeError: Cannot read property 'kind' of null
Finishing: Deploy Helm chart to qa3 environment

看起来模板已经成功部署,然后运行了kubectl cluster-info,然后又运行了其他内容。我不明白是什么原因导致了这个警告:

##[警告]捕获部署元数据失败,错误为:TypeError:无法读取null 的属性"kind">

我该怎么修?

我似乎也遇到了同样的问题。问题是您的一个helm模板加载不正确。假设你的模板是有条件的,在条件之前有一个注释

# enables PodDisruptionBudget
{{- if .Values.pdb }}{{ if .Values.pdb.enabled }}
apiVersion: policy/v1
kind: PodDisruptionBudget
...
{{- end }}{{ end }}

在某些情况下,当iftrue时,它将在没有警告的情况下工作。然而,如果它是一个false,你的模板是有点";"空";Azure应该跳过它。不幸的是,它不能,因为Azure在管道日志中打印了一条注释。由于没有跳过该模板,Azure搜索该模板的kind,但什么都没有,所以这就是出现警告的原因。要解决此问题,需要将注释移动到条件内部。

相关内容

最新更新