Yaml Kubernetes:验证数据时出错:发现v1.PodSpec的无效字段env;
我使用下面的yaml文件创建pod,kubectl命令给出以下错误 如何更正此错误消息Yaml Kubernetes:验证数据时出错:发现v1.PodSpec的无效字段env;,yaml,kubernetes,Yaml,Kubernetes,我使用下面的yaml文件创建pod,kubectl命令给出以下错误 如何更正此错误消息 apiVersion: v1 kind: Pod metadata: name: command-demo labels: purpose: demonstrate-command spec: containers: - name: command-demo-container image: debian command: ["printenv"] args:
apiVersion: v1
kind: Pod
metadata:
name: command-demo
labels:
purpose: demonstrate-command
spec:
containers:
- name: command-demo-container
image: debian
command: ["printenv"]
args: ["HOSTNAME", "KUBERNETES_PORT"]
env:
- name: MESSAGE
value: "hello world"
command: ["/bin/echo"]
args: ["$(MESSAGE)"]
kubectl create -f commands.yaml
error: error validating "commands.yaml": error validating data: found invalid field env for v1.PodSpec; if you choose to ignore these errors, turn validation off with --validate=false
请遵循本页中的示例
谢谢
-SR语法正确的YAML会导致kubernetes的数据结构不正确。在YAML中,缩进会影响数据的结构。看 我认为这应该是正确的:
apiVersion: v1
kind: Pod
metadata:
name: command-demo
labels:
purpose: demonstrate-command
spec:
containers:
- name: command-demo-container
image: debian
command: ["printenv"]
args: ["HOSTNAME", "KUBERNETES_PORT"]
env:
- name: MESSAGE
value: "hello world"
command: ["/bin/echo"]
args: ["$(MESSAGE)"]