前提条件
1, 安装helm
2,要能连接的k8s
3,本地有完成charts文件目录
具体步骤
本文因为是在项目流程中helm渲染出的deployment语法报错或者最终生成的不符合预期,因此本地使用helm命令进行debug验证测试。
我们先看一下基本的charts目录结构

在本地调试,所有命令都添加了 --debug --dry-run 这两个参数
-dry-run simulate an install
1, --set 设置value
在使用helm命令渲染的时候,默认是读取了values.yaml
如果我们需要覆盖values.yaml中定义的值,可以在helm的参数中指定–set image.tag=v1.1
官方文档的解释:
–set stringArray set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)
helm upgrade --namespace mytest --install --debug --dry-run goodly-guppy ./template-charts --set image.imageName=abc --set image.tag=v1.1
2, --values 指定新的values文件
可以指定新的values文件,文件名称不一定使用values.yaml
–values ./template-charts/custom.values.yaml
–values strings specify values in a YAML file or a URL (can specify multiple)
–values (or -f): Specify a YAML file with overrides. This can be specified multiple times and the rightmost file will take precedence
可以指定多个values文件, 最右边的优先级高
ou can specify the ‘–values’/‘-f’ flag multiple times. The priority will be given to the last (right-most) file specified. For example, if both myvalues.yaml and override.yaml contained a key called ‘Test’, the value set in override.yaml would take precedence:
$ helm install -f myvalues.yaml -f override.yaml myredis ./redis
https://helm.sh/docs/helm/helm_install/#synopsis

helm upgrade --namespace mytest --install --debug --dry-run goodly-guppy ./template-charts --set image.imageName=abc --set image.tag=v1.1 --values ./template-charts/custom.values.yaml


本文介绍了如何在本地使用Helm命令行工具进行调试,确保在Kubernetes集群中部署charts时避免错误。主要步骤包括:1) 安装并连接到K8s;2) 检查charts目录结构;3) 使用`--set`参数覆盖`values.yaml`中的值;4) 通过`--values`指定自定义的values文件。在调试过程中,添加`--debug`和`--dry-run`选项来模拟安装并查看结果。此外,还解释了如何通过多个values文件覆盖值,以及文件覆盖的优先级。
1528

被折叠的 条评论
为什么被折叠?



