【问题标题】:minikube kubectl create file error (validating data: apiVersion not set)minikube kubectl 创建文件错误(验证数据:未设置 apiVersion)
【发布时间】:2020-10-15 08:04:35
【问题描述】:

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

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

【问题讨论】:

    标签: kubernetes yaml kubectl minikube


    【解决方案1】:

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

    你可以用这个:

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

    【讨论】:

    • 谢谢,我在“apiVersion”中写错了大写V。
    • 这是我第一次发布大量的 stackoverflow,这就是为什么我不知道保持 indetation 的格式。再次感谢
    猜你喜欢
    • 2020-10-26
    • 1970-01-01
    • 2020-04-02
    • 2022-07-10
    • 1970-01-01
    • 2021-10-29
    • 2020-06-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多