<p>How do I assign a variable within a <strong>helmfile</strong>?</p>

<pre><code>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'
</code></pre>

<h3>Error message</h3>

<pre><code> 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
</code></pre>

<p>If I use a pure <strong>helm</strong> installation that works with no problem:</p>

<pre><code>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
</code></pre>

<p>That works with no problem. I will need to add numerous <strong>annotations</strong>.</p>

<p>Typically, if using the <code>set</code> parameter in <code>helmfile.yaml</code>, you would specify it this way:</p>

<pre><code>set:
  - name: 'controller.service.annotations.service\.beta\.kubernetes\.io/aws-load-balancer-ssl-ports'
    value: 'https'
</code></pre>

<p><strong>NOTE</strong> the backslashes are used to escape the dots in the key <code>service.beta.kubernetes.io/aws-load-balancer-ssl-ports</code>. Dots in YAML selectors have a special meaning, so we need to escape them.</p>

<p>However, since that's very unintuitive, I recommend using inline values. Then it looks something like this:</p>

<pre><code>values:
  - rbac:
      create: true
    controller:
      service:
        annotations:
          "service.beta.kubernetes.io/aws-load-balancer-ssl-ports": true
</code></pre>

<p><strong>NOTE</strong> In the end, it's always tricky with helm since there's no universal specification for how to consume <code>values.yaml</code> - that is, the structure can be arbitrary. I am assuming that it's a <code>map</code>, since most charts we use define <code>annotations</code> as a simple map (as opposed to a list).</p>

<p>Here's an example where we define an annotation for <code>replica.annotations.iam\.amazonaws\.com/role</code></p>

<p><a href="https://github.com/cloudposse/geodesic/blob/0.12.0/rootfs/conf/kops/helmfile.yaml#L104-L105" rel="nofollow noreferrer">https://github.com/cloudposse/geodesic/blob/0.12.0/rootfs/conf/kops/helmfile.yaml#L104-L105</a></p>

<p>And here's how we do it for inline values: (we switched to using this everywhere)
<a href="https://github.com/cloudposse/helmfiles/blob/0.2.4/helmfile.d/0300.chartmuseum.yaml#L52-L55" rel="nofollow noreferrer">https://github.com/cloudposse/helmfiles/blob/0.2.4/helmfile.d/0300.chartmuseum.yaml#L52-L55</a></p>
