diff --git a/stable/graylog/Chart.yaml b/stable/graylog/Chart.yaml index 7be09851ab..64261ba4ee 100755 --- a/stable/graylog/Chart.yaml +++ b/stable/graylog/Chart.yaml @@ -1,7 +1,7 @@ apiVersion: v1 name: graylog home: https://www.graylog.org -version: 1.4.0 +version: 1.4.1 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: diff --git a/stable/graylog/templates/configmap.yaml b/stable/graylog/templates/configmap.yaml index 0f04277316..c06729fa51 100644 --- a/stable/graylog/templates/configmap.yaml +++ b/stable/graylog/templates/configmap.yaml @@ -141,15 +141,23 @@ data: MASTER_NAME="{{ template "graylog.fullname" . }}-master.{{ .Release.Namespace }}.svc.cluster.local" # Looking for Master IP 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}'` + SELF_IP=`/k8s/kubectl --namespace {{ .Release.Namespace }} get pod $HOSTNAME -o jsonpath='{.status.podIP}'` echo "Current master is $MASTER_IP" + echo "Self IP is $SELF_IP" if [[ -z "$MASTER_IP" ]]; then echo "Launching $HOSTNAME as master" export GRAYLOG_IS_MASTER="true" /k8s/kubectl --namespace {{ .Release.Namespace }} label --overwrite pod $HOSTNAME graylog-role="master" else - echo "Launching $HOSTNAME as coordinating" - export GRAYLOG_IS_MASTER="false" - /k8s/kubectl --namespace {{ .Release.Namespace }} label --overwrite pod $HOSTNAME graylog-role="coordinating" + # When container was recreated or restart, MASTER_IP == SELF_IP, running as master and no need to change label graylog-role="master" + if [ "$SELF_IP" == "$MASTER_IP" ];then + export GRAYLOG_IS_MASTER="true" + else + # MASTER_IP != SELF_IP, running as coordinating + echo "Launching $HOSTNAME as coordinating" + export GRAYLOG_IS_MASTER="false" + /k8s/kubectl --namespace {{ .Release.Namespace }} label --overwrite pod $HOSTNAME graylog-role="coordinating" + fi fi # Download plugins {{- if .Values.graylog.plugins }}