Skip to content

Commit 5119967

Browse files
committed
add support for custom env vars
1 parent de4f594 commit 5119967

File tree

6 files changed

+204
-89
lines changed

6 files changed

+204
-89
lines changed

README.md

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

graylog/templates/_helpers.tpl

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -259,34 +259,52 @@ Datanode configmap name
259259
{{- include "graylog.fullname" . | printf "%s-datanode-config" }}
260260
{{- end }}
261261

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+
262280
{{/*
263281
Graylog plugins
264282
*/}}
265283
{{- define "graylog.pluginURLs" }}
266-
{{- if and .Values.graylog.config.plugins.enabled .Values.graylog.config.init.assetFetch.enabled .Values.graylog.config.init.assetFetch.plugins.enabled }}
284+
{{- if and .Values.graylog.config.plugins.enabled .Values.graylog.config.init.assetFetch.enabled .Values.graylog.config.init.assetFetch.plugins.enabled .Values.graylog.plugins }}
267285
{{- $urls := list }}
268286
{{- $baseUrl := .Values.graylog.config.init.assetFetch.plugins.baseUrl | default "" }}
269287
{{- $skipChecksum := .Values.graylog.config.init.assetFetch.skipChecksum | default false }}
270288
{{- $allowHttp := .Values.graylog.config.init.assetFetch.allowHttp | default false }}
271289
{{- if not $allowHttp | and (hasPrefix "http://" $baseUrl) }}
272290
{{- printf "Validation error: plugin baseUrl is '%s'. Only HTTPS is allowed for plugin URLs." $baseUrl | fail }}
273291
{{- end }}
274-
{{- range $name, $plugin := .Values.graylog.config.plugins }}
275-
{{- $url := $plugin.url }}
292+
{{- range .Values.graylog.plugins }}
293+
{{- $url := .url }}
276294
{{- if $url }}
277-
{{- if and (not $skipChecksum) (empty $plugin.checksum) }}
278-
{{- printf "Validation error: checksum verification is enabled but no checksum hash has been provided for plugin '%s'." $name | fail }}
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 }}
279297
{{- end }}
280298
{{- if and (hasPrefix "http://" $url | not) (hasPrefix "https://" $url | not) }}
281299
{{- $url = printf "%s/%s" (trimSuffix "/" $baseUrl) (trimPrefix "/" $url) }}
282300
{{- end }}
283301
{{- if not $allowHttp | and (hasPrefix "http://" $url) }}
284-
{{- printf "Validation error: plugin '%s' is using URL '%s'. Only HTTPS is allowed for plugin URLs." $name $url | fail }}
302+
{{- printf "Validation error: plugin '%s' is using URL '%s'. Only HTTPS is allowed for plugin URLs." .name $url | fail }}
285303
{{- end }}
286304
{{- if not $skipChecksum }}
287-
{{- $url = printf "%s|%s" $url $plugin.checksum }}
305+
{{- $url = printf "%s|%s" $url .checksum }}
288306
{{- end }}
289-
{{- $urls = printf "%s|%s" $name $url | append $urls }}
307+
{{- $urls = printf "%s|%s" .name $url | append $urls }}
290308
{{- end }}
291309
{{- end }}
292310
{{- $urls | join "^" | quote }}

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: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ spec:
7676
mountPath: /mnt/data
7777
- name: init-script
7878
mountPath: /scripts
79-
{{- if .Values.graylog.config.plugins.enabled }}
79+
{{- if .Values.graylog.config.plugins.enabled }}
8080
- name: init-plugins
8181
mountPath: /mnt/plugins
8282
{{- range .Values.graylog.plugins }}
@@ -85,8 +85,6 @@ spec:
8585
mountPath: {{ printf "/mnt/shared/plugins/%s" .name }}
8686
{{- end }}
8787
{{- end }}
88-
{{- end }}
89-
{{- if .Values.graylog.config.plugins.enabled }}
9088
{{- range .Values.graylog.plugins }}
9189
{{- if empty .existingClaim | and .image }}
9290
- name: {{ printf "copy-plugin-%s" .name }}
@@ -102,13 +100,9 @@ spec:
102100
- name: graylog-app
103101
image: {{ include "graylog.image" . }}
104102
imagePullPolicy: {{ .Values.graylog.custom.image.imagePullPolicy }}
105-
{{- if .Values.graylog.custom.env | default list | len | lt 0 }}
103+
{{- if or .Values.graylog.custom.env .Values.graylog.custom.extraEnv }}
106104
env:
107-
{{- range .Values.graylog.custom.env }}
108-
{{- $envList := splitList "=" . }}
109-
- name: {{ index $envList 0 | quote }}
110-
value: {{ index $envList 1 | quote }}
111-
{{- end }}
105+
{{- include "graylog.custom.env" .Values.graylog | indent 12 }}
112106
{{- end }}
113107
envFrom:
114108
- configMapRef:
@@ -187,14 +181,10 @@ spec:
187181
- name: init-plugins
188182
emptyDir: {}
189183
{{- range .Values.graylog.plugins }}
190-
{{- if empty .url }}
184+
{{- if empty .url | and .existingClaim }}
191185
- name: {{ .name }}
192-
{{- if .existingClaim }}
193186
persistentVolumeClaim:
194187
claimName: {{ .existingClaim }}
195-
{{- else }}
196-
emptyDir: {}
197-
{{- end }}
198188
{{- end }}
199189
{{- end }}
200190
{{- end }}

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: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ graylog:
114114
nodeSelector: {}
115115
tolerations: {}
116116
affinity: {}
117+
env: {}
118+
extraEnv: []
117119
inputs:
118120
enabled: true
119121
metrics:
@@ -123,7 +125,6 @@ graylog:
123125
tag: ""
124126
imagePullPolicy: IfNotPresent
125127
imagePullSecrets: []
126-
env:
127128
updateStrategy:
128129
type:
129130
rollingUpdate:
@@ -195,6 +196,8 @@ datanode:
195196
nodeSelector: {}
196197
tolerations: {}
197198
affinity: {}
199+
env: {}
200+
extraEnv: []
198201
image:
199202
repository: ""
200203
tag: ""

0 commit comments

Comments
 (0)