Yaml与Kubernetes

我正在做一些练习,试图把我的头缠在如何编写yaml build上。

    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中进行构建时,何时使用'-'符号? 我确实知道,如果我在字符串之前加上“-”,它将使它成为列表内的对象,但是我不明白何时需要在kubernetes的内部版本中使用列表。

ning419 回答:Yaml与Kubernetes

“-”符号是因为字段的类型是对象的数组,如果字段的类型是字符串,则值在“:”符号后。当field是object时,没有“-”,而是该对象的键列表,例如在valueFrom中看到的那样。运行kubectl explain命令时,您将看到字段的分隔,例如:

 kubectl explain pod
 kubectl explain pod.spec.containers
本文链接:https://www.f2er.com/3129296.html

大家都在问