<p>I have created kubernetes cluster in GCP and top of it i have configured jenkins in kubernetes using the below url
<a href="https://cloud.google.com/solutions/jenkins-on-kubernetes-engine-tutorial" rel="nofollow noreferrer">https://cloud.google.com/solutions/jenkins-on-kubernetes-engine-tutorial</a></p>
<p>I am able to run jenkins build with normal commands and it is creating a pod and the build is getting successful. When i am trying to change the image for maven build or golang build, i am unable to complete it. When i try to change it the pod is keep on terminating and recreating.</p>
<p><a href="https://i.stack.imgur.com/pmPxz.png" rel="nofollow noreferrer">jenkins kubernetes configuration</a></p>
<p><a href="https://i.stack.imgur.com/l90Xv.png" rel="nofollow noreferrer">Jenkins pod template</a></p>
<p><a href="https://i.stack.imgur.com/Zl88D.png" rel="nofollow noreferrer">Jenkins build</a></p>

sai manikanta
<p>We can add pod template in Jenkins pipeline script to pull our custom image and to run as a slave pod. Use this below format:</p>
<p><div class="snippet" data-lang="js" data-hide="true" data-console="false" data-babel="false">
<div class="snippet-code snippet-currently-hidden">
<pre class="snippet-code-html lang-html prettyprint-override"><code>pipeline {
  agent {
    kubernetes {
      defaultContainer 'jnlp'
      yaml """
apiVersion: v1
kind: Pod
metadata:
  labels:
    some-label: some-label-value
spec:
  containers:
  - name: maven
    image: maven:alpine
    command:
    - cat
    tty: true
  - name: busybox
    image: busybox
    command:
    - cat
    tty: true
"""
    }
  }
  stages {
    stage('Run maven') {
      steps {
        container('maven') {
          sh 'mvn -version'
        }
        container('busybox') {
          sh '/bin/busybox'
        }
      }
    }
  }
}</code></pre>
</div>
</div>
</p>
