[DO-1444] change_podtemplate (#51)
Co-authored-by: Rustam Tagaev <rustam.tagaev@avroid.tech> Reviewed-on: https://git.avroid.tech/DevOps/jenkins-shared-lib/pulls/51 Reviewed-by: Denis Patrakeev <denis.patrakeev@avroid.team> Reviewed-by: Aleksandr Vodyanov <aleksandr.vodyanov@avroid.team>
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
package tech.avroid.kube
|
||||
|
||||
|
||||
class PodTemplates implements Serializable {
|
||||
String registry
|
||||
Object script
|
||||
String cloud
|
||||
List dockerCreds
|
||||
|
||||
public PodTemplates(script, String registry, List dockerCreds) {
|
||||
// TODO: delete default cloud after k8s cluster migration
|
||||
public PodTemplates(script, String registry, List dockerCreds, String cloud='avroid') {
|
||||
this.script = script
|
||||
this.cloud = cloud
|
||||
this.registry = registry
|
||||
this.dockerCreds = dockerCreds
|
||||
}
|
||||
@@ -22,6 +23,7 @@ class PodTemplates implements Serializable {
|
||||
|
||||
public void jnlp(imageVersion='jdk17', body) {
|
||||
this.script.podTemplate(
|
||||
cloud: this.cloud,
|
||||
containers: [
|
||||
this.script.containerTemplate(
|
||||
alwaysPullImage: true,
|
||||
@@ -42,6 +44,7 @@ class PodTemplates implements Serializable {
|
||||
volumes: [
|
||||
this.script.emptyDirVolume(memory: false, mountPath: '/tmp'),
|
||||
this.script.emptyDirVolume(memory: false, mountPath: '/home/jenkins/.cache'),
|
||||
this.script.emptyDirVolume(memory: false, mountPath: '/home/jenkins/.ssh'),
|
||||
this.script.emptyDirVolume(memory: false, mountPath: '/home/jenkins/.npm'),
|
||||
this.script.emptyDirVolume(memory: false, mountPath: '/home/jenkins/.config'),
|
||||
this.script.emptyDirVolume(memory: false, mountPath: '/home/jenkins/.composer'),
|
||||
@@ -59,6 +62,7 @@ class PodTemplates implements Serializable {
|
||||
public void poetry(imageVersion='1.8.4', body) {
|
||||
this.script.podTemplate(
|
||||
imagePullSecrets: this.dockerCreds,
|
||||
cloud: this.cloud,
|
||||
containers: [
|
||||
this.script.containerTemplate(
|
||||
alwaysPullImage: true,
|
||||
@@ -94,11 +98,12 @@ class PodTemplates implements Serializable {
|
||||
public void docker(imageVersion='27.3.1-dind',body) {
|
||||
this.script.podTemplate(
|
||||
imagePullSecrets: this.dockerCreds,
|
||||
cloud: this.cloud,
|
||||
containers: [
|
||||
this.script.containerTemplate(
|
||||
alwaysPullImage: true,
|
||||
name: 'docker',
|
||||
image: "${registry}/docker-hub-proxy/docker:${imageVersion}",
|
||||
image: "${this.registry}/docker-hub-proxy/docker:${imageVersion}",
|
||||
envVars: [
|
||||
this.script.containerEnvVar(key: 'HOME', value: '/home/jenkins'),
|
||||
],
|
||||
@@ -129,11 +134,15 @@ class PodTemplates implements Serializable {
|
||||
|
||||
public void git(imageVersion='v2.45.2', body) {
|
||||
this.script.podTemplate(
|
||||
runAsUser: "1000",
|
||||
runAsGroup: "1000",
|
||||
imagePullSecrets: this.dockerCreds,
|
||||
cloud: this.cloud,
|
||||
containers: [
|
||||
this.script.containerTemplate(
|
||||
alwaysPullImage: true,
|
||||
name: 'git',
|
||||
image: "${registry}/docker-hub-proxy/alpine/git:${imageVersion}",
|
||||
image: "${this.registry}/devops/git:${imageVersion}",
|
||||
envVars: [
|
||||
this.script.containerEnvVar(key: 'HOME', value: '/home/jenkins'),
|
||||
],
|
||||
@@ -162,11 +171,12 @@ class PodTemplates implements Serializable {
|
||||
public void helm(imageVersion='3.16.3', body) {
|
||||
this.script.podTemplate(
|
||||
serviceAccount: 'jenkins-deploy',
|
||||
cloud: this.cloud,
|
||||
containers: [
|
||||
this.script.containerTemplate(
|
||||
alwaysPullImage: true,
|
||||
name: 'helm',
|
||||
image: "${registry}/docker-hub-proxy/alpine/helm:${imageVersion}",
|
||||
image: "${this.registry}/docker-hub-proxy/alpine/helm:${imageVersion}",
|
||||
envVars: [
|
||||
this.script.containerEnvVar(key: 'HOME', value: '/home/jenkins'),
|
||||
],
|
||||
@@ -195,12 +205,13 @@ class PodTemplates implements Serializable {
|
||||
public void kubectl(imageVersion='1.31.3', body) {
|
||||
this.script.podTemplate(
|
||||
serviceAccount: 'jenkins-deploy',
|
||||
cloud: this.cloud,
|
||||
runAsUser: "0",
|
||||
containers: [
|
||||
this.script.containerTemplate(
|
||||
alwaysPullImage: true,
|
||||
name: 'kubectl',
|
||||
image: "${registry}/docker-hub-proxy/bitnami/kubectl:${imageVersion}",
|
||||
image: "${this.registry}/docker-hub-proxy/bitnami/kubectl:${imageVersion}",
|
||||
envVars: [
|
||||
this.script.containerEnvVar(key: 'HOME', value: '/home/jenkins'),
|
||||
],
|
||||
@@ -229,6 +240,7 @@ class PodTemplates implements Serializable {
|
||||
public void nodejs(imageVersion='18.16-alpine3.18', body) {
|
||||
this.script.podTemplate(
|
||||
runAsUser: "0",
|
||||
cloud: this.cloud,
|
||||
imagePullSecrets: this.dockerCreds,
|
||||
containers: [
|
||||
this.script.containerTemplate(
|
||||
|
||||
Reference in New Issue
Block a user