Skip to content

Commit 0c4fb5b

Browse files
committed
clean-up kubectl since graylog detects the masternode now, supply data_dir for graylog 6
Signed-off-by: metron2 <derek.griffiths@cyber.gc.ca>
1 parent 1e7274b commit 0c4fb5b

File tree

3 files changed

+11
-50
lines changed

3 files changed

+11
-50
lines changed

charts/graylog/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: v2
22
name: graylog
33
home: https://www.graylog.org
4-
version: 2.3.7
4+
version: 2.3.8
55
appVersion: 5.2.6
66
description: Graylog is the centralized log management solution built to open
77
standards for capturing, storing, and enabling real-time analysis of terabytes

charts/graylog/templates/configmap.yaml

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ data:
149149
{{- end }}
150150
{{- if .Values.graylog.trustedProxies }}
151151
trusted_proxies = {{.Values.graylog.trustedProxies}}
152+
data_dir = /usr/share/graylog/data
152153
{{- end }}
153154
{{- if .Values.graylog.config }}
154155
{{ .Values.graylog.config | indent 4 }}
@@ -162,36 +163,6 @@ data:
162163
find ${GRAYLOG_HOME}/plugins-default/ -type f -exec cp {} ${GRAYLOG_PLUGIN_DIR} \;
163164
# Looking for Master IP
164165
retry=1
165-
for i in {0..2}
166-
do
167-
MASTER_IP=`/k8s/kubectl --namespace {{ .Release.Namespace }} get pod -o jsonpath='{range .items[*]}{.metadata.name} {.status.podIP}{"\n"}{end}' -l graylog-role=master --field-selector=status.phase=Running|awk '{print $2}'`
168-
SELF_IP=`/k8s/kubectl --namespace {{ .Release.Namespace }} get pod $HOSTNAME -o jsonpath='{.status.podIP}'`
169-
echo "Current master is $MASTER_IP"
170-
echo "Self IP is $SELF_IP"
171-
retry=$((retry+1))
172-
[[ ! -z "$MASTER_IP" ]] && break
173-
echo "[Try ${retry}/3] Waiting for master node..."
174-
sleep 2
175-
done
176-
if [[ -z "$MASTER_IP" ]]; then
177-
echo "Launching $HOSTNAME as master"
178-
export GRAYLOG_IS_MASTER="true"
179-
export GRAYLOG_IS_LEADER="true"
180-
/k8s/kubectl --namespace {{ .Release.Namespace }} label --overwrite pod $HOSTNAME graylog-role="master"
181-
else
182-
# When container was recreated or restart, MASTER_IP == SELF_IP, running as master and no need to change label graylog-role="master"
183-
if [ "$SELF_IP" == "$MASTER_IP" ];then
184-
echo "Launching $HOSTNAME as master"
185-
export GRAYLOG_IS_MASTER="true"
186-
export GRAYLOG_IS_LEADER="true"
187-
else
188-
# MASTER_IP != SELF_IP, running as coordinating
189-
echo "Launching $HOSTNAME as coordinating"
190-
export GRAYLOG_IS_MASTER="false"
191-
export GRAYLOG_IS_LEADER="false"
192-
/k8s/kubectl --namespace {{ .Release.Namespace }} label --overwrite pod $HOSTNAME graylog-role="coordinating"
193-
fi
194-
fi
195166
# Download plugins
196167
{{- if .Values.graylog.plugins.proxy.enabled }}
197168
export https_proxy={{ .Values.graylog.plugins.proxy.host }}

charts/graylog/templates/statefulset.yaml

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ metadata:
77
{{- with .Values.graylog.customLabels }}
88
{{ . | toYaml | indent 4 }}
99
{{- end }}
10+
{{ $graylogVersion := .Values.graylog.image.tag | default .Chart.AppVersion }}
1011
spec:
1112
serviceName: {{ template "graylog.service.headless.name" . }}
1213
replicas: {{ .Values.graylog.replicas }}
@@ -74,14 +75,6 @@ spec:
7475
rm -rf /usr/share/graylog/data/journal/messagejournal-0
7576
rm -rf /usr/share/graylog/data/journal/recovery-point-offset-checkpoint
7677
{{- end }}
77-
{{- if .Values.graylog.init.kubectlLocation }}
78-
wget {{ .Values.graylog.init.kubectlLocation }} -O /k8s/kubectl
79-
{{- else }}
80-
{{.Capabilities.KubeVersion}}
81-
wget https://dl.k8s.io/release/{{ .Values.graylog.init.kubectlVersion | default (regexReplaceAll "-.+" .Capabilities.KubeVersion.Version "") }}/bin/linux/amd64/kubectl -O /k8s/kubectl
82-
{{- end }}
83-
chmod +x /k8s/kubectl
84-
8578
GRAYLOG_HOME=/usr/share/graylog
8679
chown -R 1100:1100 ${GRAYLOG_HOME}/data/
8780
securityContext:
@@ -94,8 +87,6 @@ spec:
9487
volumeMounts:
9588
- name: journal
9689
mountPath: /usr/share/graylog/data/journal
97-
- name: kubectl
98-
mountPath: /k8s
9990
{{- if .Values.graylog.init.resources }}
10091
resources:
10192
{{ toYaml .Values.graylog.init.resources | indent 12 }}
@@ -110,6 +101,12 @@ spec:
110101
command:
111102
- /entrypoint.sh
112103
env:
104+
# Kubernetes Auto Master Selection
105+
# https://go2docs.graylog.org/5-0/downloading_and_installing_graylog/docker_installation.htm#KubernetesAutomaticMasterSelection
106+
- name: POD_NAME
107+
valueFrom:
108+
fieldRef:
109+
fieldPath: metadata.name
113110
- name: GRAYLOG_SERVER_JAVA_OPTS
114111
{{- $javaOpts := .Values.graylog.javaOpts }}
115112
{{- if .Values.graylog.heapSize }}
@@ -231,26 +228,21 @@ spec:
231228
- name: files
232229
mountPath: /etc/graylog/server
233230
{{- end }}
234-
- name: kubectl
235-
mountPath: /k8s
231+
236232
{{- if .Values.graylog.extraVolumeMounts }}
237233
{{ toYaml .Values.graylog.extraVolumeMounts | nindent 12 }}
238234
{{- end }}
239-
{{ $graylogVersion := .Values.graylog.image.tag | default .Chart.AppVersion }}
240-
{{- if semverCompare "< 4.2.0-0" ( $graylogVersion ) }}
241235
lifecycle:
242236
preStop:
243237
exec:
244238
command:
245239
- bash
246240
- -ec
247241
- |
248-
ROOT_PASSWORD=`/k8s/kubectl get secret {{ template "graylog.fullname" . }} -o "jsonpath={.data['graylog-password-secret']}" | base64 -d`
249242
curl {{ if .Values.graylog.tls.enabled }}-k{{ end }} -XPOST -sS \
250-
-u "{{ .Values.graylog.rootUsername }}:${ROOT_PASSWORD}" \
243+
-u "{{ .Values.graylog.rootUsername }}:${GRAYLOG_PASSWORD_SECRET}" \
251244
-H "X-Requested-By: {{ template "graylog.fullname" . }}" \
252245
{{ template "graylog.formatUrl" (list . "localhost:9000/api/system/shutdown/shutdown") }}
253-
{{- end }}
254246
{{- if .Values.graylog.sidecarContainers }}
255247
{{ toYaml .Values.graylog.sidecarContainers | nindent 8 }}
256248
{{- end }}
@@ -278,8 +270,6 @@ spec:
278270
configMap:
279271
name: {{ template "graylog.fullname" . }}-files
280272
{{- end }}
281-
- name: kubectl
282-
emptyDir: {}
283273
{{- if .Values.graylog.extraVolumes }}
284274
{{ toYaml .Values.graylog.extraVolumes | nindent 8 }}
285275
{{- end }}

0 commit comments

Comments
 (0)