_jenkins.tpl 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. values: {{ $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" "init") | 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. type: {{ .Values.jenkinsStorage.home.type }}
  92. datasetName: {{ .Values.jenkinsStorage.home.datasetName | default "" }}
  93. hostPath: {{ .Values.jenkinsStorage.home.hostPath | default "" }}
  94. targetSelector:
  95. jenkins:
  96. jenkins:
  97. mountPath: /var/jenkins_home
  98. 01-permissions:
  99. mountPath: /mnt/directories/home
  100. 02-cert-container:
  101. mountPath: /var/jenkins_home
  102. tmp:
  103. enabled: true
  104. type: emptyDir
  105. targetSelector:
  106. jenkins:
  107. jenkins:
  108. mountPath: /tmp
  109. 02-cert-container:
  110. mountPath: /tmp
  111. {{- range $idx, $storage := .Values.jenkinsStorage.additionalStorages }}
  112. {{ printf "jenkins-%v" (int $idx) }}:
  113. enabled: true
  114. type: {{ $storage.type }}
  115. datasetName: {{ $storage.datasetName | default "" }}
  116. hostPath: {{ $storage.hostPath | default "" }}
  117. targetSelector:
  118. jenkins:
  119. jenkins:
  120. mountPath: {{ $storage.mountPath }}
  121. 01-permissions:
  122. mountPath: /mnt/directories{{ $storage.mountPath }}
  123. {{- end }}
  124. {{- if .Values.jenkinsNetwork.certificateID }}
  125. cert:
  126. enabled: true
  127. type: secret
  128. objectName: jenkins-cert
  129. defaultMode: "0600"
  130. items:
  131. - key: tls.key
  132. path: {{ .Values.jenkinsConstants.keyName }}
  133. - key: tls.crt
  134. path: {{ .Values.jenkinsConstants.crtName }}
  135. targetSelector:
  136. jenkins:
  137. 02-cert-container:
  138. mountPath: {{ .Values.jenkinsConstants.certsPath }}
  139. readOnly: true
  140. scaleCertificate:
  141. jenkins-cert:
  142. enabled: true
  143. id: {{ .Values.jenkinsNetwork.certificateID }}
  144. {{- end -}}
  145. {{- end -}}