7

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?

Community
  • 1
  • 1
Jessie
  • 71
  • 1
  • 1
  • 4

1 Answers1

-1

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
  • 4,191
  • 2
  • 23
  • 25
  • In logs check the value for container cap, it should be set to a higher value. – Vaibhav Jain Feb 03 '18 at 19:41
  • 5
    if job is stuck at `Jenkins doesn’t have label mypod` then there's no pod created at that point in k8. means no pod log to look into. you can't assume its jnlp issue. Do you know where to looks for logs that point that it's a jnlp issue? – nir Nov 28 '18 at 02:26
  • @Jessie Does it answer your question ? Do you still have this problem ? – matt_j Mar 18 '21 at 16:46