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