title: Kubernetes cloud agent for Jenkins always offline during pipeline execution
body: <p>I try to deploy microservices into k8s pod using Jenkins pipeline and k8s cloud agent.
  I configured my agent on Jenkins but during execution I always have message saying my agent is offline.</p>
  <p>You could find my Jenkins configuration and my Jenkins file.</p>
  <p>Regards,</p>
  <p>Jenkinsfile</p>
  <pre><code>pipeline {
      environment {
          MAVEN_SETTINGS = ''
          MAVEN_ENV = 'maven-3.6.3'
          JDK_ENV = 'jdk-1.2'
          GIT_URL = 'PRIVATE REPO'
      }
      agent any
      parameters{
          booleanParam(name:&quot;RELEASE&quot;,
             description:&quot;Release&quot;,
             defaultValue:false
          )
      }
      stages {
          stage ('build &amp; deploy'){
              when{
                  expression {!params.RELEASE}
              }
              steps{
                  withMaven(
                      maven: env.MAVEN_ENV,
                      mavenSettingsConfig: env.MAVEN_SETTINGS,
                      jdk: env.JDK_ENV) {
                          sh &quot;mvn clean deploy -U&quot;
                  }
              }
          }
          stage ('create image'){
              steps{
                  script {
                      docker.withRegistry('https://registry.digitalocean.com', 'images-credential') {
                          def customImage = docker.build(&quot;images-repo:${params.IMAGE_VERSION}&quot;,&quot;./target&quot;)
                          customImage.push(&quot;${params.IMAGE_VERSION}&quot;)
                      }
                  }
              }
          }
          stage ('Deploy Pod') {
  
              agent { label 'kubepod' }
  
              steps {
                  script {
                      kubernetesDeploy(configs: &quot;/kubernetes/pod.yml&quot;, kubeconfigId: &quot;mykubeconfig&quot;)
                      kubernetesDeploy(configs: &quot;/kubernetes/services.yml&quot;, kubeconfigId: &quot;mykubeconfig&quot;)
                  }
              }
          }
      }
  }
  </code></pre>
  <p>Kubernetes agent config
  <a href="https://i.stack.imgur.com/ELjxa.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ELjxa.jpg" alt="enter image description here" /></a></p>
  <p>Pod template config
  <a href="https://i.stack.imgur.com/uza2w.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uza2w.png" alt="enter image description here" /></a></p>
  <p>Jenkins global security config
  <a href="https://i.stack.imgur.com/Bww8O.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Bww8O.jpg" alt="enter image description here" /></a></p>
  <p>Build log
  <a href="https://i.stack.imgur.com/j1b5Y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/j1b5Y.png" alt="enter image description here" /></a></p>