UNCLASSIFIED

upgrade_check_hook.yaml 2.85 KB
Newer Older
kevin.wilder's avatar
kevin.wilder committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
{{- if .Values.upgradeCheck.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ template "fullname" . }}-upgrade-check
  namespace: {{ $.Release.Namespace }}
  labels:
    {{- include "gitlab.standardLabels" . | nindent 4 }}
  annotations:
    "helm.sh/hook": pre-upgrade
    "helm.sh/hook-weight": "-11"
    "helm.sh/hook-delete-policy": before-hook-creation
data:
  runcheck: |
    {{- include (print $.Template.BasePath "/_runcheck.tpl") . | nindent 4 }}
---
apiVersion: batch/v1
kind: Job
metadata:
  name: {{ template "fullname" . }}-upgrade-check
  namespace: {{ .Release.Namespace }}
  labels:
    {{- include "gitlab.standardLabels" . | nindent 4 }}
  annotations:
    "helm.sh/hook": pre-upgrade
    "helm.sh/hook-weight": "-10"
    "helm.sh/hook-delete-policy": hook-succeeded,before-hook-creation
spec:
  backoffLimit: 2
  template:
    metadata:
      labels:
        app: {{ template "name" . }}
        release: {{ .Release.Name }}
    spec:
kevin.wilder's avatar
kevin.wilder committed
36 37 38 39 40
      {{- if .Values.upgradeCheck.nodeSelector }}
        nodeSelector: {{ toYaml .Values.upgradeCheck.nodeSelector | nindent 8 }}
      {{- else }}
      {{- include "gitlab.nodeSelector" . | nindent 6 }}
      {{- end }}
kevin.wilder's avatar
kevin.wilder committed
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
      {{- if .Values.upgradeCheck.tolerations }}
      tolerations:
        {{- toYaml .Values.upgradeCheck.tolerations | nindent 8 }}
      {{- end }}
      securityContext:
        runAsUser: {{ .Values.upgradeCheck.securityContext.runAsUser }}
        fsGroup: {{ .Values.upgradeCheck.securityContext.fsGroup }}
      restartPolicy: Never
      {{- include "pullsecrets" .Values.upgradeCheck.image | nindent 6}}
      containers:
        - name: run-check
          image: {{ include "gitlab.busybox.image" (dict "local" .Values.upgradeCheck "global" $.Values.global.busybox) | quote }}
          command: ['/bin/sh', '/scripts/runcheck']
          {{ template "gitlab.imagePullPolicy" . }}
          env:
            - name: GITLAB_VERSION
              value: '{{ coalesce .Values.global.gitlabVersion .Chart.AppVersion }}'
            - name: CHART_VERSION
              value: '{{ .Chart.Version }}'
          volumeMounts:
            - name: chart-info
              mountPath: /chart-info
            - name: scripts
              mountPath: /scripts
{{- if .Values.postgresql.install }}
            - name: postgresql-secret
              mountPath: /etc/secrets/postgresql
{{- end }}
          resources:
            {{- toYaml .Values.upgradeCheck.resources | nindent 12 }}
      volumes:
      - name: chart-info
        configMap:
          name: {{ template "fullname" . }}-chart-info
          optional: true
      - name: scripts
        configMap:
          name: {{ template "fullname" . }}-upgrade-check
{{- if .Values.postgresql.install }}
      - name: postgresql-secret
        secret:
          secretName: {{ template "gitlab.psql.password.secret" . }}
          optional: true
{{- end }}
{{- end }}