minikube kubectl创建文件错误(验证数据:apiVersion未设置)

时间:2020-06-24 23:32:44

标签: kubernetes yaml kubectl minikube pod

我是一名学生,是minikube和linux的新手。我的老师也做了同样的事情,他的吊舱也创建了,但是我遇到了错误。我不知道是什么问题。我应该忽略验证错误吗?

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

我正在使用以下版本:

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

1 个答案:

答案 0 :(得分:1)

好像您有错字。它应该是apiVersion而不是apiversion。另外,PodSpec中的缩进似乎不正确。

您可以使用此:

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