I'm trying to use kubectl patch to add an extra annotation to my k8s nginx ingress.
Here's the ingress that I start with:
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
Here is my patch file that I'm applying ingress_annotation.yaml
.
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;
I apply this patch by running kubectl patch ingress kibana --patch "$(cat ingress_annotation.yaml)"
.
When I apply this it does add the annotation to the ingress looks like this when I run kubectl get ingress <my_ingress> -o yaml
:
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
Note the extra "-"
character after nginx.ingress.kubernetes.io/configuration-snippet: |
. 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?
This is YAML syntax that is probably added automatically by kubectl:
- indicator: remove extra newlines after block
content: |-
Arbitrary free text without newlines after it