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

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?

Have you tried with apiVersion: extensions/v1beta1?

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

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.

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

Related

How to upgrade kubectl server version to v1.21

I would like to upgrade kubectl server version to be compatible with client version to get rid of Selflink issue that has been deprecated after kubernetes v1.21. How can I do this?
PS C:\> kubectl version
Client Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.2", GitCommit:"092fbfbf53427de67cac1e9fa54aaa09a28371d7", GitTreeState:"clean", BuildDate:"2021-06-16T12:59:11Z", GoVersion:"go1.16.5", Compiler:"gc", Platform:"windows/amd64"}
Server Version: version.Info{Major:"1", Minor:"20", GitVersion:"v1.20.7", GitCommit:"e1d093448d0ed9b9b1a48f49833ff1ee64c05ba5", GitTreeState:"clean", BuildDate:"2021-06-03T00:20:57Z", GoVersion:"go1.15.12", Compiler:"gc", Platform:"linux/amd64"}
Update your kubernetes cluster that you are using. You see the api server version there.

kubectl get deployments output differ from this in documentation

When I run this command
kubectl get deployments
at my Linux Ubuntu 18 machine, I got different output than expected (according to documentation).
Expected:
Actual:
Of course, I am not talking about values, I am talking about names of labels.
[EDIT]
My k8s version:
This is just an old output format. The newer output you're getting below contains all the same information; the "READY" field is a combination of the old "DESIRED" and "CURRENT".
It's showing as 4/5 in your output to indicate 4 pods ready/current, and 5 pods desired.
Hope this helps.
The output depends on client version. Let's check it with the same server
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"8", GitVersion:"v1.8.0", GitCommit:"6e937839ac04a38cac63e6a7a306c5d035fe7b0a", GitTreeState:"clean", BuildDate:"2017-09-28T22:57:57Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.3", GitCommit:"5e53fd6bc17c0dec8434817e69b04a25d8ae0ff0", GitTreeState:"clean", BuildDate:"2019-06-06T01:36:19Z", GoVersion:"go1.12.5", Compiler:"gc", Platform:"linux/amd64"}
$ kubectl get deployments kube-dns -n kube-system
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
kube-dns 2 2 2 2 10d
Switching the kubectl version changes output:
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.3", GitCommit:"5e53fd6bc17c0dec8434817e69b04a25d8ae0ff0", GitTreeState:"clean", BuildDate:"2019-06-06T01:44:30Z", GoVersion:"go1.12.5", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.3", GitCommit:"5e53fd6bc17c0dec8434817e69b04a25d8ae0ff0", GitTreeState:"clean", BuildDate:"2019-06-06T01:36:19Z", GoVersion:"go1.12.5", Compiler:"gc", Platform:"linux/amd64"}
$ kubectl get deployments kube-dns -n kube-system
NAME READY UP-TO-DATE AVAILABLE AGE
kube-dns 2/2 2 2 10d

Can't delete Kubernetes object: no kind "GetOptions" is registered

I'm getting the following error when trying to delete a StatefulSets on my local minikube cluster
error: no kind "GetOptions" is registered for version "apps/v1"
I can set the replicas to 0, but that still keeps the StatefulSet alive.
I'm running following version
Client Version: version.Info{Major:"1", Minor:"8", GitVersion:"v1.8.0", GitCommit:"6e937839ac04a38cac63e6a7a306c5d035fe7b0a", GitTreeState:"clean", BuildDate:"2017-09-28T22:57:57Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.0", GitCommit:"fc32d2f3698e36b93322a3465f63a14e9f0eaead", GitTreeState:"clean", BuildDate:"2018-03-26T16:44:10Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}
Any help would be appreciated!
It seems your kubectl version and kubernetes version isn't in sync. your kubectl version doesn't know new statefulset version.
You need to upgrade your kubectl version.

GitLab Kubernetes integration error; configuration of Helm Tiller already exists

After connecting my Gitlab repo to my self-putup Kubernetes cluster via Operations > Kubernetes, I want to install Helm Tiller via the GUI; but I get:
Something went wrong while installing Helm Tiller
Kubernetes error: configmaps "values-content-configuration-helm" already exists
There are no pods running on the cluster and kubectl version returns:
Client Version: version.Info{Major:"1", Minor:"11", GitVersion:"v1.11.2", GitCommit:"bb9ffb1654d4a729bb4cec18ff088eacc153c239", GitTreeState:"clean", BuildDate:"2018-08-07T23:17:28Z", GoVersion:"go1.10.3", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"11", GitVersion:"v1.11.2", GitCommit:"bb9ffb1654d4a729bb4cec18ff088eacc153c239", GitTreeState:"clean", BuildDate:"2018-08-07T23:08:19Z", GoVersion:"go1.10.3", Compiler:"gc", Platform:"linux/amd64"}
update
the output of kubectl get cm --all-namespaces:
NAMESPACE NAME DATA AGE
gitlab-managed-apps values-content-configuration-helm 3 7d
...
deleting this namespace solves the issue!
Find the gitlab-managed-apps namespace with kubectl get cm --all-namespaces:
NAMESPACE NAME DATA AGE
gitlab-managed-apps values-content-configuration-helm 3 7d
...
deleting this namespace solves the issue:
kubectl delete namespace gitlab-managed-apps
Thanks to Lev Kuznetsov.

kubectl describe nodes, reports some error

I am gettting this error in kubectl describe nodes nodename. I just did a google search but nothing useful found , what does this mean.
Failed to update Node Allocatable Limits "": failed to set supported cgroup subsystems for cgroup : Failed to set config for supported subsystems : failed to write 3783778304 to memory.limit_in_bytes: write /rootfs/sys/fs/cgroup/memory/memory.limit_in_bytes: invalid argument
Do I need to change some kernel settings using sysctl ?
[iahmad#lxplus000 ~]$ kubectl --version
Kubernetes v1.5.2
[iahmad#lxplus000 ~]$
[iahmad#lxplus000 ~]$
[iahmad#lxplus000 ~]$ kubectl version
Client Version: version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.2", GitCommit:"269f928217957e7126dc87e6adfa82242bfe5b1e", GitTreeState:"clean", BuildDate:"2017-07-03T15:31:10Z", GoVersion:"go1.7.4", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"7", GitVersion:"v1.7.6", GitCommit:"4bc5e7f9a6c25dc4c03d4d656f2cefd21540e28c", GitTreeState:"clean", BuildDate:"2017-09-18T08:52:26Z", GoVersion:"go1.9", Compiler:"gc", Platform:"linux/amd64"}
[iahmad#lxplus000 ~]$
It depends on the kubectl/kubernetes version: this was seen (and fixed) in kubernetes issue 42701
1.6 should have been patched.
If this is not the same bug, the error message was also seen in issue 29166:
I just forgot to active back disk.uuid after creating back my new VMs!