1
votes

I have created one cluster in google container engine & in that i have deployed one pod having jenkins running in it. then configiured one job which will build,run,push & deploy sample app. so all these job steps are executing except "deploy-sampleapp-step" due to below error

[sampleapp_master-HAWDXNK5BCRQ7EWPPOHGW7RUWBBM25WIAIKOP6UBHIDYZGTMQIJA] Running shell script
+ kubectl --namespace=production apply -f k8s/services/ error: group map[:0xc820374b60 apps:0xc820374bd0 authorization.k8s.io:0xc820374c40 componentconfig:0xc820374d90 extensions:0xc820374e00 policy:0xc820374e70 storage.k8s.io:0xc8202cc770 federation:0xc820374af0 autoscaling:0xc820374cb0 batch:0xc820374d20 rbac.authorization.k8s.io:0xc820374ee0 authentication.k8s.io:0xc820374fc0] is already registered

So I am using cluster version 1.6.4

So does anyone has any idea how to escalate this problem
Thanks In advance Adding some more information that may be useful for the above question-

user@yproject-173008:~$ kubectl cluster-info
Kubernetes master is running at https://IP GLBCDefaultBackend is running at https://IP/api/v1/proxy/namespaces/kube-system/services/default-http-backend
Heapster is running at https://IP/api/v1/proxy/namespaces/kube-system/services/heapster
KubeDNS is running at https://IP/api/v1/proxy/namespaces/kube-system/services/kube-dns
kubernetes-dashboard is running at
https://IP/api/v1/proxy/namespaces/kube-system/services/kubernetes-dashboard
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.

user@yproject-173008:~$ kubectl version
Client Version: version.Info{Major:"1", Minor:"6", GitVersion:"v1.6.6", GitCommit:"7fa1c1756d8bc963f1a389f4a6937dc71f08ada2", GitTreeState:"clean", BuildDate:"2017-06-16T18:34:20Z", GoVersion:"go1.7.6", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"6", GitVersion:"v1.6.4", GitCommit:"d6f433224538d4f9ca2f7ae19b252e6fcb66a3ae", GitTreeState:"clean", BuildDate:"2017-05-19T18:33:17Z", GoVersion:"go1.7.5", Compiler:"gc", Platform:"linux/amd64"}

2

2 Answers

2
votes

You are getting this error because the version of kubeAPI and version of kubectl is different. To get versions, edit Jenkins file present in the build directory to print version of kubectl client that has been used inside the jenkins slave envirnment while executing the job. In my case it was at /continuous-deployment-on-kubernetes/sample-app/Jenkinsfile . Add following line-

sh("kubectl version")

This will print the version of the kubectl used by jenkins slave.

I found it as GitVersion:"v1.3.4". If this is the case for you then perform following steps-

1. Generate jenkins slave dockerfile
-> create Dockerfile with following contents-

FROM jenkinsci/jnlp-slave
ENV CLOUDSDK_CORE_DISABLE_PROMPTS 1
ENV PATH /opt/google-cloud-sdk/bin:$PATH
USER root
RUN apt-get update -y
RUN apt-get install -y jq
RUN curl https://sdk.cloud.google.com | bash && mv google-cloud-sdk /opt
COPY kubectl /opt/google-cloud-sdk/bin/
RUN chmod +x /opt/google-cloud-sdk/bin/kubectl

-> Download kubectl binary compatible with your kube-cluster. OR Take binary present at your kube-cluster and place it in this directory.
-> build image and push it to your registry.

docker build -t IMAGE_NAME .
gcloud docker -- push IMAGE_NAME

2. Edit jenkins configuration to use this image for slave.
Go to Jenkins-> Manage Jenkins->Configure System.
Scroll down to Cloud.
Select Kubernetes. Go to Images->Containers->Docker image.
Enter image name that you have pushed in step 1.
click save.
3. start the job.

0
votes

This looks like this issue: kubectl throwing group is already registered error

Perhaps your kubectl is an old version (1.4 or earlier)? Try upgrading to a newer version.