Kubernetes Jenkins plugin - Jenkins doesn’t have label mypod

9/7/2017

I'm trying to perform jenkins CI/CD on Kubernetes with dynamic slaves, my jenkins version is official image 2.60.2, while the kubernetes-plugin is 1.0. After add a cloud with kubernetes, the slave can't run up. It shows:

pending—Jenkins doesn’t have label mypod

I refer to Kubernetes Jenkins plugin - slaves always offline to configure the jenkins system. I find the issue is described as a defect, I don't know whether this updated to latest jenkins images. Here is the link: https://github.com/jenkinsci/kubernetes-plugin/pull/127

Next error:

Jenkins doesn’t have label mypod

Could this be because of 400d1ed? KubernetesDeclarativeAgentScript.groovy probably needs to get an update then.

Does anyone know how to fix this issue?

-- Jessie
jenkins-pipeline
kubernetes

1 Answer

10/26/2017

The keyword is (as always): look at the logs! You should see your errors when issuing

kubectl logs $JENKINS_POD_NAME

Also, you can try the command below. Here, your faulted slaves will be listed. Look at the logs for these:

kubectl get pods -a

Your issue is related to JNLP communication, slave->master

My jenkins is running in a container and I had to expose the JNLP port to the cluster-node (nodePort).

apiVersion: v1
kind: Service
metadata:
  name: jenkins
  labels:
    app: jenkins
spec:
  ports:
    - name: jnlp
      port: 40294
      targetPort: 40294
    - name: http
      port: 80
      targetPort: 8080
  selector:
    app: jenkins
    tier: jenkins
  type: NodePort

Also in jenkins security, look for JNLP and enable ALL protocols. I am still playing with fixed or random ports. Not sure how I can expose random port from a k8s service. Port-range is not supported in k8s.

But I am able to fire off a slave and do some work!

-- Bjarte Brandt
Source: StackOverflow