<p>We are migrating from <code>Jenkins Master/Slave</code> installation to <code>Kubernetes deployment</code> using <code>Jenkins</code> operator from <a href="https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/" rel="nofollow noreferrer">https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/</a></p>
<p>This is a snippet from our initial <code>jenkinsfile</code></p>
<pre><code>   pipeline {
    agent {
        label ('jenkins-slave')        
    }
    stages {
        stage ('Cloud Authentication') {
            steps {
                script {
                    withCredentials([file(credentialsId: 'mygcpproject-8e16', variable: 'key')]) {
                        sh &quot;&quot;&quot;
                        cat ${key} &gt; mykeys.json
                        chmod 400 mykeys.json
                        &quot;&quot;&quot; 
                    }
             ..........
             ..........
</code></pre>
<p>Now since we are moving to <code>Jenkins running as kubernetes pods</code> , what should be our value for <code>agent</code> inside the <code>pipeline</code></p>
<pre><code>        pipeline {
          agent {
            label ('jenkins-slave') 
</code></pre>
<p>Any suggestions or reference to any documentation will be highly appreciated.</p>

Zama Ques
<p>When you run <code>Jenkins</code> in <code>k8s</code> agents can be define two ways. One option is directly from <code>yaml</code> in <code>Jenkinsfile</code>. Second way is to include pod template from repository where you store your <code>Jenkins</code> pipeline configuration file.</p>
<p>Please refer to <a href="https://plugins.jenkins.io/kubernetes/#plugin-content-declarative-pipeline" rel="nofollow noreferrer">this</a> part of <code>k8s</code> plugin documentation for more detail instruction.</p>
