0

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

这没有问题。我将需要添加大量注释

4

1 回答 1

1

通常,如果使用 in 中的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

注意最后,使用 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

于 2018-08-10T17:47:41.463 回答