_jenkins.tpl 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. {{- define "jenkins.workload" -}}
  2. workload:
  3. jenkins:
  4. enabled: true
  5. primary: true
  6. type: Deployment
  7. podSpec:
  8. hostNetwork: {{ .Values.jenkinsNetwork.hostNetwork }}
  9. securityContext:
  10. fsGroup: 1000
  11. containers:
  12. jenkins:
  13. enabled: true
  14. primary: true
  15. imageSelector: image
  16. securityContext:
  17. runAsUser: 1000
  18. runAsGroup: 1000
  19. {{ $config := (include "jenkins.configuration" $ | fromYaml).opts }}
  20. env:
  21. JENKINS_SLAVE_AGENT_PORT: {{ .Values.jenkinsNetwork.agentPort }}
  22. JENKINS_JAVA_OPTS: {{ join " " $config.jenkinsJavaOpts }}
  23. JENKINS_OPTS: {{ join " " $config.jenkinsOpts }}
  24. {{ with .Values.jenkinsConfig.additionalEnvs }}
  25. envList:
  26. {{ range $env := . }}
  27. - name: {{ $env.name }}
  28. value: {{ $env.value }}
  29. {{ end }}
  30. {{ end }}
  31. {{ $scheme := "http" }}
  32. {{ if .Values.jenkinsNetwork.certificateID }}
  33. {{ $scheme = "https" }}
  34. {{ end }}
  35. probes:
  36. liveness:
  37. enabled: true
  38. type: {{ $scheme }}
  39. port: {{ .Values.jenkinsNetwork.webPort }}
  40. path: /login
  41. readiness:
  42. enabled: true
  43. type: {{ $scheme }}
  44. port: {{ .Values.jenkinsNetwork.webPort }}
  45. path: /login
  46. startup:
  47. enabled: true
  48. type: {{ $scheme }}
  49. port: {{ .Values.jenkinsNetwork.webPort }}
  50. path: /login
  51. initContainers:
  52. {{- include "ix.v1.common.app.permissions" (dict "containerName" "01-permissions"
  53. "UID" 1000
  54. "GID" 1000
  55. "mode" "check"
  56. "type" "install") | nindent 8 }}
  57. {{- if .Values.jenkinsNetwork.certificateID }}
  58. 02-cert-container:
  59. {{- include "jenkins.certContainer" $ | nindent 10 }}
  60. {{- end }}
  61. {{/* Service */}}
  62. service:
  63. jenkins:
  64. enabled: true
  65. primary: true
  66. type: NodePort
  67. targetSelector: jenkins
  68. ports:
  69. web:
  70. enabled: true
  71. primary: true
  72. port: {{ .Values.jenkinsNetwork.webPort }}
  73. nodePort: {{ .Values.jenkinsNetwork.webPort }}
  74. targetSelector: jenkins
  75. agent:
  76. enabled: {{ .Values.jenkinsNetwork.agent }}
  77. primary: false
  78. type: NodePort
  79. targetSelector: jenkins
  80. ports:
  81. agent:
  82. enabled: {{ .Values.jenkinsNetwork.agent }}
  83. primary: true
  84. port: {{ .Values.jenkinsNetwork.agentPort }}
  85. nodePort: {{ .Values.jenkinsNetwork.agentPort }}
  86. targetSelector: jenkins
  87. {{/* Persistence */}}
  88. persistence:
  89. home:
  90. enabled: true
  91. {{- include "jenkins.storage.ci.migration" (dict "storage" .Values.jenkinsStorage.home) }}
  92. {{- include "ix.v1.common.app.storageOptions" (dict "storage" .Values.jenkinsStorage.home) | nindent 4 }}
  93. targetSelector:
  94. jenkins:
  95. jenkins:
  96. mountPath: /var/jenkins_home
  97. {{- if and (eq .Values.jenkinsStorage.home.type "ixVolume")
  98. (not (.Values.jenkinsStorage.home.ixVolumeConfig | default dict).aclEnable) }}
  99. 01-permissions:
  100. mountPath: /mnt/directories/jenkins_home
  101. {{- end }}
  102. 02-cert-container:
  103. mountPath: /var/jenkins_home
  104. tmp:
  105. enabled: true
  106. type: emptyDir
  107. targetSelector:
  108. jenkins:
  109. jenkins:
  110. mountPath: /tmp
  111. 02-cert-container:
  112. mountPath: /tmp
  113. {{- range $idx, $storage := .Values.jenkinsStorage.additionalStorages }}
  114. {{ printf "jenkins-%v:" (int $idx) }}
  115. enabled: true
  116. {{- include "jenkins.storage.ci.migration" (dict "storage" $storage) }}
  117. {{- include "ix.v1.common.app.storageOptions" (dict "storage" $storage) | nindent 4 }}
  118. targetSelector:
  119. jenkins:
  120. jenkins:
  121. mountPath: {{ $storage.mountPath }}
  122. {{- if and (eq $storage.type "ixVolume") (not ($storage.ixVolumeConfig | default dict).aclEnable) }}
  123. 01-permissions:
  124. mountPath: /mnt/directories{{ $storage.mountPath }}
  125. {{- end }}
  126. {{- end }}
  127. {{- if .Values.jenkinsNetwork.certificateID }}
  128. cert:
  129. enabled: true
  130. type: secret
  131. objectName: jenkins-cert
  132. defaultMode: "0600"
  133. items:
  134. - key: tls.key
  135. path: {{ .Values.jenkinsConstants.keyName }}
  136. - key: tls.crt
  137. path: {{ .Values.jenkinsConstants.crtName }}
  138. targetSelector:
  139. jenkins:
  140. 02-cert-container:
  141. mountPath: {{ .Values.jenkinsConstants.certsPath }}
  142. readOnly: true
  143. scaleCertificate:
  144. jenkins-cert:
  145. enabled: true
  146. id: {{ .Values.jenkinsNetwork.certificateID }}
  147. {{- end -}}
  148. {{- end -}}
  149. {{/* TODO: Remove on the next version bump, eg 1.2.0+ */}}
  150. {{- define "jenkins.storage.ci.migration" -}}
  151. {{- $storage := .storage -}}
  152. {{- if $storage.hostPath -}}
  153. {{- $_ := set $storage "hostPathConfig" dict -}}
  154. {{- $_ := set $storage.hostPathConfig "hostPath" $storage.hostPath -}}
  155. {{- end -}}
  156. {{- end -}}