1
0

Fix #8: Make the containers in the jenkins pod template configurable through values

This commit is contained in:
Fleur Kelpin 2018-06-29 12:34:52 +02:00
parent 3eec43fad5
commit 1d1035c51d
3 changed files with 85 additions and 164 deletions

View File

@ -1,6 +1,6 @@
name: molgenis-jenkins name: molgenis-jenkins
home: https://jenkins.io/ home: https://jenkins.io/
version: 0.2.3 version: 0.2.4
appVersion: 2.107 appVersion: 2.107
description: Molgenis installation for the jenkins chart. description: Molgenis installation for the jenkins chart.
sources: sources:

View File

@ -28,23 +28,23 @@ data:
<org.csanchez.jenkins.plugins.kubernetes.KubernetesCloud plugin="kubernetes@{{ template "jenkins.kubernetes-version" . }}"> <org.csanchez.jenkins.plugins.kubernetes.KubernetesCloud plugin="kubernetes@{{ template "jenkins.kubernetes-version" . }}">
<name>kubernetes</name> <name>kubernetes</name>
<templates> <templates>
{{- if .Values.Agent.Enabled }} {{- range $podName, $pod := .Values.Pods }}
<org.csanchez.jenkins.plugins.kubernetes.PodTemplate> <org.csanchez.jenkins.plugins.kubernetes.PodTemplate>
<inheritFrom></inheritFrom> <inheritFrom></inheritFrom>
<name>default</name> <name>{{ $podName }}</name>
<instanceCap>2147483647</instanceCap> <instanceCap>2147483647</instanceCap>
<idleMinutes>0</idleMinutes> <idleMinutes>0</idleMinutes>
<label>{{ .Release.Name }}-{{ .Values.Agent.Component }}</label> <label>{{ $.Release.Name }}-{{ $pod.Label }}</label>
<nodeSelector> <nodeSelector>
{{- $local := dict "first" true }} {{- $local := dict "first" true }}
{{- range $key, $value := .Values.Agent.NodeSelector }} {{- range $key, $value := $pod.NodeSelector }}
{{- if not $local.first }},{{- end }} {{- if not $local.first }},{{- end }}
{{- $key }}={{ $value }} {{- $key }}={{ $value }}
{{- $_ := set $local "first" false }} {{- $_ := set $local "first" false }}
{{- end }}</nodeSelector> {{- end }}</nodeSelector>
<nodeUsageMode>EXCLUSIVE</nodeUsageMode> <nodeUsageMode>$pod.NodeUsageMode</nodeUsageMode>
<volumes> <volumes>
{{- range $index, $volume := .Values.Agent.volumes }} {{- range $index, $volume := $pod.volumes }}
<org.csanchez.jenkins.plugins.kubernetes.volumes.{{ $volume.type }}Volume> <org.csanchez.jenkins.plugins.kubernetes.volumes.{{ $volume.type }}Volume>
{{- range $key, $value := $volume }}{{- if not (eq $key "type") }} {{- range $key, $value := $volume }}{{- if not (eq $key "type") }}
<{{ $key }}>{{ $value }}</{{ $key }}> <{{ $key }}>{{ $value }}</{{ $key }}>
@ -53,153 +53,59 @@ data:
{{- end }} {{- end }}
</volumes> </volumes>
<containers> <containers>
{{- range $containerName, $container := $pod.Containers }}
<org.csanchez.jenkins.plugins.kubernetes.ContainerTemplate> <org.csanchez.jenkins.plugins.kubernetes.ContainerTemplate>
<name>jnlp</name> <name>{{ $containerName }}</name>
<image>{{ .Values.Agent.Image }}:{{ .Values.Agent.ImageTag }}</image> <image>{{ $container.Image }}:{{ $container.ImageTag | default "latest" }}</image>
{{- if .Values.Agent.Privileged }} {{- if $container.Privileged }}
<privileged>true</privileged> <privileged>true</privileged>
{{- else }} {{- else }}
<privileged>false</privileged> <privileged>false</privileged>
{{- end }} {{- end }}
<alwaysPullImage>{{ .Values.Agent.AlwaysPullImage }}</alwaysPullImage> {{- if $container.AlwaysPullImage }}
<workingDir>/home/jenkins</workingDir> <alwaysPullImage>true</alwaysPullImage>
<command></command>
<args>${computer.jnlpmac} ${computer.name}</args>
<ttyEnabled>false</ttyEnabled>
<resourceRequestCpu>{{.Values.Agent.Cpu}}</resourceRequestCpu>
<resourceRequestMemory>{{.Values.Agent.Memory}}</resourceRequestMemory>
<resourceLimitCpu>{{.Values.Agent.Cpu}}</resourceLimitCpu>
<resourceLimitMemory>{{.Values.Agent.Memory}}</resourceLimitMemory>
<envVars>
<org.csanchez.jenkins.plugins.kubernetes.ContainerEnvVar>
<key>JENKINS_URL</key>
<value>http://{{ template "jenkins.fullname" . }}:{{.Values.Master.ServicePort}}{{ default "" .Values.Master.JenkinsUriPrefix }}</value>
</org.csanchez.jenkins.plugins.kubernetes.ContainerEnvVar>
</envVars>
</org.csanchez.jenkins.plugins.kubernetes.ContainerTemplate>
</containers>
<envVars/>
<annotations/>
{{- if .Values.Agent.ImagePullSecret }}
<imagePullSecrets>
<org.csanchez.jenkins.plugins.kubernetes.PodImagePullSecret>
<name>{{ .Values.Agent.ImagePullSecret }}</name>
</org.csanchez.jenkins.plugins.kubernetes.PodImagePullSecret>
</imagePullSecrets>
{{- else }} {{- else }}
<imagePullSecrets/>
{{- end }}
<nodeProperties/>
</org.csanchez.jenkins.plugins.kubernetes.PodTemplate>
{{- end -}}
{{- if .Values.Pod.Enabled }}
<org.csanchez.jenkins.plugins.kubernetes.PodTemplate>
<inheritFrom></inheritFrom>
<name>{{ .Values.Pod.Label }}</name>
<instanceCap>2147483647</instanceCap>
<idleMinutes>0</idleMinutes>
<label>{{ .Values.Pod.Label }}</label>
<nodeSelector>
{{- $local := dict "first" true }}
{{- range $key, $value := .Values.Pod.NodeSelector }}
{{- if not $local.first }},{{- end }}
{{- $key }}={{ $value }}
{{- $_ := set $local "first" false }}
{{- end }}</nodeSelector>
<nodeUsageMode>NORMAL</nodeUsageMode>
<volumes>
{{- range $index, $volume := .Values.Pod.volumes }}
<org.csanchez.jenkins.plugins.kubernetes.volumes.{{ $volume.type }}Volume>
{{- range $key, $value := $volume }}{{- if not (eq $key "type") }}
<{{ $key }}>{{ $value }}</{{ $key }}>
{{- end }}{{- end }}
</org.csanchez.jenkins.plugins.kubernetes.volumes.{{ $volume.type }}Volume>
{{- end }}
</volumes>
<containers>
<org.csanchez.jenkins.plugins.kubernetes.ContainerTemplate>
<name>{{ .Values.Pod.Label }}</name>
<image>{{ .Values.Pod.Image }}:{{ .Values.Pod.ImageTag }}</image>
{{- if .Values.Pod.Privileged }}
<privileged>true</privileged>
{{- else }}
<privileged>false</privileged>
{{- end }}
<alwaysPullImage>{{ .Values.Pod.AlwaysPullImage }}</alwaysPullImage>
<workingDir>/home/jenkins</workingDir>
<command>{{ .Values.Pod.Command }}</command>
<args>{{ .Values.Pod.Args }}</args>
{{- if .Values.Pod.TTY }}
<ttyEnabled>true</ttyEnabled>
{{- else }}
<ttyEnabled>false</ttyEnabled>
{{- end }}
<resourceRequestCpu>{{.Values.Pod.Cpu}}</resourceRequestCpu>
<resourceRequestMemory>{{.Values.Pod.Memory}}</resourceRequestMemory>
<resourceLimitCpu>{{.Values.Pod.Cpu}}</resourceLimitCpu>
<resourceLimitMemory>{{.Values.Pod.Memory}}</resourceLimitMemory>
</org.csanchez.jenkins.plugins.kubernetes.ContainerTemplate>
<org.csanchez.jenkins.plugins.kubernetes.ContainerTemplate>
<name>alpine</name>
<image>spotify/alpine</image>
<privileged>false</privileged>
<alwaysPullImage>false</alwaysPullImage> <alwaysPullImage>false</alwaysPullImage>
{{- end }}
<workingDir>/home/jenkins</workingDir> <workingDir>/home/jenkins</workingDir>
<command>/bin/sh -c</command> <command>{{ $container.Command | default "cat" }}</command>
<args>cat</args> <args>{{ $container.Args | default "" }}</args>
{{- if $container.TTY }}
<ttyEnabled>true</ttyEnabled> <ttyEnabled>true</ttyEnabled>
<resourceRequestCpu></resourceRequestCpu> {{- else }}
<resourceRequestMemory></resourceRequestMemory> <ttyEnabled>false</ttyEnabled>
<resourceLimitCpu></resourceLimitCpu> {{- end }}
<resourceLimitMemory></resourceLimitMemory> {{- if $container.resources }}
<ports/> {{- if $container.resources.requests }}
<livenessProbe> <resourceRequestCpu>{{ $container.resources.requests.cpu | default "" }}</resourceRequestCpu>
<execArgs></execArgs> <resourceRequestMemory>{{ $container.resources.requests.memory | default "" }}</resourceRequestMemory>
<timeoutSeconds>0</timeoutSeconds> {{- end }}
<initialDelaySeconds>0</initialDelaySeconds> {{- if $container.resources.limits }}
<failureThreshold>0</failureThreshold> <resourceLimitCpu>{{ $container.resources.limits.cpu | default "" }}</resourceLimitCpu>
<periodSeconds>0</periodSeconds> <resourceLimitMemory>{{ $container.resources.limits.memory | default "" }}</resourceLimitMemory>
<successThreshold>0</successThreshold> {{- end }}
</livenessProbe> {{- end }}
</org.csanchez.jenkins.plugins.kubernetes.ContainerTemplate> </org.csanchez.jenkins.plugins.kubernetes.ContainerTemplate>
{{- end }}
</containers> </containers>
<envVars>
<envVars> <envVars>
<org.csanchez.jenkins.plugins.kubernetes.model.KeyValueEnvVar> <org.csanchez.jenkins.plugins.kubernetes.model.KeyValueEnvVar>
<key>JENKINS_URL</key> <key>JENKINS_URL</key>
<value>http://{{ template "jenkins.fullname" . }}:{{.Values.Master.ServicePort}}{{ default "" .Values.Master.JenkinsUriPrefix }}</value> <value>http://{{ template "jenkins.fullname" $ }}:{{$.Values.Master.ServicePort}}{{ default "" $.Values.Master.JenkinsUriPrefix }}</value>
</org.csanchez.jenkins.plugins.kubernetes.model.KeyValueEnvVar> </org.csanchez.jenkins.plugins.kubernetes.model.KeyValueEnvVar>
</envVars> {{- range $index, $envVar := $pod.EnvVars }}
<org.csanchez.jenkins.plugins.kubernetes.model.SecretEnvVar> <org.csanchez.jenkins.plugins.kubernetes.model.{{ $envVar.type }}EnvVar>
<key>PGP_PASSPHRASE</key> {{- range $key, $value := $envVar }}{{- if not (eq $key "type") }}
<secretName>molgenis-pipeline-env-secret</secretName> <{{ $key }}>{{ $value }}</{{ $key }}>
<secretKey>pgpPassphrase</secretKey> {{- end }}{{- end }}
</org.csanchez.jenkins.plugins.kubernetes.model.SecretEnvVar> </org.csanchez.jenkins.plugins.kubernetes.model.{{ $envVar.type }}EnvVar>
<org.csanchez.jenkins.plugins.kubernetes.model.KeyValueEnvVar> {{- end }}
<key>PGP_SECRETKEY</key>
<value>keyfile:/root/.m2/key.asc</value>
</org.csanchez.jenkins.plugins.kubernetes.model.KeyValueEnvVar>
<org.csanchez.jenkins.plugins.kubernetes.model.SecretEnvVar>
<key>SONAR_TOKEN</key>
<secretName>molgenis-pipeline-env-secret</secretName>
<secretKey>sonarToken</secretKey>
</org.csanchez.jenkins.plugins.kubernetes.model.SecretEnvVar>
<org.csanchez.jenkins.plugins.kubernetes.model.SecretEnvVar>
<key>CODECOV_TOKEN</key>
<secretName>molgenis-pipeline-env-secret</secretName>
<secretKey>codecovToken</secretKey>
</org.csanchez.jenkins.plugins.kubernetes.model.SecretEnvVar>
<org.csanchez.jenkins.plugins.kubernetes.model.SecretEnvVar>
<key>GITHUB_TOKEN</key>
<secretName>molgenis-pipeline-env-secret</secretName>
<secretKey>githubToken</secretKey>
</org.csanchez.jenkins.plugins.kubernetes.model.SecretEnvVar>
</envVars> </envVars>
<annotations/> <annotations/>
{{- if .Values.Pod.ImagePullSecret }} {{- if $pod.ImagePullSecret }}
<imagePullSecrets> <imagePullSecrets>
<org.csanchez.jenkins.plugins.kubernetes.PodImagePullSecret> <org.csanchez.jenkins.plugins.kubernetes.PodImagePullSecret>
<name>{{ .Values.Pod.ImagePullSecret }}</name> <name>{{ $pod.ImagePullSecret }}</name>
</org.csanchez.jenkins.plugins.kubernetes.PodImagePullSecret> </org.csanchez.jenkins.plugins.kubernetes.PodImagePullSecret>
</imagePullSecrets> </imagePullSecrets>
{{- else }} {{- else }}
@ -207,7 +113,7 @@ data:
{{- end }} {{- end }}
<nodeProperties/> <nodeProperties/>
</org.csanchez.jenkins.plugins.kubernetes.PodTemplate> </org.csanchez.jenkins.plugins.kubernetes.PodTemplate>
{{- end -}} {{- end }}
</templates> </templates>
<serverUrl>https://kubernetes.default</serverUrl> <serverUrl>https://kubernetes.default</serverUrl>
<skipTlsVerify>false</skipTlsVerify> <skipTlsVerify>false</skipTlsVerify>

View File

@ -82,25 +82,10 @@ jenkins:
CustomConfigMap: true CustomConfigMap: true
rbac: rbac:
install: true install: true
# A second pod template for maven builds Pods:
Pod: default:
Enabled: true Label: "default"
Image: "webhost12.service.rug.nl/molgenis/molgenis-maven" NodeUsageMode: NORMAL
ImageTag: latest
# ImagePullSecret: jenkins
Label: "molgenis-maven"
Privileged: false
Cpu: ""
Memory: ""
# You may want to change this to true while testing a new image
AlwaysPullImage: false
Command: "/bin/sh -c"
Args: "cat"
TTY: true
# You can define the volumes that you want to mount for this container
# Allowed types are: ConfigMap, EmptyDir, HostPath, Nfs, Pod, Secret
# Configure the attributes as they appear in the corresponding Java class for that type
# https://github.com/jenkinsci/kubernetes-plugin/tree/master/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes
volumes: volumes:
- type: HostPath - type: HostPath
hostPath: "/var/run/docker.sock" hostPath: "/var/run/docker.sock"
@ -108,9 +93,39 @@ jenkins:
- type: Secret - type: Secret
secretName: molgenis-pipeline-file-secret secretName: molgenis-pipeline-file-secret
mountPath: "/root/.m2" mountPath: "/root/.m2"
Containers:
maven:
Image: "webhost12.service.rug.nl/molgenis/molgenis-maven"
resources:
requests:
cpu: "1000m"
limits:
memory: "1Gi"
alpine:
Image: "spotify/alpine"
EnvVars:
- type: Secret
key: PGP_PASSPHRASE
secretName: molgenis-pipeline-env-secret
secretKey: pgpPassphrase
- type: KeyValue
key: PGP_SECRETKEY
value: "keyfile:/root/.m2/key.asc"
- type: Secret
key: SONAR_TOKEN
secretName: molgenis-pipeline-env-secret
secretKey: sonarToken
- type: Secret
key: CODECOV_TOKEN
secretName: molgenis-pipeline-env-secret
secretKey: codecovToken
- type: Secret
key: GITHUB_TOKEN
secretName: molgenis-pipeline-env-secret
secretKey: githubToken
# If needed
# ImagePullSecret: jenkins
NodeSelector: {} NodeSelector: {}
# Key Value selectors. Ex:
# jenkins-agent: v1
PipelineSecrets: PipelineSecrets:
Env: Env:
# Set to false to keep existing secret # Set to false to keep existing secret