[stable/graylog] Add support fetching elasticsearch and mongodb hosts from K8s secrets (#20807)

* - Add support for elasticsearch and mongodb hosts retrieval from a k8s secret

Signed-off-by: Mohamed Hazem <mhaz@hellofresh.com>

* - Version bump to 1.5.8

Signed-off-by: Mohamed Hazem <mhaz@hellofresh.com>

* - Simplify values for enabling URI fetching from k8s secrets

Signed-off-by: Mohamed Hazem <mhaz@hellofresh.com>
This commit is contained in:
Mohamed Hazem
2020-02-19 21:05:02 -08:00
committed by GitHub
parent 697f7bee3e
commit a97558f680
6 changed files with 41 additions and 3 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
apiVersion: v1
name: graylog
home: https://www.graylog.org
version: 1.5.7
version: 1.5.8
appVersion: 3.1
description: Graylog is the centralized log management solution built to open standards for capturing, storing, and enabling real-time analysis of terabytes of machine data.
keywords:
+4
View File
@@ -142,7 +142,11 @@ The following table lists the configurable parameters of the Graylog chart and t
| `graylog.existingRootSecret` | Graylog existing root secret | `` |
| `graylog.rootTimezone` | Graylog root timezone. | `UTC` |
| `graylog.elasticsearch.hosts` | Graylog Elasticsearch host name. You need to specific where data will be stored. | `` |
| `graylog.elasticsearch.uriSecretName` | K8s secret name where elasticsearch hosts will be set from. | `{{ graylog.fullname }}` |
| `graylog.elasticsearch.uriSecretKey` | K8s secret key name where elasticsearch hosts will be set from. | `` |
| `graylog.mongodb.uri` | Graylog MongoDB connection string. You need to specific where data will be stored. | `` |
| `graylog.mongodb.uriSecretName` | K8s secret name where MongoDB URI will be set from. | `{{ graylog.fullname }}` |
| `graylog.mongodb.uriSecretKey` | K8s secret key name where MongoDB URI will be set from. | `` |
| `graylog.transportEmail.enabled` | If true, enable transport email settings on Graylog | `false` |
| `graylog.config` | Add additional server configuration to `graylog.conf` file. | `` |
| `graylog.serverFiles` | Add additional server files on /etc/graylog/server. This is useful for enable TLS on input | `{}` |
+6 -2
View File
@@ -77,7 +77,9 @@ Create a default fully qualified elasticsearch name or use the `graylog.elastics
Or use chart dependencies with release name
*/}}
{{- define "graylog.elasticsearch.hosts" -}}
{{- if .Values.graylog.elasticsearch.hosts }}
{{- if .Values.graylog.elasticsearch.uriSecretKey }}
{{- printf "${GRAYLOG_ELASTICSEARCH_HOST}" -}}
{{- else if .Values.graylog.elasticsearch.hosts }}
{{- .Values.graylog.elasticsearch.hosts -}}
{{- else }}
{{- printf "http://%s-elasticsearch-client.%s.svc.cluster.local:9200" .Release.Name .Release.Namespace -}}
@@ -89,7 +91,9 @@ Create a default fully qualified mongodb name or use the `graylog.mongodb.uri` v
Or use chart dependencies with release name
*/}}
{{- define "graylog.mongodb.uri" -}}
{{- if .Values.graylog.mongodb.uri }}
{{- if .Values.graylog.mongodb.uriSecretKey }}
{{- printf "${GRAYLOG_MONGODB_URI}" -}}
{{- else if .Values.graylog.mongodb.uri }}
{{- .Values.graylog.mongodb.uri -}}
{{- else }}
{{- printf "mongodb://%s-mongodb-replicaset.%s.svc.cluster.local:27017/graylog?replicaSet=rs0" .Release.Name .Release.Namespace -}}
+8
View File
@@ -186,6 +186,10 @@ data:
echo "Starting graylog"
# Original docker-entrypoint.sh in Graylog Docker will error while executing since you can't chown readonly files in `config`
# exec /docker-entrypoint.sh graylog
{{- if or (.Values.graylog.elasticsearch.uriSecretKey) (.Values.graylog.mongodb.uriSecretKey) }}
# Interpolate
sed 's/"/\\\"/g;s/.*/echo "&"/e' ${GRAYLOG_HOME}/config/graylog.conf > ${GRAYLOG_HOME}/graylog.conf.subst
{{- end }}
echo "Graylog Home ${GRAYLOG_HOME}"
echo "JVM Options ${GRAYLOG_SERVER_JAVA_OPTS}"
"${JAVA_HOME}/bin/java" \
@@ -196,4 +200,8 @@ data:
-Dgraylog2.installation_source=docker \
${GRAYLOG_HOME}/graylog.jar \
server \
{{- if or (.Values.graylog.elasticsearch.uriSecretKey) (.Values.graylog.mongodb.uriSecretKey) }}
-f ${GRAYLOG_HOME}/graylog.conf.subst
{{- else }}
-f ${GRAYLOG_HOME}/config/graylog.conf
{{- end }}
+14
View File
@@ -102,6 +102,20 @@ spec:
secretKeyRef:
name: {{ .Values.graylog.existingRootSecret | default (include "graylog.fullname" .) }}
key: graylog-password-sha2
{{- if .Values.graylog.elasticsearch.uriSecretKey }}
- name: GRAYLOG_ELASTICSEARCH_HOST
valueFrom:
secretKeyRef:
name: {{ .Values.graylog.elasticsearch.uriSecretName | default (include "graylog.fullname" .) }}
key: {{ .Values.graylog.elasticsearch.uriSecretKey }}
{{- end }}
{{- if .Values.graylog.mongodb.uriSecretKey }}
- name: GRAYLOG_MONGODB_URI
valueFrom:
secretKeyRef:
name: {{ .Values.graylog.mongodb.uriSecretName | default (include "graylog.fullname" .) }}
key: {{ .Values.graylog.mongodb.uriSecretKey }}
{{- end }}
{{- range $key, $value := .Values.graylog.env }}
- name: {{ $key }}
value: {{ $value | quote }}
+8
View File
@@ -270,12 +270,20 @@ graylog:
##
# hosts: http://elasticsearch-client.graylog.svc.cluster.local:9200
hosts: ""
# Allow elasticsearch hosts to be fetched from a k8s secret
# {{ graylog.fullname }} will be used as uriSecretName if left empty
uriSecretName: ""
uriSecretKey: ""
mongodb:
## MongoDB connection string
## See https://docs.mongodb.com/manual/reference/connection-string/ for details
# uri: mongodb://user:pass@host1:27017,host2:27017,host3:27017/graylog?replicaSet=rs01
uri: ""
# Allow mongodb uri to be fetched from a k8s secret
# {{ graylog.fullname }} will be used as uriSecretName if left empty
uriSecretName: ""
uriSecretKey: ""
## Increase this value according to the maximum connections your MongoDB server can handle from a single client
## if you encounter MongoDB connection problems.