<p>I'm trying to use kubectl patch to add an extra annotation to my k8s nginx ingress.</p>

<p>Here's the ingress that I start with:</p>

<pre><code>apiVersion: v1
items:
- apiVersion: extensions/v1beta1
  kind: Ingress
  metadata:
    annotations:
      field.cattle.io/publicEndpoints: '[{"stuff:false}]'
      kubernetes.io/ingress.class: nginx-external
    creationTimestamp: "2019-02-25T20:38:29Z"
    generation: 1
</code></pre>

<p>Here is my patch file that I'm applying <code>ingress_annotation.yaml</code>.</p>

<pre><code>metadata:
  annotations:
    nginx.ingress.kubernetes.io/configuration-snippet: |
      proxy_set_header l5d-dst-override $service_name.$namespace.svc.cluster.local:80;
      proxy_hide_header l5d-remote-ip;
      proxy_hide_header l5d-server-id;
</code></pre>

<p>I apply this patch by running <code>kubectl patch ingress kibana --patch "$(cat ingress_annotation.yaml)"</code>.</p>

<p>When I apply this it does add the annotation to the ingress looks like this when I run <code>kubectl get ingress &lt;my_ingress&gt; -o yaml</code>:</p>

<pre><code>apiVersion: v1
items:
- apiVersion: extensions/v1beta1
  kind: Ingress
  metadata:
    annotations:
      field.cattle.io/publicEndpoints: '[{"Stuff:false}]'
      kubernetes.io/ingress.class: nginx-external
      nginx.ingress.kubernetes.io/configuration-snippet: |-
        proxy_set_header l5d-dst-override $service_name.$namespace.svc.cluster.local:80;
        proxy_hide_header l5d-remote-ip;
        proxy_hide_header l5d-server-id;
    creationTimestamp: "2019-02-25T20:38:29Z"
    generation: 1
</code></pre>

<p>Note the extra <code>"-"</code> character after <code>nginx.ingress.kubernetes.io/configuration-snippet: |</code>. I'm not sure where this character is coming from or what it's doing here. Can anyone shine some light on this for me, or how I can prevent this character from being added to my annotation?</p>

dredbound
<p>This is <a href="https://lzone.de/cheat-sheet/YAML" rel="nofollow noreferrer">YAML syntax</a> that is probably added automatically by kubectl:</p>

<blockquote>
  <p><strong>- indicator: remove extra newlines after block</strong></p>
</blockquote>

<pre><code>content: |-
   Arbitrary free text without newlines after it
</code></pre>
