如何为helmfile中的变量赋值? [英] How do I assign value to variable in helmfile?

查看:43
本文介绍了如何为helmfile中的变量赋值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在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

这是没有问题的。我需要添加大量批注

推荐答案

通常,如果在helmfile.yaml中使用set参数,您可以这样指定它:

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

注意归根结底,Helm总是很棘手,因为没有关于如何使用values.yaml的通用规范--也就是说,结构可以是任意的。我假设它是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

这篇关于如何为helmfile中的变量赋值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆