Search code examples
kubernetesyamlkubectlminikube

minikube kubectl create file error (validating data: apiVersion not set)


I am a student and new to minikube as well as linux. My Teacher did the same and his pod created but i am getting error. I don't know what is the problem. Should i ignore validation error?

kubectl create -f myfirstpod.yaml
error: error validating "myfirstpod.yaml": error validating data: apiVersion not set; if you choose to ignore these errors, turn validation off with --validate=false

cat myfirstpod.yaml

 kind: Pod
 apiversion: v1
 metadata:
   name: myfirstpod
 spec:
   containers:
 name: container1
 image: aamirpinger/helloworld:latest
 ports:
   containerPort: 80

I am using these versions:

  • minikube version: v1.11.0
  • kubectl version 1.8.4
  • Kubernetes 1.18.3
  • Docker 19.03.11

Solution

  • Seems like you have typo. It should be apiVersion instead of apiversion. Also, the indentation in the PodSpec seems incorrect.

    You can use this:

    kind: Pod
    apiVersion: v1
    metadata:
      name: myfirstpod
    spec:
      containers:
      - name: container1
        image: aamirpinger/helloworld:latest
        ports:
        - containerPort: 80