我们可以使用“数据"吗?作为yaml文件而不是Config映射中的Json文件 [英] Can we use "data" as a yaml file instead of Json file in Config map

查看:134
本文介绍了我们可以使用“数据"吗?作为yaml文件而不是Config映射中的Json文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我们以配置映射为例

apiVersion: v1
kind: ConfigMap
data:
  abc.yml: |-
<yml here>

遇到无法将Yaml解析为Json之类的错误.

Getting an error like failed to parse yaml to Json.

推荐答案

可以,但是您应该注意语法.您还可以从这里.

Yes you can do that, but you should care about the syntax. You can also follow techniques for yaml from here.

如果使用kubectl create configmap myconfig --from-file=abc.yml,则可以.

但是,如果您在myconfig.yaml中为configmap写入整个yaml文件,然后运行kubectl create -f myconfig.yaml,则应该注意语法.

But if you write the whole yaml file for your configmap in myconfig.yaml and then run kubectl create -f myconfig.yaml, then you should care about syntax.

说您的abc.yml文件如下:

a:
  b: b1
  c: c1
d: d1

然后编写您的myconfig.yaml文件:

apiVersion: v1
kind: ConfigMap
data:
  abc.yml: |
    a:
      b: b1
      c: c1
    d: d1

现在只需运行kubectl create -f myconfig.yaml. 就是这样.

Now just run kubectl create -f myconfig.yaml. That's it.

快乐Kubernetes !!

Happy Kubernetes!!!.

这篇关于我们可以使用“数据"吗?作为yaml文件而不是Config映射中的Json文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆