<p>I'm running jenkins jobs to build our maven application and deploy into kubernetes cluster. in-order do that i have created pod container template to deploy my modules.</p>

<p>When i am running to build my jenkins job, my build got failed with below error,</p>

<pre><code>Still waiting to schedule task
‘Jenkins’ doesn’t have label ‘Angular_71-bt2f0’
</code></pre>

<p>At the same time when i am checking kubernetes master, i can able to see pods is trying to schedule and its going back to terminating state after few seconds.</p>

<pre><code>root@poc:/var/run# kubectl get pods
NAME                           READY   STATUS              RESTARTS   AGE
angular-71-bt2f0-ns772-4rmrq   0/3     ContainerCreating   0          1s

root@poc:/var/run# kubectl get pods
NAME                           READY   STATUS        RESTARTS   AGE
angular-71-bt2f0-ns772-4rmrq   2/3     Terminating   0          28s
angular-71-bt2f0-ns772-mcv9z   2/3     Error         0          8s
</code></pre>

<p>pipeline script</p>

<pre><code>def label = "worker-${UUID.randomUUID().toString()}"

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'
                }
            }
        }
    }
  }
</code></pre>

<p>Please find the below master machine configuration</p>

<pre><code>root@poc:~# kubectl get svc
NAME         TYPE        CLUSTER-IP    EXTERNAL-IP   PORT(S)          AGE
kubernetes   ClusterIP   10.96.0.1     &lt;none&gt;        443/TCP          2d

root@poc:~# kubectl get nodes
NAME          STATUS    ROLES    AGE    VERSION
poc-worker2   Ready    worker   6m3s   v1.17.0
poc.com       Ready    master   2d     v1.17.0

root@poc:~# kubectl get svc
NAME         TYPE        CLUSTER-IP    EXTERNAL-IP   PORT(S)          AGE
kubernetes   ClusterIP   10.96.0.1     &lt;none&gt;        443/TCP          2d

root@poc:~# kubectl cluster-info
Kubernetes master is running at https://10.0.0.4:6443
KubeDNS is running at https://10.0.0.4:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
</code></pre>

<p>kubectl error log</p>

<pre><code>kubectl logs angular-71-bt2f0-ns772-4rmrq 

error: a container name must be specified for pod angular-77-l32fr-sfxqk-qhdgf, choose one of: [maven golang jnlp]
</code></pre>

<pre><code>Below is the kubectl logs while running jenkins job

root@poc:~# kubectl logs angular103f578nkcrnfx69fk c maven
Error from server (NotFound): pods "angular103f578nkcrnfx69fk" not found

root@poc:~# kubectl logs angular103f578nkcrnfx69fk c golang
Error from server (NotFound): pods "angular103f578nkcrnfx69fk" not found

root@poc:~# kubectl logs angular103f578nkcrnfx69fk c jnlp
Error from server (NotFound): pods "angular103f578nkcrnfx69fk" not found
</code></pre>

<p>can you please some one help me how to fix this issue, i am not sure where i am doing wrong here.</p>

<p>Because, <code>kubectl -n jenkins-namespace get services</code> shows : </p>

<pre><code>NAME                 TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)     AGE
cicd-jenkins         ClusterIP   172.20.120.227   &lt;none&gt;        8080/TCP    128d
cicd-jenkins-agent   ClusterIP   172.20.105.189   &lt;none&gt;        50000/TCP   128d
</code></pre>

<p>You have to go to Jenkins > Manage Jenkins > Configure System (<a href="http://jenkins:8080/configure" rel="nofollow noreferrer">http://jenkins:8080/configure</a>).
Then, configure <strong>Jenkins URL</strong> and <strong>jenkins tunnel</strong> accordingly (see screenshot below )</p>

<p><strong>CREDITS</strong> to <a href="https://youtu.be/MkzCVvlpiaM" rel="nofollow noreferrer">https://youtu.be/MkzCVvlpiaM</a></p>

<p><a href="https://i.stack.imgur.com/sys1u.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sys1u.png" alt="enter image description here"></a></p>

<p>If you'are using the Jenkins Configuration as Code (JCasC) plugin this is configured via <code>jenkinsUrl</code> and <code>jenkinsTunnel</code> keys : </p>

<pre><code>jenkins:
  clouds:
  - kubernetes:
      name: cluster
      serverUrl: https://kubernetes.default
      # ....
      jenkinsUrl: http://cicd-jenkins:8080/
      jenkinsTunnel:  cicd-jenkins-agent:50000
      # ....
</code></pre>
