Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add event log trim cron job #28

Merged
merged 1 commit into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 112 additions & 0 deletions templates/event-log-trim/cronjob.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
29 changes: 29 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down