not able to deploy k8s pod when tried through jenkins job on GCE

7/6/2017

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

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

-- Vaibhav
docker
google-compute-engine
jenkins
kubernetes

2 Answers

7/10/2017

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.

-- Ian Lewis
Source: StackOverflow

7/10/2017

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.

-- Yogesh Jilhawar
Source: StackOverflow