<p>We have configured two Kubernetes clouds in our jenkins</p>
<ul>
<li>kubernetes: this one runs all the build jobs related to setting up infra, building spring boot apps and their docker images etc; it's our devops automation apps cluster</li>
<li>apps-dev: this is where all our apps are deployed so it's our runtime cluster, non production</li>
</ul>
<p>I'm trying to run cucumber tests via maven but as we do not expose services via alb in the apps-dev cluster I wanted to run the maven job as a pod on the <code>apps-dev</code> cluster.</p>
<p>We've added pod label to the template but jenkins pipeline starts with just jnlp container.</p>
<pre><code>pipeline {
    agent {
        kubernetes {
            cloud 'apps-dev'
            yamlFile '''
                apiVersion: v1
                kind: Pod
                metadata:
                  labels:
                    jenkins/label: jenkins-apps-dev-agent
                    namespace: jenkins-jobs
                  containers:     
                    - name: mavenjdk11
                      image: maven:3.8.2-adoptopenjdk-11
                      resources:
                        limits:
                          memory: &quot;512Mi&quot;
                          cpu: &quot;500m&quot;
                        requests:
                          memory: &quot;256Mi&quot;
                          cpu: &quot;100m&quot;
                      command:
                        - sleep
                      args:
                        - 99d 
                  volumes:
                    - name: sharedvolume
                      emptyDir: {}                             
            '''
        }
    }
    ...
</code></pre>
<p>and the logs</p>
<pre><code>Created Pod: foo jenkins-jobs/foo-foo-integration-foo-feature-tests-17-m-4hhpq
[Normal][jenkins-jobs/foo-foo-integration-foo-feature-tests-17-m-4hhpq][LoggingEnabled] Successfully enabled logging for pod
Still waiting to schedule task
‘foo-foo-integration-foo-feature-tests-17-m-4hhpq’ is offline
[Normal][jenkins-jobs/foo-foo-integration-foo-feature-tests-17-m-4hhpq][Scheduled] Successfully assigned jenkins-jobs/foo-foo-integration-foo-feature-tests-17-m-4hhpq to fargate-ip-176-24-3-48.ec2.internal
[Normal][jenkins-jobs/foo-foo-integration-foo-feature-tests-17-m-4hhpq][Pulling] Pulling image &quot;jenkins/inbound-agent:4.3-4&quot;
[Normal][jenkins-jobs/foo-foo-integration-foo-feature-tests-17-m-4hhpq][TaintManagerEviction] Cancelling deletion of Pod jenkins-jobs/foo-foo-integration-foo-feature-tests-17-m-4hhpq
[Normal][jenkins-jobs/foo-foo-integration-foo-feature-tests-17-m-4hhpq][Pulled] Successfully pulled image &quot;jenkins/inbound-agent:4.3-4&quot; in 15.29095263s
[Normal][jenkins-jobs/foo-foo-integration-foo-feature-tests-17-m-4hhpq][Created] Created container jnlp
[Normal][jenkins-jobs/foo-foo-integration-foo-feature-tests-17-m-4hhpq][Started] Started container jnlp
Agent foo-foo-integration-foo-feature-tests-17-m-4hhpq is provisioned from template foo_foo-integration_foo-feature-tests_17-mnscq-lz8wj
---
apiVersion: &quot;v1&quot;
kind: &quot;Pod&quot;
metadata:
  annotations:
    buildUrl: &quot;https://jenkins.cloud.bar.com/job/foo/job/foo-integration/job/foo-feature-tests/17/&quot;
    runUrl: &quot;job/foo/job/foo-integration/job/foo-feature-tests/17/&quot;
  labels:
    jenkins/label-digest: &quot;baf69ff51703705e7e8252b6f5a54fc663dae21d&quot;
    jenkins/label: &quot;foo_foo-integration_foo-feature-tests_17-mnscq&quot;
  name: &quot;foo-foo-integration-foo-feature-tests-17-m-4hhpq&quot;
spec:
  containers:
  - env:
    - name: &quot;JENKINS_SECRET&quot;
      value: &quot;********&quot;
    - name: &quot;JENKINS_AGENT_NAME&quot;
      value: &quot;foo-foo-integration-foo-feature-tests-17-m-4hhpq&quot;
    - name: &quot;JENKINS_WEB_SOCKET&quot;
      value: &quot;true&quot;
    - name: &quot;JENKINS_NAME&quot;
      value: &quot;foo-foo-integration-foo-feature-tests-17-m-4hhpq&quot;
    - name: &quot;JENKINS_AGENT_WORKDIR&quot;
      value: &quot;/home/jenkins/agent&quot;
    - name: &quot;JENKINS_URL&quot;
      value: &quot;https://jenkins.cloud.bar.com/&quot;
    image: &quot;jenkins/inbound-agent:4.3-4&quot;
    name: &quot;jnlp&quot;
    resources:
      limits: {}
      requests:
        memory: &quot;256Mi&quot;
        cpu: &quot;100m&quot;
    volumeMounts:
    - mountPath: &quot;/home/jenkins/agent&quot;
      name: &quot;workspace-volume&quot;
      readOnly: false
  nodeSelector:
    kubernetes.io/os: &quot;linux&quot;
  restartPolicy: &quot;Never&quot;
  volumes:
  - emptyDir:
      medium: &quot;&quot;
    name: &quot;workspace-volume&quot;

 
</code></pre>

Anadi Misra
<p>There's an error in my yaml, it should have been</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  labels:
    jenkins/label: jenkins-apps-dev-agent
    namespace: jenkins-jobs
spec:
  containers:     
    - name: mavenjdk11
      image: maven:3.8.2-adoptopenjdk-11
      resources:
        limits:
          memory: &quot;512Mi&quot;
          cpu: &quot;500m&quot;
        requests:
          memory: &quot;256Mi&quot;
          cpu: &quot;100m&quot;
      command:
        - sleep
      args:
        - 99d 
  volumes:
    - name: sharedvolume
      emptyDir: {} 
</code></pre>
<p>the <code>spec:</code> before containers was missing</p>
