如何在helmfile中分配变量
context: example.com # kube-context (--kube-context)
releases:
# Published chart example
- name: controller-pod-nginx # Name of this release
namespace: ingress-nginx # Target namespace
chart: stable/nginx-ingress # The chart being installed to create this release, referenced by `repository/chart` syntax
set: # Values (--set)
- name: rbac.create
value: true
- name: controller.service.annotations
value: 'service.beta.kubernetes.io/aws-load-balancer-ssl-ports:https'错误消息
helmfile -f deploy_cp_ns_ingress-nginx.yaml sync
exec: helm repo add roboll http://roboll.io/charts --kube-context example.com
"roboll" has been added to your repositories
exec: helm repo update --kube-context example.com
Hang tight while we grab the latest from your chart repositories...
...Skip local chart repository
...Successfully got an update from the "roboll" chart repository
...Successfully got an update from the "stable" chart repository
Update Complete. ⎈ Happy Helming!⎈
exec: helm upgrade --install controller-pod-nginx stable/nginx-ingress --namespace ingress-nginx --set rbac.create=true,controller.service.annotations=service.beta.kubernetes.io/aws-load-balancer-ssl-ports:https --kube-context example.com
Error: UPGRADE FAILED: YAML parse error on nginx-ingress/templates/controller-service.yaml: error unmarshaling JSON: json: cannot unmarshal string into Go struct field .annotations of type map[string]string
err: exit status 1如果我使用的是纯helm安装,它可以正常工作:
helm install stable/nginx-ingress --set rbac.create=true --set controller.service.annotations."service\.beta\.kubernetes\.io/aws-load-balancer-backend-protocol"=http --namespace=ingress-nginx这没什么问题。我需要添加许多注释。
发布于 2018-08-10 17:47:41
通常,如果在set中使用helmfile.yaml参数,您可以这样指定它:
set:
- name: 'controller.service.annotations.service\.beta\.kubernetes\.io/aws-load-balancer-ssl-ports'
value: 'https'注意反斜杠用于转义键service.beta.kubernetes.io/aws-load-balancer-ssl-ports中的点。在YAML选择器中的点有一个特殊的含义,所以我们需要避开它们。
但是,由于这是非常不直观的,我建议使用内联值。然后看起来是这样的:
values:
- rbac:
create: true
controller:
service:
annotations:
"service.beta.kubernetes.io/aws-load-balancer-ssl-ports": true注意到最后,由于没有关于如何使用values.yaml的通用规范--也就是说,结构可以是任意的,所以helm总是很棘手的。我假设它是一个map,因为我们使用的大多数图表都将annotations定义为一个简单的映射(与列表相反)。
下面是一个我们为replica.annotations.iam\.amazonaws\.com/role定义注释的示例
https://github.com/cloudposse/geodesic/blob/0.12.0/rootfs/conf/kops/helmfile.yaml#L104-L105
下面是我们如何实现内联值的方法:(我们转而在任何地方使用它) https://github.com/cloudposse/helmfiles/blob/0.2.4/helmfile.d/0300.chartmuseum.yaml#L52-L55
https://stackoverflow.com/questions/49856305
复制相似问题