Creating a Kubernetes job results in 'batch/, Kind=Job matches multiple kinds'

11/11/2016

I recently upgraded from Kubernetes 1.2.0 to Kubernetes 1.3.0, and now I get the following error when I try to start a job:

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

where pijob.yaml is the job definition from the tutorial:

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

The error is confusing because it suggests that apiVersion: batch/v1, Kind: Job should be valid. If I try apiVersion: batch/v2alpha1, Kind: Job, I also get an error:

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

What am I doing wrong?

-- morxa
kubernetes

4 Answers

2/21/2017

I had the same error, so I followed the method below:

    [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"}

Than I create the job and didn't have any errors left.

-- Join Simith
Source: StackOverflow

11/22/2016

Have you tried with apiVersion: extensions/v1beta1?

-- Connor Doyle
Source: StackOverflow

1/23/2020

I had the same error message, it turned out that I was not logged in...

-- Remy
Source: StackOverflow

1/4/2017

check your kubernetes server and client version and make same one.

[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
-- Dae Seong Kim
Source: StackOverflow