Skip to content

Commit ef5f125

Browse files
committed
chore(quickwit): add create index template job
1 parent cb66533 commit ef5f125

3 files changed

Lines changed: 69 additions & 1 deletion

File tree

charts/quickwit/templates/quickwit-configmap.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ data:
6363
log-indexes-template.json: |
6464
{
6565
"version": "0.9",
66-
"template_id": "logs",
66+
"template_id": "{{ .Values.logIndexTemplateName }}",
6767
"description": "kubernetes container logs",
6868
"index_id_patterns": [
6969
"{{ .Values.logIndexPrefix }}*"
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
apiVersion: batch/v1
2+
kind: Job
3+
metadata:
4+
name: drycc-quickwit-job-upgrade
5+
annotations:
6+
component.drycc.cc/version: {{ .Values.imageTag }}
7+
helm.sh/hook: post-install,post-upgrade,post-rollback
8+
helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded
9+
spec:
10+
template:
11+
spec:
12+
initContainers:
13+
- name: drycc-quickwit-init
14+
image: {{.Values.imageRegistry}}/{{.Values.imageOrg}}/python-dev:latest
15+
imagePullPolicy: {{.Values.imagePullPolicy}}
16+
args:
17+
- netcat
18+
- -v
19+
- -u
20+
- $(DRYCC_DATABASE_URL),$(DRYCC_DATABASE_REPLICA_URL)
21+
{{- include "quickwit.envs" . | indent 8 }}
22+
containers:
23+
- name: drycc-quickwit-job-upgrade
24+
image: {{.Values.imageRegistry}}/{{.Values.imageOrg}}/quickwit:{{.Values.imageTag}}
25+
imagePullPolicy: {{.Values.imagePullPolicy}}
26+
{{- if .Values.diagnosticMode.enabled }}
27+
command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 8 }}
28+
args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 8 }}
29+
{{- else }}
30+
command:
31+
- init-stack
32+
args:
33+
- bash
34+
- -ec
35+
- |
36+
QUICKWIT_API="http://drycc-quickwit.{{ $.Release.Namespace }}.svc.{{ .Values.global.clusterDomain }}:7280"
37+
TEMPLATE_FILE="/opt/drycc/quickwit/config/log-indexes-template.json"
38+
response=$(curl -s -o /dev/null -w "%{http_code}" -XGET "$QUICKWIT_API/{{ .Values.logIndexTemplateName }}")
39+
if [ "$response" -eq 404 ]; then
40+
echo "Template not found, creating new template..."
41+
curl -XPOST -d @"$TEMPLATE_FILE" -H "Content-Type: application/json" "$QUICKWIT_API"
42+
elif [ "$response" -eq 200 ]; then
43+
echo "Template exists, updating..."
44+
curl -XPUT -d @"$TEMPLATE_FILE" -H "Content-Type: application/json" "$QUICKWIT_API/{{ .Values.logIndexTemplateName }}"
45+
else
46+
echo "Unexpected HTTP status: $response"
47+
exit 1
48+
fi
49+
{{- end }}
50+
{{- with index .Values "resources" }}
51+
resources:
52+
{{- toYaml . | nindent 10 }}
53+
{{- end }}
54+
{{- include "quickwit.envs" . | indent 8 }}
55+
volumeMounts:
56+
- name: quickwit-config
57+
readOnly: true
58+
mountPath: /opt/drycc/quickwit/config
59+
- name: quickwit-control-plane-data
60+
mountPath: /data
61+
volumes:
62+
- name: quickwit-config
63+
configMap:
64+
name: quickwit-config
65+
- name: quickwit-control-plane-data
66+
emptyDir: {}
67+
restartPolicy: Never

charts/quickwit/values.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ diagnosticMode:
2121
# log index config
2222
logIndexPrefix: logs-
2323
logIndexRetention: "30 days"
24+
logIndexTemplateName: "logs"
2425

2526
# databaseUrl are will no longer use the built-in database component
2627
databaseUrl: ""

0 commit comments

Comments
 (0)