Creating a POD + container using Yaml file -->validating data: failed to download openapi:

adminuser@containerVm:~$ cat pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: nginx
labels:
app: nginx
tier: frontend
spec:
containers:

  • name: nginx
    image: nginx

adminuser@containerVm:~$ kubectl apply -f pod.yaml
error: error validating “pod.yaml”: error validating data: failed to download openapi: Get “http://localhost:8080/openapi/v2?timeout=32s”: dial tcp 127.0.0.1:8080: connect: connection refused; if you choose to ignore these errors, turn validation off with --validate=false

How can we fix this ?

I don’t see any problem with your YAML (although please use the </> key to generate code blocks for your YAML – it’s garbled if you don’t do that). One thing that might give you this problem is if your kubectl version and your cluster version aren’t sufficiently in sync. What do you get when you do

kubectl version

?