| Giorgi Lekveishvili | ee15ee2 | 2024-03-28 12:35:10 +0400 | [diff] [blame] | 1 | {{- $root := . -}} |
| 2 | |
| 3 | apiVersion: apps/v1 |
| 4 | kind: StatefulSet |
| 5 | metadata: |
| 6 | name: {{ .Release.Name }}-gerrit-stateful-set |
| 7 | labels: |
| 8 | app.kubernetes.io/component: gerrit |
| 9 | app.kubernetes.io/instance: {{ .Release.Name }} |
| 10 | chart: {{ template "gerrit.chart" . }} |
| 11 | heritage: {{ .Release.Service }} |
| 12 | release: {{ .Release.Name }} |
| 13 | {{- if .Values.additionalLabels }} |
| 14 | {{ toYaml .Values.additionalLabels | indent 4 }} |
| 15 | {{- end }} |
| 16 | spec: |
| 17 | serviceName: {{ .Release.Name }}-gerrit-service |
| 18 | replicas: {{ .Values.gerrit.replicas }} |
| 19 | updateStrategy: |
| 20 | rollingUpdate: |
| 21 | partition: {{ .Values.gerrit.updatePartition }} |
| 22 | selector: |
| 23 | matchLabels: |
| 24 | app.kubernetes.io/component: gerrit |
| 25 | app.kubernetes.io/instance: {{ .Release.Name }} |
| 26 | template: |
| 27 | metadata: |
| 28 | labels: |
| 29 | app.kubernetes.io/component: gerrit |
| 30 | app.kubernetes.io/instance: {{ .Release.Name }} |
| 31 | chart: {{ template "gerrit.chart" . }} |
| 32 | heritage: {{ .Release.Service }} |
| 33 | release: {{ .Release.Name }} |
| 34 | {{- if .Values.additionalLabels }} |
| 35 | {{ toYaml .Values.additionalLabels | indent 8 }} |
| 36 | {{- end }} |
| 37 | {{- if .Values.gerrit.additionalPodLabels }} |
| 38 | {{ toYaml .Values.gerrit.additionalPodLabels | indent 8 }} |
| 39 | {{- end }} |
| 40 | annotations: |
| 41 | chartRevision: "{{ .Release.Revision }}" |
| 42 | {{- if .Values.gerrit.additionalAnnotations }} |
| 43 | {{ toYaml .Values.gerrit.additionalAnnotations | indent 8 }} |
| 44 | {{- end }} |
| 45 | spec: |
| 46 | {{- with .Values.gerrit.tolerations }} |
| 47 | tolerations: |
| 48 | {{- toYaml . | nindent 8 }} |
| 49 | {{- end }} |
| 50 | {{- with .Values.gerrit.topologySpreadConstraints }} |
| 51 | topologySpreadConstraints: |
| 52 | {{- toYaml . | nindent 8 }} |
| 53 | {{- end }} |
| 54 | {{- with .Values.gerrit.nodeSelector }} |
| 55 | nodeSelector: |
| 56 | {{- toYaml . | nindent 8 }} |
| 57 | {{- end }} |
| 58 | {{- with .Values.gerrit.affinity }} |
| 59 | affinity: |
| 60 | {{- toYaml . | nindent 8 }} |
| 61 | {{- end }} |
| 62 | {{- with .Values.gerrit.priorityClassName }} |
| 63 | priorityClassName: {{ . }} |
| 64 | {{- end }} |
| 65 | terminationGracePeriodSeconds: {{ .Values.gerrit.gracefulStopTimeout }} |
| 66 | securityContext: |
| 67 | fsGroup: 100 |
| 68 | {{ if .Values.images.registry.ImagePullSecret.name -}} |
| 69 | imagePullSecrets: |
| 70 | - name: {{ .Values.images.registry.ImagePullSecret.name }} |
| 71 | {{- range .Values.images.additionalImagePullSecrets }} |
| 72 | - name: {{ . }} |
| 73 | {{- end }} |
| 74 | {{- end }} |
| 75 | initContainers: |
| 76 | {{- if and .Values.nfsWorkaround.enabled .Values.nfsWorkaround.chownOnStartup }} |
| 77 | - name: nfs-init |
| 78 | image: {{ .Values.images.busybox.registry -}}/busybox:{{- .Values.images.busybox.tag }} |
| 79 | command: |
| 80 | - sh |
| 81 | - -c |
| 82 | args: |
| 83 | - | |
| 84 | chown 1000:100 /var/mnt/logs |
| 85 | chown 1000:100 /var/mnt/git |
| 86 | env: |
| 87 | - name: POD_NAME |
| 88 | valueFrom: |
| 89 | fieldRef: |
| 90 | fieldPath: metadata.name |
| 91 | volumeMounts: |
| 92 | - name: logs |
| 93 | subPathExpr: "gerrit-replica/$(POD_NAME)" |
| 94 | mountPath: "/var/mnt/logs" |
| 95 | - name: git-repositories |
| 96 | mountPath: "/var/mnt/git" |
| 97 | {{- if .Values.nfsWorkaround.idDomain }} |
| 98 | - name: nfs-config |
| 99 | mountPath: "/etc/idmapd.conf" |
| 100 | subPath: idmapd.conf |
| 101 | {{- end }} |
| 102 | {{- end }} |
| 103 | - name: gerrit-init |
| 104 | image: {{ template "registry" . }}{{ .Values.gerrit.images.gerritInit }}:{{ .Values.images.version }} |
| 105 | imagePullPolicy: {{ .Values.images.imagePullPolicy }} |
| 106 | env: |
| 107 | - name: POD_NAME |
| 108 | valueFrom: |
| 109 | fieldRef: |
| 110 | fieldPath: metadata.name |
| 111 | volumeMounts: |
| 112 | - name: gerrit-site |
| 113 | mountPath: "/var/gerrit" |
| 114 | - name: git-repositories |
| 115 | mountPath: "/var/mnt/git" |
| 116 | - name: logs |
| 117 | subPathExpr: "gerrit/$(POD_NAME)" |
| 118 | mountPath: "/var/mnt/logs" |
| 119 | - name: gerrit-init-config |
| 120 | mountPath: "/var/config/gerrit-init.yaml" |
| 121 | subPath: gerrit-init.yaml |
| 122 | {{- if and .Values.nfsWorkaround.enabled .Values.nfsWorkaround.idDomain }} |
| 123 | - name: nfs-config |
| 124 | mountPath: "/etc/idmapd.conf" |
| 125 | subPath: idmapd.conf |
| 126 | {{- end }} |
| 127 | {{- if and .Values.gerrit.pluginManagement.cache.enabled }} |
| 128 | - name: gerrit-plugin-cache |
| 129 | mountPath: "/var/mnt/plugins" |
| 130 | {{- end }} |
| 131 | {{ if eq .Values.gerrit.index.type "elasticsearch" -}} |
| 132 | - name: gerrit-index-config |
| 133 | mountPath: "/var/mnt/index" |
| 134 | {{- end }} |
| 135 | - name: gerrit-config |
| 136 | mountPath: "/var/mnt/etc/config" |
| 137 | - name: gerrit-secure-config |
| 138 | mountPath: "/var/mnt/etc/secret" |
| 139 | {{ if .Values.caCert -}} |
| 140 | - name: tls-ca |
| 141 | subPath: ca.crt |
| 142 | mountPath: "/var/config/ca.crt" |
| 143 | {{- end }} |
| 144 | {{- range .Values.gerrit.additionalConfigMaps }} |
| 145 | - name: {{ .name }} |
| 146 | mountPath: "/var/mnt/data/{{ .subDir }}" |
| 147 | {{- end }} |
| 148 | containers: |
| 149 | - name: gerrit |
| 150 | image: {{ template "registry" . }}{{ .Values.gerrit.images.gerrit }}:{{ .Values.images.version }} |
| 151 | imagePullPolicy: {{ .Values.images.imagePullPolicy }} |
| 152 | env: |
| 153 | - name: POD_NAME |
| 154 | valueFrom: |
| 155 | fieldRef: |
| 156 | fieldPath: metadata.name |
| 157 | lifecycle: |
| 158 | preStop: |
| 159 | exec: |
| 160 | command: |
| 161 | - "/bin/ash" |
| 162 | - "-c" |
| 163 | - "kill -2 $(pidof java) && tail --pid=$(pidof java) -f /dev/null" |
| 164 | ports: |
| 165 | - name: gerrit-port |
| 166 | containerPort: 8080 |
| 167 | {{- if .Values.gerrit.service.ssh.enabled }} |
| 168 | - name: gerrit-ssh |
| 169 | containerPort: 29418 |
| 170 | {{- end }} |
| 171 | volumeMounts: |
| 172 | - name: gerrit-site |
| 173 | mountPath: "/var/gerrit" |
| 174 | - name: git-repositories |
| 175 | mountPath: "/var/mnt/git" |
| 176 | - name: logs |
| 177 | subPathExpr: "gerrit/$(POD_NAME)" |
| 178 | mountPath: "/var/mnt/logs" |
| 179 | {{- if and .Values.nfsWorkaround.enabled .Values.nfsWorkaround.idDomain }} |
| 180 | - name: nfs-config |
| 181 | mountPath: "/etc/idmapd.conf" |
| 182 | subPath: idmapd.conf |
| 183 | {{- end }} |
| 184 | {{ if eq .Values.gerrit.index.type "elasticsearch" -}} |
| 185 | - name: gerrit-index-config |
| 186 | mountPath: "/var/mnt/index" |
| 187 | {{- end }} |
| 188 | - name: gerrit-config |
| 189 | mountPath: "/var/mnt/etc/config" |
| 190 | - name: gerrit-secure-config |
| 191 | mountPath: "/var/mnt/etc/secret" |
| 192 | {{- range .Values.gerrit.additionalConfigMaps }} |
| 193 | - name: {{ .name }} |
| 194 | mountPath: "/var/mnt/data/{{ .subDir }}" |
| 195 | {{- end }} |
| 196 | resources: |
| 197 | {{ toYaml .Values.gerrit.resources | indent 10 }} |
| 198 | livenessProbe: |
| 199 | httpGet: |
| 200 | path: /config/server/healthcheck~status |
| 201 | port: gerrit-port |
| 202 | {{- if .Values.gerrit.probeScheme }} |
| 203 | scheme: {{ .Values.gerrit.probeScheme }} |
| 204 | {{- end }} |
| 205 | {{ toYaml .Values.gerrit.livenessProbe | indent 10 }} |
| 206 | readinessProbe: |
| 207 | httpGet: |
| 208 | path: /config/server/healthcheck~status |
| 209 | port: gerrit-port |
| 210 | {{- if .Values.gerrit.probeScheme }} |
| 211 | scheme: {{ .Values.gerrit.probeScheme }} |
| 212 | {{- end }} |
| 213 | {{ toYaml .Values.gerrit.readinessProbe | indent 10 }} |
| 214 | startupProbe: |
| 215 | httpGet: |
| 216 | path: /config/server/healthcheck~status |
| 217 | port: gerrit-port |
| 218 | {{- if .Values.gerrit.probeScheme }} |
| 219 | scheme: {{ .Values.gerrit.probeScheme }} |
| 220 | {{- end }} |
| 221 | {{ toYaml .Values.gerrit.startupProbe | indent 10 }} |
| 222 | volumes: |
| 223 | {{ if not .Values.gerrit.persistence.enabled -}} |
| 224 | - name: gerrit-site |
| 225 | emptyDir: {} |
| 226 | {{- end }} |
| 227 | {{- if and .Values.gerrit.pluginManagement.cache.enabled }} |
| 228 | - name: gerrit-plugin-cache |
| 229 | persistentVolumeClaim: |
| 230 | claimName: {{ .Release.Name }}-plugin-cache-pvc |
| 231 | {{- end }} |
| 232 | - name: git-repositories |
| 233 | persistentVolumeClaim: |
| 234 | {{- if .Values.gitRepositoryStorage.externalPVC.use }} |
| 235 | claimName: {{ .Values.gitRepositoryStorage.externalPVC.name }} |
| 236 | {{- else }} |
| 237 | claimName: {{ .Release.Name }}-git-repositories-pvc |
| 238 | {{- end }} |
| 239 | - name: logs |
| 240 | {{ if .Values.logStorage.enabled -}} |
| 241 | persistentVolumeClaim: |
| 242 | {{- if .Values.logStorage.externalPVC.use }} |
| 243 | claimName: {{ .Values.logStorage.externalPVC.name }} |
| 244 | {{- else }} |
| 245 | claimName: {{ .Release.Name }}-log-pvc |
| 246 | {{- end }} |
| 247 | {{ else -}} |
| 248 | emptyDir: {} |
| 249 | {{- end }} |
| 250 | - name: gerrit-init-config |
| 251 | configMap: |
| 252 | name: {{ .Release.Name }}-gerrit-init-configmap |
| 253 | {{ if eq .Values.gerrit.index.type "elasticsearch" -}} |
| 254 | - name: gerrit-index-config |
| 255 | persistentVolumeClaim: |
| 256 | claimName: {{ .Release.Name }}-gerrit-index-config-pvc |
| 257 | {{- end }} |
| 258 | - name: gerrit-config |
| 259 | configMap: |
| Giorgi Lekveishvili | ef7f833 | 2024-04-08 19:46:54 +0400 | [diff] [blame^] | 260 | name: {{ if .Values.gerrit.etc.existingConfigMapName }}{{ .Values.gerrit.etc.existingConfigMapName }}{{ else }} {{ .Release.Name }}-gerrit-configmap{{ end }} |
| Giorgi Lekveishvili | ee15ee2 | 2024-03-28 12:35:10 +0400 | [diff] [blame] | 261 | - name: gerrit-secure-config |
| 262 | secret: |
| 263 | secretName: {{ .Release.Name }}-gerrit-secure-config |
| 264 | {{ if .Values.caCert -}} |
| 265 | - name: tls-ca |
| 266 | secret: |
| 267 | secretName: {{ .Release.Name }}-tls-ca |
| 268 | {{- end }} |
| 269 | {{- range .Values.gerrit.additionalConfigMaps }} |
| 270 | - name: {{ .name }} |
| 271 | configMap: |
| 272 | name: {{ if .data }}{{ $root.Release.Name }}-{{ .name }}{{ else }}{{ .name }}{{ end }} |
| 273 | {{- end }} |
| 274 | {{- if and .Values.nfsWorkaround.enabled .Values.nfsWorkaround.idDomain }} |
| 275 | - name: nfs-config |
| 276 | configMap: |
| 277 | name: {{ .Release.Name }}-nfs-configmap |
| 278 | {{- end }} |
| 279 | {{ if .Values.gerrit.persistence.enabled -}} |
| 280 | volumeClaimTemplates: |
| 281 | - metadata: |
| 282 | name: gerrit-site |
| 283 | labels: |
| 284 | app.kubernetes.io/component: gerrit |
| 285 | app.kubernetes.io/instance: {{ .Release.Name }} |
| 286 | chart: {{ template "gerrit.chart" . }} |
| 287 | heritage: {{ .Release.Service }} |
| 288 | release: {{ .Release.Name }} |
| 289 | {{- if .Values.additionalLabels }} |
| 290 | {{ toYaml .Values.additionalLabels | indent 8 }} |
| 291 | {{- end }} |
| 292 | spec: |
| 293 | accessModes: |
| 294 | - ReadWriteOnce |
| 295 | resources: |
| 296 | requests: |
| 297 | storage: {{ .Values.gerrit.persistence.size }} |
| 298 | storageClassName: {{ .Values.storageClasses.default.name }} |
| 299 | {{- end }} |