【问题标题】:Generating yaml output using kubectl result in splits line使用 kubectl 生成 yaml 输出会导致拆分行
【发布时间】:2021-05-05 20:17:39
【问题描述】:

我正在尝试使用 kubectl --dry-run 生成 yaml 输出。

当我运行它时

$ 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" . }}'

我得到以下输出,其中注释被分成 2 行。

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

我想要的输出是注释应该在一行中。如下所示

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

如果我减小字符串的大小,则它变为 1 行。我在文档中的任何地方都找不到有关行长的任何信息。谁能指导我如何解决这个问题?

【问题讨论】:

    标签: kubernetes yaml output kubectl configmap


    【解决方案1】:

    我认为您找不到任何东西,因为这是一个完全有效的 yaml。所以我想你可以直接使用它,而无需将大括号放在同一行。

    【讨论】:

    • 是的,它看起来是有效的 yaml。但是helm不喜欢这样,它抱怨“模板子句中出现意外未关闭的动作”的分割线。如果我将其更改为一行,则它可以工作。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-02-26
    • 2020-12-09
    • 1970-01-01
    • 1970-01-01
    • 2020-09-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多