Kubectl 补丁添加额外的“-”字符

Kubectl patch adding extra "-" character

我正在尝试使用 kubectl 补丁为我的 k8s nginx ingress 添加额外的注释。

这是我开始的入口:

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

这是我正在应用的补丁文件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;

我通过 运行ning kubectl patch ingress kibana --patch "$(cat ingress_annotation.yaml)" 应用了这个补丁。

当我应用它时,它确实将注释添加到入口,当我 运行 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

注意 nginx.ingress.kubernetes.io/configuration-snippet: | 之后的额外 "-" 字符。我不确定这个角色来自哪里或在这里做什么。任何人都可以为我阐明这一点,或者我怎样才能防止这个字符被添加到我的注释中?

这是YAML syntax,可能是kubectl自动添加的:

- indicator: remove extra newlines after block

content: |-
   Arbitrary free text without newlines after it