title: Kubernetes : error validating data: found invalid field env for v1.PodSpec;
body: <p>I am using below yaml file to create the pod, kubectl command giving below error.</p>
  
  <p>How to correct this error message?</p>
  
  <pre><code>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
  </code></pre>
  
  <p>follow example from this page.</p>
  
  <p><a href="https://kubernetes.io/docs/tasks/configure-pod-container/define-command-argument-container/" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/configure-pod-container/define-command-argument-container/</a></p>
  
  <p>Thanks
  -SR</p>