如何解决在HELM中使用--set传递值时,由于“无”对象而导致验证错误
我正在尝试使用--set
中的helm3
传递值。但是,看起来yaml文件没有提取/解析值。
我的文件夹结构如下:(还有一些其他图表,但为简单起见,我将其删除)
k8shelmcharts
├── Chart.yaml
└── charts
├── postgresdb
│ ├── Chart.yaml
│ ├── templates
│ │ ├── postgres.configmap.yml
│ │ ├── postgres.deployment.yml
│ │ ├── postgres.secrets.yml
│ │ └── postgres.service.yml
│ └── values.yaml
,postgres.secrest.yml
文件的内容为:
apiVersion: v1
kind: Secret
metadata:
name: postgres-secret
type: Opaque
data:
# property-like keys; each key maps to a simple value
password: {{ .Values.password }}
(我也尝试过.Values.global.password
)
当我尝试通过运行命令(从舵机图表的根目录,即k8shelmcharts
文件夹)来安装图表时,helm install testapp . --set password=postgrespasssword --debug --dry-run
我得到了错误:
Error: unable to build kubernetes objects from release manifest: error validating "": error validating data: unknown object type "nil" in Secret.data.password
helm.go:94: [debug] error validating "": error validating data: unknown object type "nil" in Secret.data.password
如果我尝试使用helm template testflaskapp . --set password=postgrespassword --debug --dry-run
生成模板,则可以看到postgres.secret.yml
文件中似乎没有填充密码-
# Source: flask-k8s-app/charts/postgresdb/templates/postgres.secret.yml
apiVersion: v1
kind: Secret
metadata:
name: postgres-secret
data:
# property-like keys; each key maps to a simple value
password:
对我所缺少的内容有任何帮助,这样我就可以--set
值并将其成功拉入yaml文件了吗?谢谢!
解决方法
选项1:
helm install testapp . --set postgresdb.password=postgrespasssword --debug --dry-run
该变量应称为postgresdb.password
,在postgres.secrets.yml中应保持{{ .Values.password }}
。
选项2
helm install testapp . --set global.password=postgrespasssword --debug --dry-run
该变量应称为global.password
,postgres.secrets.yml应该更改为{{ .Values.global.password }}
。
第一个选项是我猜想的首选,因为您可能仅在postgresdb
子图中使用了后退密码。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。