如何在helmfile中为变量赋值?

时间:2018-04-16 11:34:48

标签: kubernetes kubernetes-helm kubernetes-ingress 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

这没有问题。我需要添加许多注释

1 个答案:

答案 0 :(得分:0)

通常,如果在s = df['Chrom'] + '-' + df['Loc'].astype(str) + '-' + df['WT'] + '-' + df['Var'] df1 = df.set_index(s).rename_axis('ID')[['VAF']] print (df1) VAF ID chr1-115227855-T-C 0.002662 chr1-115227856-C-T 0.001545 chr1-115227857-C-T 0.001236 chr1-115227858-A-T 0.001793 chr1-115227880-C-T 0.001115 中使用set参数,则可以这样指定:

helmfile.yaml

注意,反斜杠用于转义键set: - name: 'controller.service.annotations.service\.beta\.kubernetes\.io/aws-load-balancer-ssl-ports' value: 'https' 中的点。 YAML选择器中的点具有特殊含义,因此我们需要对其进行转义。

但是,由于这非常不直观,因此我建议使用内联值。然后看起来像这样:

service.beta.kubernetes.io/aws-load-balancer-ssl-ports

注意最后,掌舵总是很棘手,因为对于如何使用values: - rbac: create: true controller: service: annotations: "service.beta.kubernetes.io/aws-load-balancer-ssl-ports": true 没有统一的规范-也就是说,结构可以是任意的。我假设它是values.yaml,因为我们使用的大多数图表都将map定义为一个简单的地图(而不是列表)。

在此示例中,我们为annotations定义了注释

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