error validating data: [ValidationError(Pod.spec)

7/2/2020

I am a beginner and start learning Kubernetes.

I'm trying to create a POD with the name of myfirstpodwithlabels.yaml and write the following specification in my YAML file. But when I try to create a POD I get this error.

error: error validating "myfirstpodwithlabels.yaml": error validating data: [ValidationError(Pod.spec): unknown field "contianers" in io.k8s.api.core.v1.PodSpec, ValidationError(Pod.spec): missing required field "containers" in io.k8s.api.core.v1.PodSpec]; if you choose to ignore these errors, turn validation off with --validate=false

My YAML file specification

kind: Pod
apiVersion: v1
metadata:
  name: myfirstpodwithlabels
  labels:
    type: backend
    env: production
spec:
  contianers:
  - image: aamirpinger/helloworld:latest
    name: container1
    ports:
    - containerPort: 80
-- Rukhshan Ali
kubernetes
minikube

1 Answer

7/2/2020

There is a typo in your .spec Section of the yaml. you have written:

  • "contianers"

as seen in the error message when it really should be

  • "containers"

also for future reference: if there is an issue in your resource definitions yaml it helps if you actually post the yaml on stackoverflow otherwise helping is not an easy task.

-- meaningqo
Source: StackOverflow