# Jenkins kubernetes dynamic agent issue while running sh commands

**URL:** <https://community.jenkins.io/t/jenkins-kubernetes-dynamic-agent-issue-while-running-sh-commands/22953>\
**Category:** Ask a question\
**Tags:** pipeline, kubernetes\
**Created:** [November 6, 2024, 9:41pm UTC](https://community.jenkins.io/t/jenkins-kubernetes-dynamic-agent-issue-while-running-sh-commands/22953 "2024-11-06T21:41:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![azeem](https://avatars.discourse-cdn.com/v4/letter/a/43a26b/32.png) [@azeem](https://community.jenkins.io/u/azeem)\
**Post date:** [November 6, 2024, 9:41pm UTC](https://community.jenkins.io/t/jenkins-kubernetes-dynamic-agent-issue-while-running-sh-commands/22953/1 "2024-11-06T21:41:48Z")

</div>

Jenkins setup:

Jenkins 2.479.1 (running on AWS EC2)  
directly running jenkins.war

[Kubernetes Client API PluginVersion6.10.0-240.v57880ce8b\_0b\_2](https://plugins.jenkins.io/kubernetes-client-api)

[Kubernetes pluginVersion4296.v20a\_7e4d77cf6](https://plugins.jenkins.io/kubernetes)

Hey Guys!

I have been stuck with a very weird issue after upgrading jenkins.

The issue is as follows.

My Jenkins controller is running on AWS EC2 instance (t2.small). I have an EKS cluster on which I want to spawn my agent when running the pipeline. below is my pipeline script:

```auto
pipeline {
    agent {
    kubernetes {
      yaml '''
        apiVersion: v1
        kind: Pod
        metadata:
          labels:
            label: runner 
        spec:
          containers:
          - name: maven
            image: maven:3.6.3-openjdk-17-slim
            command:
            - cat
            tty: true
            volumeMounts: 
            - name: data-share
              mountPath: /tmp/
          - name: dind-daemon 
            image: docker:dind-rootless
            command:
            - cat
            resources: 
              requests: 
                cpu: 100m 
                memory: 512Mi
              limits:
                cpu: 500m
                memory: 1Gi
            tty: true    
            securityContext:
              privileged: true 
            volumeMounts: 
            - name: docker-graph-storage 
              mountPath: /var/lib/docker
            - name: data-share
              mountPath: /tmp/
          volumes: 
          - name: docker-graph-storage 
            emptyDir: {}
          - name: data-share
            emptyDir: {}
            '''
       }
    }
    

    stages() {
        stage('Checkout Application') {
            steps {
                container('maven') {
                    checkout scmGit(branches: [[name: '$branch_Name']], extensions: [], userRemoteConfigs: [[credentialsId: 'git-bwt-jenkins-token', url: 'URL']])
                }
            }
        }
        stage('Change Properties') {
            steps {
                container('maven') {
                 sh ''' ls -al
                        cd src/main/resources/
                        cat application-dev.properties
                    '''
                }
            }
        }
        stage('Maven Test & Build') {
            steps {
                container('maven') {
                sh 'mvn clean install -Dactive.profile=dev'
                }
            }
        }
        
    }
}    

```

The issue is the stage checkout works fine and successfully completes but when the pipeline moves to the next stage (‘Change Properties’) it gets stuck on sh.

When I go check the runners on my eks all 3 containers are running maven, jnlp, dind-daemon. But when I exec into the maven container and check running processes i see a cat command running. Basically the containers idle command is running and the sh ‘’ command is not overriding.

PFA logs and screenshots

 ![Screenshot 2024-11-07 at 2.21.01 AM](https://europe1.discourse-cdn.com/flex013/uploads/jenkins/original/2X/2/2ccec9f8fdc76d6989d1770bd6094b4de408e4c7.png)
