Generating yaml output using kubectl result in splits line

2/1/2021

I am trying to generate yaml output with kubectl --dry-run.

When I run this

$ kubectl create configmap my-config-map  -o yaml --dry-run=client | kubectl annotate -f- --dry-run=client -o yaml --local this-is-my-target-directory='{{ template "This.is.long.path.for.some.value" . }}'

I get the following output where annotations are splitting into 2 lines.

apiVersion: v1
kind: ConfigMap
metadata:
  annotations:
    this-is-my-target-directory: '{{ template "This.is.long.path.for.some.value" .
      }}'
  creationTimestamp: null
  name: my-config-map

my desired output is that annotations should be in one line. like below

apiVersion: v1
kind: ConfigMap
metadata:
  annotations:
    this-is-my-target-directory: '{{ template "This.is.long.path.for.some.value" . }}'
  creationTimestamp: null
  name: my-config-map

If I reduce the size of the string then it becomes 1 line. I could not find anywhere in the documentation anything about line length. Can anyone guide me on how to fix this?

-- Noman Latif
configmap
kubectl
kubernetes
output
yaml

1 Answer

2/1/2021

I think you can't find anything because this is a totally valid yaml. So I guess you can use it as it's without the need to put the curly brackets at the same line.

-- 0xMH
Source: StackOverflow