while creating yaml file with kubectl i am getting error of apiversion not set. but i have already set it to v1.
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:
i am using these versions
minikube version: v1.11.0
kubectl is version 1.8.4
Kubernetes 1.18.3
Docker 19.03.11
I did typo in writing apiversion instead of apiVersion. Issue is resolved.
In my case, I am deploying my project on GKE via Travis. In my travis file, I am calling a shell file (deploy.sh).
In the deploy.sh file, I have written all the steps to create kubernetes resources:
### Deploy
# Apply k8s config
kubectl apply -f .
So here, I replaced kubectl apply -f . with the individual file names as follows:
### Deploy
# Apply k8s config
kubectl apply -f namespace.yaml
kubectl apply -f deployment.yaml
kubectl apply -f service.yaml
kubectl apply -f ingress.yaml
And then, the error is fixed!