diff --git a/templates/event-log-trim/cronjob.yaml b/templates/event-log-trim/cronjob.yaml new file mode 100644 index 0000000..23bbcf2 --- /dev/null +++ b/templates/event-log-trim/cronjob.yaml @@ -0,0 +1,112 @@ +{{- if .Values.eventLogTrim.enabled }} +apiVersion: batch/v1 +kind: CronJob +metadata: + name: {{ include "jitsu.fullname" . }}-event-log-trim-{{ sha1sum (toJson .Values) | substr 0 8 }} + labels: + {{- include "jitsu.labels" . | nindent 4 }} + {{- with .Values.eventLogTrim.jobAnnotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + schedule: {{ .Values.eventLogTrim.schedule | quote }} + jobTemplate: + spec: + backoffLimit: 1 + template: + metadata: + labels: + {{- include "jitsu.selectorLabels" . | nindent 12 }} + {{- with (merge (deepCopy .Values.eventLogTrim.podAnnotations) .Values.global.podAnnotations) }} + annotations: + {{- toYaml . | nindent 12 }} + {{- end }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 12 }} + {{- end }} + restartPolicy: "Never" + serviceAccountName: {{ include "jitsu.serviceAccountName" . }} + {{- with (.Values.eventLogTrim.podSecurityContext | default .Values.global.podSecurityContext) }} + securityContext: + {{- toYaml . | nindent 12 }} + {{- end }} + initContainers: + {{- if .Values.tokenGenerator.enabled }} + - name: wait-for-tokens + {{- with (.Values.eventLogTrim.securityContext | default .Values.global.securityContext) }} + securityContext: + {{- toYaml . | nindent 16 }} + {{- end }} + image: ghcr.io/groundnuty/k8s-wait-for:v2.0 + args: ["job-wr", "{{ include "jitsu.fullname" . }}-token-generator-{{ sha1sum (toJson .Values) | substr 0 8 }}"] + {{- end }} + {{- if .Values.console.enabled }} + - name: wait-for-console + {{- with (.Values.eventLogTrim.securityContext | default .Values.global.securityContext) }} + securityContext: + {{- toYaml . | nindent 16 }} + {{- end }} + image: ghcr.io/groundnuty/k8s-wait-for:v2.0 + args: ["service", "{{ .Release.Name }}-console"] + {{- end }} + containers: + - name: {{ .Chart.Name }} + {{- with (.Values.eventLogTrim.securityContext | default .Values.global.securityContext) }} + securityContext: + {{- toYaml . | nindent 16 }} + {{- end }} + image: "{{ .Values.eventLogTrim.image.repository }}:{{ .Values.eventLogTrim.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.eventLogTrim.image.pullPolicy }} + command: + - sh + - -c + - > + curl --silent --output /dev/null --show-error -H "Authorization: Bearer $CONSOLE_AUTH_TOKEN" "$CONSOLE_ENDPOINT" + {{- if .Values.eventLogTrim.envFrom }} + envFrom: + {{- toYaml .Values.eventLogTrim.envFrom | nindent 16 }} + {{- end }} + env: + {{- if and .Values.config.enabled .Values.eventLogTrim.config.enabled }} + - name: CONSOLE_ENDPOINT + value: {{ printf "http://%s-console:%d/api/admin/events-log-trim" + (include "jitsu.fullname" .) + (int $.Values.console.service.port) + }} + {{- if .Values.eventLogTrim.config.consoleAuthTokenFrom }} + - name: CONSOLE_AUTH_TOKEN + valueFrom: + {{- toYaml .Values.eventLogTrim.config.consoleAuthTokenFrom | nindent 20 }} + {{- else }} + {{- if and (not .Values.eventLogTrim.config.consoleAuthToken) .Values.console.enabled .Values.tokenGenerator.enabled }} + - name: CONSOLE_AUTH_TOKEN + valueFrom: + secretKeyRef: + name: {{ include "jitsu.fullname" . }}-tokens + key: consoleAuthToken + {{- end }} + {{- with .Values.eventLogTrim.config.consoleAuthToken }} + - name: CONSOLE_AUTH_TOKEN + value: {{ .Values.eventLogTrim.config.consoleAuthToken | quote }} + {{- end }} + {{- end }} + {{- end }} + {{- with .Values.eventLogTrim.env }} + {{- toYaml . | nindent 16 }} + {{- end }} + {{- with (.Values.eventLogTrim.nodeSelector | default .Values.global.nodeSelector) }} + nodeSelector: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with (.Values.eventLogTrim.affinity | default .Values.global.affinity) }} + affinity: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with (.Values.eventLogTrim.tolerations | default .Values.global.affinity) }} + tolerations: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- end }} diff --git a/values.yaml b/values.yaml index 27eac55..8aad02f 100644 --- a/values.yaml +++ b/values.yaml @@ -870,6 +870,35 @@ eventLogInit: tolerations: [] affinity: {} +eventLogTrim: + enabled: true + schedule: '0 0 * * *' + config: + # Set to false to disable config abstractions in order to configure manually. + enabled: true + + # Leave empty to configure automatically + consoleEndpoint: "" + + # Configured automatically when using the token generator + consoleAuthToken: "" + consoleAuthTokenFrom: {} + image: + repository: jitsucom/console + pullPolicy: IfNotPresent + tag: "" + restartPolicy: Never + env: [] + envFrom: [] + jobAnnotations: {} + podAnnotations: {} + podSecurityContext: {} + securityContext: {} + resources: {} + nodeSelector: {} + tolerations: [] + affinity: {} + imagePullSecrets: [] serviceAccount: