|
| 1 | +{{- if .Values.eventLogTrim.enabled }} |
| 2 | +apiVersion: batch/v1 |
| 3 | +kind: CronJob |
| 4 | +metadata: |
| 5 | + name: {{ include "jitsu.fullname" . }}-event-log-trim-{{ sha1sum (toJson .Values) | substr 0 8 }} |
| 6 | + labels: |
| 7 | + {{- include "jitsu.labels" . | nindent 4 }} |
| 8 | + {{- with .Values.eventLogTrim.jobAnnotations }} |
| 9 | + annotations: |
| 10 | + {{- toYaml . | nindent 4 }} |
| 11 | + {{- end }} |
| 12 | +spec: |
| 13 | + schedule: {{ .Values.eventLogTrim.schedule | quote }} |
| 14 | + jobTemplate: |
| 15 | + spec: |
| 16 | + backoffLimit: 1 |
| 17 | + template: |
| 18 | + metadata: |
| 19 | + labels: |
| 20 | + {{- include "jitsu.selectorLabels" . | nindent 12 }} |
| 21 | + {{- with (merge (deepCopy .Values.eventLogTrim.podAnnotations) .Values.global.podAnnotations) }} |
| 22 | + annotations: |
| 23 | + {{- toYaml . | nindent 12 }} |
| 24 | + {{- end }} |
| 25 | + spec: |
| 26 | + {{- with .Values.imagePullSecrets }} |
| 27 | + imagePullSecrets: |
| 28 | + {{- toYaml . | nindent 12 }} |
| 29 | + {{- end }} |
| 30 | + restartPolicy: "Never" |
| 31 | + serviceAccountName: {{ include "jitsu.serviceAccountName" . }} |
| 32 | + {{- with (.Values.eventLogTrim.podSecurityContext | default .Values.global.podSecurityContext) }} |
| 33 | + securityContext: |
| 34 | + {{- toYaml . | nindent 12 }} |
| 35 | + {{- end }} |
| 36 | + initContainers: |
| 37 | + {{- if .Values.tokenGenerator.enabled }} |
| 38 | + - name: wait-for-tokens |
| 39 | + {{- with (.Values.eventLogTrim.securityContext | default .Values.global.securityContext) }} |
| 40 | + securityContext: |
| 41 | + {{- toYaml . | nindent 16 }} |
| 42 | + {{- end }} |
| 43 | + image: ghcr.io/groundnuty/k8s-wait-for:v2.0 |
| 44 | + args: ["job-wr", "{{ include "jitsu.fullname" . }}-token-generator-{{ sha1sum (toJson .Values) | substr 0 8 }}"] |
| 45 | + {{- end }} |
| 46 | + {{- if .Values.console.enabled }} |
| 47 | + - name: wait-for-console |
| 48 | + {{- with (.Values.eventLogTrim.securityContext | default .Values.global.securityContext) }} |
| 49 | + securityContext: |
| 50 | + {{- toYaml . | nindent 16 }} |
| 51 | + {{- end }} |
| 52 | + image: ghcr.io/groundnuty/k8s-wait-for:v2.0 |
| 53 | + args: ["service", "{{ .Release.Name }}-console"] |
| 54 | + {{- end }} |
| 55 | + containers: |
| 56 | + - name: {{ .Chart.Name }} |
| 57 | + {{- with (.Values.eventLogTrim.securityContext | default .Values.global.securityContext) }} |
| 58 | + securityContext: |
| 59 | + {{- toYaml . | nindent 16 }} |
| 60 | + {{- end }} |
| 61 | + image: "{{ .Values.eventLogTrim.image.repository }}:{{ .Values.eventLogTrim.image.tag | default .Chart.AppVersion }}" |
| 62 | + imagePullPolicy: {{ .Values.eventLogTrim.image.pullPolicy }} |
| 63 | + command: |
| 64 | + - sh |
| 65 | + - -c |
| 66 | + - > |
| 67 | + curl --silent --output /dev/null --show-error -H "Authorization: Bearer $CONSOLE_AUTH_TOKEN" "$CONSOLE_ENDPOINT" |
| 68 | + {{- if .Values.eventLogTrim.envFrom }} |
| 69 | + envFrom: |
| 70 | + {{- toYaml .Values.eventLogTrim.envFrom | nindent 16 }} |
| 71 | + {{- end }} |
| 72 | + env: |
| 73 | + {{- if and .Values.config.enabled .Values.eventLogTrim.config.enabled }} |
| 74 | + - name: CONSOLE_ENDPOINT |
| 75 | + value: {{ printf "http://%s-console:%d/api/admin/events-log-trim" |
| 76 | + (include "jitsu.fullname" .) |
| 77 | + (int $.Values.console.service.port) |
| 78 | + }} |
| 79 | + {{- if .Values.eventLogTrim.config.consoleAuthTokenFrom }} |
| 80 | + - name: CONSOLE_AUTH_TOKEN |
| 81 | + valueFrom: |
| 82 | + {{- toYaml .Values.eventLogTrim.config.consoleAuthTokenFrom | nindent 20 }} |
| 83 | + {{- else }} |
| 84 | + {{- if and (not .Values.eventLogTrim.config.consoleAuthToken) .Values.console.enabled .Values.tokenGenerator.enabled }} |
| 85 | + - name: CONSOLE_AUTH_TOKEN |
| 86 | + valueFrom: |
| 87 | + secretKeyRef: |
| 88 | + name: {{ include "jitsu.fullname" . }}-tokens |
| 89 | + key: consoleAuthToken |
| 90 | + {{- end }} |
| 91 | + {{- with .Values.eventLogTrim.config.consoleAuthToken }} |
| 92 | + - name: CONSOLE_AUTH_TOKEN |
| 93 | + value: {{ .Values.eventLogTrim.config.consoleAuthToken | quote }} |
| 94 | + {{- end }} |
| 95 | + {{- end }} |
| 96 | + {{- end }} |
| 97 | + {{- with .Values.eventLogTrim.env }} |
| 98 | + {{- toYaml . | nindent 16 }} |
| 99 | + {{- end }} |
| 100 | + {{- with (.Values.eventLogTrim.nodeSelector | default .Values.global.nodeSelector) }} |
| 101 | + nodeSelector: |
| 102 | + {{- toYaml . | nindent 12 }} |
| 103 | + {{- end }} |
| 104 | + {{- with (.Values.eventLogTrim.affinity | default .Values.global.affinity) }} |
| 105 | + affinity: |
| 106 | + {{- toYaml . | nindent 12 }} |
| 107 | + {{- end }} |
| 108 | + {{- with (.Values.eventLogTrim.tolerations | default .Values.global.affinity) }} |
| 109 | + tolerations: |
| 110 | + {{- toYaml . | nindent 12 }} |
| 111 | + {{- end }} |
| 112 | + {{- end }} |
0 commit comments