Skip to content

Commit 35c57e6

Browse files
authored
Merge branch 'main' into bug/ingress
2 parents 2c48c58 + 542c77e commit 35c57e6

7 files changed

Lines changed: 315 additions & 80 deletions

File tree

README.md

Lines changed: 145 additions & 76 deletions
Large diffs are not rendered by default.

graylog/templates/_helpers.tpl

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,4 +257,56 @@ Datanode configmap name
257257
*/}}
258258
{{- define "graylog.datanode.configmapName" -}}
259259
{{- include "graylog.fullname" . | printf "%s-datanode-config" }}
260-
{{- end }}
260+
{{- end }}
261+
262+
{{/*
263+
Custom enviroment variables
264+
usage: {{ include "graylog.custom.env" .Values.{graylog|datanode} | indent N }}
265+
*/}}
266+
{{- define "graylog.custom.env" }}
267+
{{- $explicit := list }}
268+
{{- range $_, $e := .custom.extraEnv }}
269+
{{- if $e.name }}{{ $explicit = append $explicit .name }}{{ end }}
270+
- {{ toYaml $e | nindent 2 | trim }}
271+
{{- end }}
272+
{{- range $k, $v := .custom.env }}
273+
{{- if has $k $explicit | not }}
274+
- name: {{ $k }}
275+
value: {{ $v | quote }}
276+
{{- end }}
277+
{{- end }}
278+
{{- end }}
279+
280+
{{/*
281+
Graylog plugins
282+
*/}}
283+
{{- define "graylog.pluginURLs" }}
284+
{{- if and .Values.graylog.config.plugins.enabled .Values.graylog.config.init.assetFetch.enabled .Values.graylog.config.init.assetFetch.plugins.enabled .Values.graylog.plugins }}
285+
{{- $urls := list }}
286+
{{- $baseUrl := .Values.graylog.config.init.assetFetch.plugins.baseUrl | default "" }}
287+
{{- $skipChecksum := .Values.graylog.config.init.assetFetch.skipChecksum | default false }}
288+
{{- $allowHttp := .Values.graylog.config.init.assetFetch.allowHttp | default false }}
289+
{{- if not $allowHttp | and (hasPrefix "http://" $baseUrl) }}
290+
{{- printf "Validation error: plugin baseUrl is '%s'. Only HTTPS is allowed for plugin URLs." $baseUrl | fail }}
291+
{{- end }}
292+
{{- range .Values.graylog.plugins }}
293+
{{- $url := .url }}
294+
{{- if $url }}
295+
{{- if and (not $skipChecksum) (empty .checksum) }}
296+
{{- printf "Validation error: checksum verification is enabled but no checksum hash has been provided for plugin '%s'." .name | fail }}
297+
{{- end }}
298+
{{- if and (hasPrefix "http://" $url | not) (hasPrefix "https://" $url | not) }}
299+
{{- $url = printf "%s/%s" (trimSuffix "/" $baseUrl) (trimPrefix "/" $url) }}
300+
{{- end }}
301+
{{- if not $allowHttp | and (hasPrefix "http://" $url) }}
302+
{{- printf "Validation error: plugin '%s' is using URL '%s'. Only HTTPS is allowed for plugin URLs." .name $url | fail }}
303+
{{- end }}
304+
{{- if not $skipChecksum }}
305+
{{- $url = printf "%s|%s" $url .checksum }}
306+
{{- end }}
307+
{{- $urls = printf "%s|%s" .name $url | append $urls }}
308+
{{- end }}
309+
{{- end }}
310+
{{- $urls | join "^" | quote }}
311+
{{- end }}
312+
{{- end }}

graylog/templates/config/init-graylog.yaml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,38 @@ data:
1212
else
1313
cp -r /usr/share/graylog/data/* /mnt/data/
1414
fi
15+
{{- if .Values.graylog.config.plugins.enabled }}
16+
# copy plugins
17+
[ -d /mnt/shared/plugins ] && find /mnt/shared/plugins/ -type f -name '*.jar' -exec cp {} /mnt/plugins/ \;
18+
19+
{{- if and .Values.graylog.config.init.assetFetch.enabled .Values.graylog.config.init.assetFetch.plugins.enabled }}
20+
# retrieve plugins directly
21+
for urlchecksum in $(echo "${GRAYLOG_PLUGIN_URLS}" | tr "^" "\n"); do
22+
name=$(echo "$urlchecksum" | cut -d'|' -f1)
23+
url=$(echo "$urlchecksum" | cut -d'|' -f2)
24+
checksum=$(echo "$urlchecksum" | cut -d'|' -f3)
25+
wget "$url" -O "$name.jar" || { echo "Failed to fetch plugin $name.jar at $url"; continue; }
26+
if [ -n "$checksum" ]; then
27+
actual=$(sha256sum "$name.jar" | awk '{print $1}')
28+
if [ "$checksum" = "$actual" ]; then
29+
echo "Plugin checksum matches for $name.jar"
30+
cp "$name.jar" "/mnt/plugins/" && rm "$name.jar"
31+
else
32+
echo "Plugin checksum does NOT match for $name. Skipping plugin."
33+
rm "$name.jar"
34+
fi
35+
else
36+
echo "Warning: no checksum validation has been performed for plugin $name.jar"
37+
cp "$name.jar" "/mnt/plugins/" && rm "$name.jar"
38+
fi
39+
done
40+
{{- end }}
41+
{{- end }}
1542
# check mongo credentials
1643
if env | grep GRAYLOG_MONGODB_URI | grep -q "@"; then
1744
echo "MongoDB credentials set. We're good to go!"
1845
else
1946
echo "Error: MongoDB credentials not set in MongoDB URI. Make sure secrets are up to date."
2047
exit 1
2148
fi
22-
{{- end }}
49+
{{- end }}

graylog/templates/workload/statefulsets/datanode.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ spec:
8787
secretKeyRef:
8888
name: {{ include "graylog.secretsName" . }}
8989
key: GRAYLOG_S3_CLIENT_DEFAULT_ACCESS_KEY
90+
{{- include "graylog.custom.env" .Values.datanode | indent 12 }}
9091
ports:
9192
- name: api
9293
containerPort: {{ .Values.datanode.custom.service.ports.api | default 8999 | int }}

graylog/templates/workload/statefulsets/graylog.yaml

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ spec:
6161
image: {{ include "graylog.image" . }}
6262
imagePullPolicy: {{ .Values.graylog.custom.image.imagePullPolicy }}
6363
command: [ "/bin/sh", "/scripts/init-script.sh" ]
64+
{{- if and .Values.graylog.config.plugins.enabled .Values.graylog.config.init.assetFetch.enabled .Values.graylog.config.init.assetFetch.plugins.enabled .Values.graylog.plugins }}
65+
env:
66+
- name: GRAYLOG_PLUGIN_URLS
67+
value: {{ include "graylog.pluginURLs" . }}
68+
{{- end }}
6469
envFrom:
6570
- configMapRef:
6671
name: {{ include "graylog.configmapName" . }}
@@ -71,10 +76,34 @@ spec:
7176
mountPath: /mnt/data
7277
- name: init-script
7378
mountPath: /scripts
79+
{{- if .Values.graylog.config.plugins.enabled }}
80+
- name: init-plugins
81+
mountPath: /mnt/plugins
82+
{{- range .Values.graylog.plugins }}
83+
{{- if empty .image | and .existingClaim }}
84+
- name: {{ .name }}
85+
mountPath: {{ printf "/mnt/shared/plugins/%s" .name }}
86+
{{- end }}
87+
{{- end }}
88+
{{- range .Values.graylog.plugins }}
89+
{{- if empty .existingClaim | and .image }}
90+
- name: {{ printf "copy-plugin-%s" .name }}
91+
image: {{ .image }}
92+
command: [ "/bin/sh", "-c", "cp *.jar /mnt/plugins/" ]
93+
volumeMounts:
94+
- name: init-plugins
95+
mountPath: /mnt/plugins
96+
{{- end }}
97+
{{- end }}
98+
{{- end }}
7499
containers:
75100
- name: graylog-app
76101
image: {{ include "graylog.image" . }}
77102
imagePullPolicy: {{ .Values.graylog.custom.image.imagePullPolicy }}
103+
{{- if or .Values.graylog.custom.env .Values.graylog.custom.extraEnv }}
104+
env:
105+
{{- include "graylog.custom.env" .Values.graylog | indent 12 }}
106+
{{- end }}
78107
envFrom:
79108
- configMapRef:
80109
name: {{ include "graylog.configmapName" . }}
@@ -89,7 +118,7 @@ spec:
89118
protocol: TCP
90119
{{- range .Values.graylog.inputs }}
91120
- name: {{ .name }}
92-
containerPort: {{ .targetPort | int }}
121+
containerPort: {{ .targetPort | default .port | int }}
93122
protocol: {{ .protocol }}
94123
{{- end }}
95124
- name: input-fwd-conf
@@ -126,6 +155,10 @@ spec:
126155
- name: tls-creds
127156
mountPath: /usr/share/graylog/tls
128157
{{- end }}
158+
{{- if .Values.graylog.config.plugins.enabled }}
159+
- name: init-plugins
160+
mountPath: /usr/share/graylog/plugin
161+
{{- end }}
129162
tolerations:
130163
{{- with .Values.graylog.custom.tolerations }}
131164
{{- toYaml . | nindent 8 }}
@@ -138,12 +171,23 @@ spec:
138171
- name: init-script
139172
configMap:
140173
name: init-script-cm
141-
defaultMode: 0755 # Make script executable
174+
defaultMode: 0755
142175
{{- if .Values.graylog.config.tls.byoc.enabled }}
143176
- name: tls-creds
144177
secret:
145178
secretName: {{ .Values.graylog.config.tls.byoc.secretName | quote }}
146179
{{- end }}
180+
{{- if .Values.graylog.config.plugins.enabled }}
181+
- name: init-plugins
182+
emptyDir: {}
183+
{{- range .Values.graylog.plugins }}
184+
{{- if empty .url | and .existingClaim }}
185+
- name: {{ .name }}
186+
persistentVolumeClaim:
187+
claimName: {{ .existingClaim }}
188+
{{- end }}
189+
{{- end }}
190+
{{- end }}
147191
{{- if not .Values.graylog.custom.persistence.enabled | or .Values.graylog.custom.persistence.existingClaim }}
148192
- name: {{ include "graylog.volumeName" . }}
149193
{{- if .Values.graylog.custom.persistence.existingClaim }}

graylog/values.schema.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,18 @@
137137
"affinity": {
138138
"type": "object"
139139
},
140+
"env": {
141+
"type": "object",
142+
"additionalProperties": {
143+
"type": ["string","number","boolean"]
144+
},
145+
"description": "Key/value env vars rendered as literals"
146+
},
147+
"extraEnv": {
148+
"type": "array",
149+
"items": { "type": "object" },
150+
"description": "Full EnvVar objects (supports valueFrom)"
151+
},
140152
"inputs": {
141153
"type": "object",
142154
"properties": {
@@ -293,6 +305,18 @@
293305
"affinity": {
294306
"type": "object"
295307
},
308+
"env": {
309+
"type": "object",
310+
"additionalProperties": {
311+
"type": ["string","number","boolean"]
312+
},
313+
"description": "Key/value env vars rendered as literals"
314+
},
315+
"extraEnv": {
316+
"type": "array",
317+
"items": { "type": "object" },
318+
"description": "Full EnvVar objects (supports valueFrom)"
319+
},
296320
"image": {
297321
"type": "object",
298322
"properties": {

graylog/values.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ graylog:
3737
port: 13301
3838
targetPort: 13301
3939
protocol: TCP
40+
plugins:
4041
# Graylog server configuration (server.conf)
4142
config:
4243
rootUsername: "admin"
@@ -94,12 +95,27 @@ graylog:
9495
useSsl: "false"
9596
useTls: "true"
9697
webInterfaceUrl: "https://graylog.example.com"
98+
plugins:
99+
enabled: false
100+
init:
101+
assetFetch:
102+
enabled: false
103+
skipChecksum: false
104+
allowHttp: false
105+
plugins:
106+
enabled: false
107+
baseUrl:
108+
geolocation:
109+
enabled: false
110+
baseUrl:
97111
# Custom Kubernetes-specific parameters
98112
custom:
99113
podAnnotations: {}
100114
nodeSelector: {}
101115
tolerations: {}
102116
affinity: {}
117+
env: {}
118+
extraEnv: []
103119
inputs:
104120
enabled: true
105121
metrics:
@@ -180,6 +196,8 @@ datanode:
180196
nodeSelector: {}
181197
tolerations: {}
182198
affinity: {}
199+
env: {}
200+
extraEnv: []
183201
image:
184202
repository: ""
185203
tag: ""

0 commit comments

Comments
 (0)