helm 部署园子的一个应用时出现下面的错误:
Error: UPGRADE FAILED: failed to create resource: Deployment in version "v1" cannot be handled as a Deployment: json: cannot unmarshal number into Go struct field ObjectMeta.spec.template.metadata.labels of type string
所使用的 helm chart 是一个通用的应用部署模版,已经部署过很多应用,最近也没有过变更
是下面的 version
值引起的,之前版本号用的都是3位数字,比如 2.2.1
,默认会解析为字符串,不会报错。这次用的是 2.3
,被解析为数字,而 k8s 的 labels 不允许使用数字,所以报错。
spec:
template:
metadata:
labels:
version: {{ .Values.imageVersion }}
加上引号即可解决
version: "{{ .Values.imageVersion }}"