| Giorgi Lekveishvili | ee15ee2 | 2024-03-28 12:35:10 +0400 | [diff] [blame^] | 1 | apiVersion: batch/v1 |
| 2 | kind: CronJob |
| 3 | metadata: |
| 4 | name: {{ .Release.Name }}-git-gc |
| 5 | labels: |
| 6 | app.kubernetes.io/component: git-gc |
| 7 | app.kubernetes.io/instance: {{ .Release.Name }} |
| 8 | chart: {{ template "gerrit.chart" . }} |
| 9 | heritage: {{ .Release.Service }} |
| 10 | release: {{ .Release.Name }} |
| 11 | {{- if .Values.additionalLabels }} |
| 12 | {{ toYaml .Values.additionalLabels | indent 4 }} |
| 13 | {{- end }} |
| 14 | spec: |
| 15 | schedule: {{ .Values.gitGC.schedule | quote }} |
| 16 | concurrencyPolicy: "Forbid" |
| 17 | jobTemplate: |
| 18 | spec: |
| 19 | template: |
| 20 | metadata: |
| 21 | labels: |
| 22 | app.kubernetes.io/component: git-gc |
| 23 | app.kubernetes.io/instance: {{ .Release.Name }} |
| 24 | chart: {{ template "gerrit.chart" . }} |
| 25 | heritage: {{ .Release.Service }} |
| 26 | release: {{ .Release.Name }} |
| 27 | {{- if .Values.additionalLabels }} |
| 28 | {{ toYaml .Values.additionalLabels | indent 12 }} |
| 29 | {{- end }} |
| 30 | {{- if .Values.gitGC.additionalPodLabels }} |
| 31 | {{ toYaml .Values.gitGC.additionalPodLabels | indent 12 }} |
| 32 | {{- end }} |
| 33 | annotations: |
| 34 | cluster-autoscaler.kubernetes.io/safe-to-evict: "false" |
| 35 | spec: |
| 36 | {{- with .Values.gitGC.tolerations }} |
| 37 | tolerations: |
| 38 | {{- toYaml . | nindent 10 }} |
| 39 | {{- end }} |
| 40 | {{- with .Values.gitGC.nodeSelector }} |
| 41 | nodeSelector: |
| 42 | {{- toYaml . | nindent 12 }} |
| 43 | {{- end }} |
| 44 | {{- with .Values.gitGC.affinity }} |
| 45 | affinity: |
| 46 | {{- toYaml . | nindent 12 }} |
| 47 | {{- end }} |
| 48 | restartPolicy: OnFailure |
| 49 | securityContext: |
| 50 | runAsUser: 1000 |
| 51 | fsGroup: 100 |
| 52 | {{ if .Values.images.registry.ImagePullSecret.name -}} |
| 53 | imagePullSecrets: |
| 54 | - name: {{ .Values.images.registry.ImagePullSecret.name }} |
| 55 | {{- range .Values.images.additionalImagePullSecrets }} |
| 56 | - name: {{ . }} |
| 57 | {{- end }} |
| 58 | {{- end }} |
| 59 | initContainers: |
| 60 | {{- if and .Values.nfsWorkaround.enabled .Values.nfsWorkaround.chownOnStartup }} |
| 61 | - name: nfs-init |
| 62 | image: {{ .Values.images.busybox.registry -}}/busybox:{{- .Values.images.busybox.tag }} |
| 63 | command: |
| 64 | - sh |
| 65 | - -c |
| 66 | args: |
| 67 | - | |
| 68 | chown 1000:100 /var/mnt/logs |
| 69 | chown 1000:100 /var/mnt/git |
| 70 | env: |
| 71 | - name: POD_NAME |
| 72 | valueFrom: |
| 73 | fieldRef: |
| 74 | fieldPath: metadata.name |
| 75 | volumeMounts: |
| 76 | - name: logs |
| 77 | subPathExpr: "git-gc/$(POD_NAME)" |
| 78 | mountPath: "/var/mnt/logs" |
| 79 | - name: git-repositories |
| 80 | mountPath: "/var/mnt/git" |
| 81 | {{- if .Values.nfsWorkaround.idDomain }} |
| 82 | - name: nfs-config |
| 83 | mountPath: "/etc/idmapd.conf" |
| 84 | subPath: idmapd.conf |
| 85 | {{- end }} |
| 86 | {{- end }} |
| 87 | containers: |
| 88 | - name: git-gc |
| 89 | imagePullPolicy: {{ .Values.images.imagePullPolicy }} |
| 90 | image: {{ template "registry" . }}{{ .Values.gitGC.image }}:{{ .Values.images.version }} |
| 91 | env: |
| 92 | - name: POD_NAME |
| 93 | valueFrom: |
| 94 | fieldRef: |
| 95 | fieldPath: metadata.name |
| 96 | resources: |
| 97 | {{ toYaml .Values.gitGC.resources | indent 14 }} |
| 98 | volumeMounts: |
| 99 | - name: git-repositories |
| 100 | mountPath: "/var/gerrit/git" |
| 101 | - name: logs |
| 102 | subPathExpr: "git-gc/$(POD_NAME)" |
| 103 | mountPath: "/var/log/git" |
| 104 | {{- if and .Values.nfsWorkaround.enabled .Values.nfsWorkaround.idDomain }} |
| 105 | - name: nfs-config |
| 106 | mountPath: "/etc/idmapd.conf" |
| 107 | subPath: idmapd.conf |
| 108 | {{- end }} |
| 109 | volumes: |
| 110 | - name: git-repositories |
| 111 | persistentVolumeClaim: |
| 112 | {{- if .Values.gitRepositoryStorage.externalPVC.use }} |
| 113 | claimName: {{ .Values.gitRepositoryStorage.externalPVC.name }} |
| 114 | {{- else }} |
| 115 | claimName: {{ .Release.Name }}-git-repositories-pvc |
| 116 | {{- end }} |
| 117 | - name: logs |
| 118 | {{ if .Values.logStorage.enabled -}} |
| 119 | persistentVolumeClaim: |
| 120 | {{- if .Values.logStorage.externalPVC.use }} |
| 121 | claimName: {{ .Values.logStorage.externalPVC.name }} |
| 122 | {{- else }} |
| 123 | claimName: {{ .Release.Name }}-log-pvc |
| 124 | {{- end }} |
| 125 | {{ else -}} |
| 126 | emptyDir: {} |
| 127 | {{- end }} |
| 128 | {{- if and .Values.nfsWorkaround.enabled .Values.nfsWorkaround.idDomain }} |
| 129 | - name: nfs-config |
| 130 | configMap: |
| 131 | name: {{ .Release.Name }}-nfs-configmap |
| 132 | {{- end }} |