Unable to Create container Via Jenkins pipeline Job

12/14/2019

I have some code which i have copied from the internet, below code having two pod container template maven and golang, when i am running my jenkins job, my build got stuck with following error message.

podTemplate(containers: [
    containerTemplate(name: 'maven', image: 'maven:3.3.9-jdk-8-alpine', ttyEnabled: true, command: 'cat'),
    containerTemplate(name: 'golang', image: 'golang:1.8.0', ttyEnabled: true, command: 'cat')
  ]) {

    node(POD_LABEL) {
        stage('Get a Maven project') {
            git 'https://github.com/jenkinsci/kubernetes-plugin.git'
            container('maven') {
                stage('Build a Maven project') {
                    sh 'mvn -B clean install'
                }
            }
        }

        stage('Get a Golang project') {
            git url: 'https://github.com/hashicorp/terraform.git'
            container('golang') {
                stage('Build a Go project') {
                    sh """
                    mkdir -p /go/src/github.com/hashicorp
                    ln -s `pwd` /go/src/github.com/hashicorp/terraform
                    cd /go/src/github.com/hashicorp/terraform && make core-dev
                    """
                }
            }
        }

    }
}
Still waiting to schedule task
All nodes of label ‘fuck_25-g75b6’ are offline

meanwhile when i am checking my master machine, and i verified pod status

kubectl get pods
NAME                        READY   STATUS        RESTARTS   AGE
fuck-25-g75b6-37hzw-gns85   2/3     Terminating   0          11s
fuck-25-g75b6-37hzw-wz5x6   2/3     Terminating   0          31s

Please find the below pod describe logs

root@jenkins-linux-vm:/usr/share/jenkins# kubectl describe pod fuck-25-g75b6-37hzw-7q2mh
Name:                      fuck-25-g75b6-37hzw-7q2mh
Namespace:                 default
Priority:                  0
Node:                      homework-poc-worker2/10.0.0.5
Start Time:                Sat, 14 Dec 2019 12:37:55 +0000
Labels:                    jenkins=slave
                           jenkins/fuck_25-g75b6=true
Annotations:               buildUrl: http://10.0.0.5:9090/job/fuck/25/
Status:                    Terminating (lasts <invalid>)
Termination Grace Period:  30s
IP:                        10.32.0.2
IPs:
  IP:  10.32.0.2
Containers:
  maven:
    Container ID:  docker://c6f1acba6c340ea1708d0a13d72d1fc2742d47efeb9db94d38ea1c3ee4269fc7
    Image:         maven:3.3.9-jdk-8-alpine
    Image ID:      docker-pullable://maven@sha256:3ab854089af4b40cf3f1a12c96a6c84afe07063677073451c2190cdcec30391b
    Port:          <none>
    Host Port:     <none>
    Command:
      cat
    State:          Running
      Started:      Sat, 14 Dec 2019 12:37:59 +0000
    Ready:          True
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /home/jenkins/agent from workspace-volume (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-8wgjn (ro)
  golang:
    Container ID:  docker://077e06837a4928266f842f1ada7c989e75dfd1069b78d5648c2eb24e433193b0
    Image:         golang:1.8.0
    Image ID:      docker-pullable://golang@sha256:70317de915e3414b6bd8e1a0f714d6c4e2d11262abf6815fe9895495a1b3d635
    Port:          <none>
    Host Port:     <none>
    Command:
      cat
    State:          Running
      Started:      Sat, 14 Dec 2019 12:38:01 +0000
    Ready:          True
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /home/jenkins/agent from workspace-volume (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-8wgjn (ro)
  jnlp:
    Container ID:   docker://e89ff0b06c72988427b963253e4958950a9c458d4b92dd1e041a406395b07d7b
    Image:          jenkins/jnlp-slave:3.35-5-alpine
    Image ID:       docker-pullable://jenkins/jnlp-slave@sha256:b21cf35bf498b48fdca62ecaf8800ea9e6bacb8ffd68a45b1d78143368533ae1
    Port:           <none>
    Host Port:      <none>
    State:          Terminated
      Reason:       Error
      Exit Code:    255
      Started:      Sat, 14 Dec 2019 12:38:02 +0000
      Finished:     Sat, 14 Dec 2019 12:38:03 +0000
    Ready:          False
    Restart Count:  0
    Environment:
      JENKINS_SECRET:         1de8f650bdeb80df7e4896310a1a1ae8e1e65690f92858218952c93cb86c063f
      JENKINS_TUNNEL:         http://10.0.0.5:50000
      JENKINS_AGENT_NAME:     fuck-25-g75b6-37hzw-7q2mh
      JENKINS_NAME:           fuck-25-g75b6-37hzw-7q2mh
      JENKINS_AGENT_WORKDIR:  /home/jenkins/agent
      JENKINS_URL:            http://10.0.0.5:9090/
    Mounts:
      /home/jenkins/agent from workspace-volume (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-8wgjn (ro)
Conditions:
  Type              Status
  Initialized       True 
  Ready             False 
  ContainersReady   False 
  PodScheduled      True 
Volumes:
  workspace-volume:
    Type:       EmptyDir (a temporary directory that shares a pod's lifetime)
    Medium:     
    SizeLimit:  <unset>
  default-token-8wgjn:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-8wgjn
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  beta.kubernetes.io/os=linux
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                 node.kubernetes.io/unreachable:NoExecute for 300s
Events:
  Type    Reason     Age        From                       Message
  ----    ------     ----       ----                       -------
  Normal  Scheduled  <unknown>  default-scheduler          Successfully assigned default/fuck-25-g75b6-37hzw-7q2mh to homework-poc-worker2
  Normal  Pulled     29s        kubelet, homework-poc-worker2  Container image "maven:3.3.9-jdk-8-alpine" already present on machine
  Normal  Created    27s        kubelet, homework-poc-worker2  Created container maven
  Normal  Started    27s        kubelet, homework-poc-worker2  Started container maven
  Normal  Pulled     27s        kubelet, homework-poc-worker2  Container image "golang:1.8.0" already present on machine
  Normal  Created    26s        kubelet, homework-poc-worker2  Created container golang
  Normal  Started    25s        kubelet, homework-poc-worker2  Started container golang
  Normal  Pulled     25s        kubelet, homework-poc-worker2  Container image "jenkins/jnlp-slave:3.35-5-alpine" already present on machine
  Normal  Created    25s        kubelet, homework-poc-worker2  Created container jnlp
  Normal  Started    24s        kubelet, homework-poc-worker2  Started container jnlp
  Normal  Killing    20s        kubelet, homework-poc-worker2  Stopping container maven
  Normal  Killing    20s        kubelet, homework-poc-worker2  Stopping container golang

Note: i have two node master/worker both are up and running. let me know if any other details are required.

Can you please some one help me how to fix this issue, this would be really helpful to understand the basic workflow.

-- tp.palanisamy thangavel
jenkins
kubernetes

0 Answers