![](/img/trans.png)
[英]Kubernetes ConfigMap YAML into Terraform Kubernetes
[英]Yaml with kubernetes
我正在做一些练习并试图围绕如何编写 yaml 构建。
spec:
containers:
- image: nginx
imagePullPolicy: IfNotPresent
name: nginx
resources: {}
envFrom:
- configMapRef:
name: anotherone # the name of the config map
dnsPolicy: ClusterFirst
restartPolicy: Never
status: {}
VS
containers:
- image: nginx
imagePullPolicy: IfNotPresent
name: nginx
resources: {}
env:
- name: option # name of the env variable
valueFrom:
configMapKeyRef:
name: options # name of config map
key: var5 # name of the entity in config map
所以我的问题是:当我在 kubernetes 中构建时,我什么时候使用“-”符号? 我确实明白,如果我在字符串之前应用“-”,它会使其成为列表中的 object,但我不明白何时需要在 kubernetes 的构建中使用列表。
“-”符号是因为字段类型是对象数组,如果字段类型是字符串,则值在“:”符号之后。 当字段为 object 时,没有“-”,但该 object 的键列表就像您在valueFrom
中看到的那样。 当您运行kubectl explain
命令时,您将看到字段的 sepcification,例如:
kubectl explain pod
kubectl explain pod.spec.containers
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.