3

I have jenkins running on Windows as a service on 127.0.0.1:8080
and minikube running on 192.168.99.101
below is the pipeline for Jenkins job

podTemplate(
  activeDeadlineSeconds: 240,
  name: 'default',
  inheritFrom: 'default',
  nodeSelector: 'key1=value1,kubernetes.io/hostname=minikube',
  containers: [
  containerTemplate(name: 'maven', image: 'maven:3.3.9-jdk-8-alpine', ttyEnabled: true, command: 'cat' ),
  containerTemplate(name: 'jnlp', image: 'jenkins/jnlp-slave:3.35-2-alpine', args: '${computer.jnlpmac} ${computer.name}')
]) {

node(POD_LABEL) {
    stage('Get a Maven project') {
        git 'https://github.com/<project>.git/'
        container('maven') {
            stage('Build a Maven project') {
                sh 'mvn -B -gs ./settings.xml clean install'
            }
        }
    }
  }
}    

The following are the logs for from the kubernetes:

$ kubectl get -a pods --watch
Flag --show-all has been deprecated, will be removed in an upcoming release
NAME                  READY     STATUS    RESTARTS   AGE
default-7r0n8-b2sxx   0/2       Pending   0          0s
default-7r0n8-b2sxx   0/2       Pending   0         0s
default-7r0n8-b2sxx   0/2       ContainerCreating   0         0s
default-7r0n8-b2sxx   2/2       Running   0         0s
default-7r0n8-b2sxx   1/2       Error     0         1s
default-7r0n8-18cv6   0/2       Pending   0         0s
default-7r0n8-18cv6   0/2       Pending   0         0s
default-7r0n8-18cv6   0/2       ContainerCreating   0         0s
default-7r0n8-18cv6   2/2       Running   0         0s
default-7r0n8-18cv6   1/2       Error     0         2s
default-7r0n8-0kz80   0/2       Pending   0         0s
default-7r0n8-0kz80   0/2       Pending   0         0s
default-7r0n8-0kz80   0/2       ContainerCreating   0         0s
default-7r0n8-0kz80   2/2       Running   0         0s
default-7r0n8-0kz80   1/2       Error     0         1s  

The following is the console's output from the jenkins job

enter image description here

The pods are getting killed and recreated each time.

Please Can anyone help how to resolve this issue?
Any help would be appreciated.

pod logs

enter image description here

enter image description here

Pit
  • 736
  • 3
  • 17

1 Answers1

4

I have the same problem since yesterday. Navigate to Configure Clouds --> kubernetes --> Pod Template. Set Pod Retention as 'Always'. Pods will stay in error status. You can get the pod logs with command kubectl logs --all-containers and see the error reason. In my case Jenkins URL and Jenkins Tunnel is not set properly.

Refer to https://www.youtube.com/watch?v=DCkzdsffeh0

It gives details for jenkins and kubernetes plugin configuration

  • Did you setup the environment same as mine?running Jenkins as windows service, outside minikube cluster – elliot alderson Jul 31 '20 at 18:08
  • No, I have setup jenkins in GKE. jnlp container in the agent pod is not able to connect to Jenkis so new agent pod are getting created. I believe it is related to the jenkins URL. In my case after I provided correct Jenkins URL it worked for me. For jenkins as window service check if setting Jenkins URL to http://:8080 works. – Debashish Hota Aug 01 '20 at 16:42
  • Please try the following: 1. For the agent pod created from jenkins, type kubectl exec -it <> -- bash. 2. Inside the pod bash, curl http://<>. (e.g http://<>). The curl command which works is the correct Jenkins url. Agent pod will be able to connect back to jenkins. Sorry I could not find time to set up minikube and check the exact url. Also try with http://:8080 in curl command. If you succeed please let me know – Debashish Hota Aug 03 '20 at 17:37
  • The pod gets created and killed immediately, same thing repeats again and again as shown above. – Abhishek D K Aug 04 '20 at 18:48
  • the issue is inbound docker-agent is trying to ping jenkins master 127.0.0.1:8080, but this is not possible because containers are isolated from host applications. – elliot alderson Aug 05 '20 at 14:10