简体   繁体   中英

Jenkins slave as a kubernetes pod

I have created kubernetes cluster in GCP and top of it i have configured jenkins in kubernetes using the below url https://cloud.google.com/solutions/jenkins-on-kubernetes-engine-tutorial

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.

jenkins kubernetes configuration

Jenkins pod template

Jenkins build

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:

 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' } } } } }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM