From 8cc909baba7778fe56f14417b7b526a52199a69e Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Wed, 9 Nov 2022 19:05:41 -0600 Subject: [PATCH] ci: Run in Kubernetes instead of Docker We'll use the `podTemplate` block to define an ephemeral agent running in a Kubernetes pod as the node for this pipeline. This takes the place of the Docker container we used previously. --- vars/applyConfigPolicy.groovy | 39 ++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/vars/applyConfigPolicy.groovy b/vars/applyConfigPolicy.groovy index bea6eac..e879f4e 100644 --- a/vars/applyConfigPolicy.groovy +++ b/vars/applyConfigPolicy.groovy @@ -1,11 +1,7 @@ +// vim: set sw=4 ts=4 sts=4 et : import groovy.transform.Field import org.jenkinsci.plugins.pipeline.modeldefinition.Utils -@Field -def DOCKER_ARGS = '''\ --v /etc/ssh/ssh_known_hosts:/etc/ssh/ssh_known_hosts:ro -''' - def call(rw_limit, stages) { properties([ pipelineTriggers([cron('H H * * *')]) @@ -13,19 +9,28 @@ def call(rw_limit, stages) { timeout(time: 1, unit: 'HOURS') { lock('cfgpol') { - node { - checkout scm - docker.build("configpolicy", 'ci').inside(DOCKER_ARGS) { + podTemplate(containers: [ + containerTemplate( + name: 'ansible', + image: 'git.pyrocufflink.net/containerimages/ansible', + command: 'sleep', + args: 'infinity', + ) + ]) { + node(POD_LABEL) { + checkout scm withEnv(["KRB5CCNAME=${WORKSPACE}/.krb5cc"]) { - try { - stageKinit() - stageRemountRW(rw_limit) - generateStages(stages) - stageRemountRO(rw_limit) - } catch (err) { - postFailure(err) - } finally { - postCleanup() + container('ansible') { + try { + stageKinit() + stageRemountRW(rw_limit) + generateStages(stages) + stageRemountRO(rw_limit) + } catch (err) { + postFailure(err) + } finally { + postCleanup() + } } } }