创建Kubernetes作业会导致'batch /,Kind = Job multiple multiple multiple'

时间:2016-11-11 22:24:16

标签: kubernetes

我最近从Kubernetes 1.2.0升级到Kubernetes 1.3.0,现在当我尝试开始工作时出现以下错误:

$ kubectl create -f pijob.yaml 
unable to recognize "pijob.yaml": batch/, Kind=Job matches multiple kinds [batch/v1, Kind=Job batch/v2alpha1, Kind=Job]

其中pijob.yaml是教程中的作业定义:

apiVersion: batch/v1
kind: Job
metadata:
  name: pi
spec:
  template:
    metadata:
      name: pi
    spec:
      containers:
      - name: pi
        image: perl
        command: ["perl",  "-Mbignum=bpi", "-wle", "print bpi(2000)"]
      restartPolicy: Never

错误令人困惑,因为它表明apiVersion: batch/v1, Kind: Job应该有效。如果我尝试apiVersion: batch/v2alpha1, Kind: Job,我也会收到错误:

$ kubectl create -f pijob.yaml
error validating "pijob.yaml": error validating data: couldn't find type: v2alpha1.Job

我做错了什么?

4 个答案:

答案 0 :(得分:0)

您是否尝试过apiVersion: extensions/v1beta1

答案 1 :(得分:0)

检查您的kubernetes服务器和客户端版本并制作相同的版本。

[root@allinone dan]# kubectl version

Client Version: version.Info{Major:"1", Minor:"3", GitVersion:"v1.3.0", GitCommit:"86dc49aa137175378ac7fba7751c3d3e7f18e5fc", GitTreeState:"clean", BuildDate:"2016-12-15T16:57:18Z", GoVersion:"go1.6.3", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.1", GitCommit:"82450d03cb057bab0950214ef122b67c83fb11df", GitTreeState:"clean", BuildDate:"2016-12-14T00:52:01Z", GoVersion:"go1.7.4", Compiler:"gc", Platform:"linux/amd64"}
[root@allinone dan]# kubectl create -f ./job.yaml 

error: unable to recognize "./job.yaml": batch/, Kind=Job matches multiple kinds [batch/v1, Kind=Job batch/v2alpha1, Kind=Job]

[root@allinone dan]# wget https://storage.googleapis.com/kubernetes-release/release/v1.5.1/bin/linux/amd64/kubectl

[root@allinone dan]# chmod +x kubectl

[root@allinone dan]# mv kubectl /usr/local/bin/kubectl

[root@allinone dan]# kubectl version

Client Version: version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.1", GitCommit:"82450d03cb057bab0950214ef122b67c83fb11df", GitTreeState:"clean", BuildDate:"2016-12-14T00:57:05Z", GoVersion:"go1.7.4", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.1", GitCommit:"82450d03cb057bab0950214ef122b67c83fb11df", GitTreeState:"clean", BuildDate:"2016-12-14T00:52:01Z", GoVersion:"go1.7.4", Compiler:"gc", Platform:"linux/amd64"}

[root@allinone dan]# kubectl create -f ./job.yaml 
job "pi" created

答案 2 :(得分:0)

我有同样的错误,所以我按照下面的方法:

    [root@host141 tensorflow]#wget https://storage.googleapis.com/kubernetes-release/release/v1.5.1/bin/linux/amd64/kubectl  ./
    [root@host141 tensorflow]#  cp /usr/bin/kubectl /usr/bin/kubectl.bak
    [root@host141 tensorflow]#  cp kubectl /usr/bin/kubectl
    [root@host141 tensorflow]# kubectl version
    Client Version: version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.1",           GitCommit:"82450d03cb057bab0950214ef122b67c83fb11df", GitTreeState:"clean",   BuildDate:"2016-12-14T00:57:05Z", GoVersion:"go1.7.4", Compiler:"gc",  Platform:"linux/amd64"}
    Server Version: version.Info{Major:"1", Minor:"3", GitVersion:"v1.3.0",  GitCommit:"86dc49aa137175378ac7fba7751c3d3e7f18e5fc", GitTreeState:"clean",  BuildDate:"2016-12-15T16:57:18Z", GoVersion:"go1.6.3", Compiler:"gc",  Platform:"linux/amd64"}

比起我创造的工作并没有留下任何错误。

答案 3 :(得分:0)

我有同样的错误消息,结果是我没有登录...