From 00b40480a3ec726cd0785ba3e4930a61dcc8535d Mon Sep 17 00:00:00 2001 From: Steve Wilkerson Date: Tue, 15 Jan 2019 16:07:46 -0600 Subject: [PATCH] Nagios: Fix elasticsearch query clause volume mount This fixes the Nagios volume mount for the Elasticsearch query file. Previously, the check for adding the volumemount to the pod definition was incorrect. This fixes the conditional check, and also adds the same conditional check to the configuration secret This adds a simple check to the monitoring and multinode jobs to validate the resulting json gets mounted into the pod successfully Change-Id: I2af289ccc4e1cff1669cb5e6e829514781b14dd3 --- nagios/templates/configmap-etc.yaml | 2 ++ nagios/templates/deployment.yaml | 4 ++-- nagios/values.yaml | 2 +- tools/deployment/multinode/110-nagios.sh | 16 +++++++++++++++- .../osh-infra-monitoring/110-nagios.sh | 14 +++++++++++++- 5 files changed, 33 insertions(+), 5 deletions(-) diff --git a/nagios/templates/configmap-etc.yaml b/nagios/templates/configmap-etc.yaml index a8b88d3b73..27110677d2 100644 --- a/nagios/templates/configmap-etc.yaml +++ b/nagios/templates/configmap-etc.yaml @@ -34,7 +34,9 @@ type: Opaque data: cgi.cfg: {{ include "nagios.utils.to_nagios_conf" .Values.conf.nagios.cgi | b64enc }} nagios.cfg: {{ include "nagios.utils.to_nagios_conf" .Values.conf.nagios.nagios | b64enc }} + {{- if not (empty .Values.conf.nagios.query_es_clauses) }} query_es_clauses.json: {{ .Values.conf.nagios.query_es_clauses | toJson | b64enc }} + {{- end }} nagios_objects.cfg: {{ include "configmap_etc._nagios_objects" $ | b64enc }} #NOTE(portdirect): this must be last, to work round helm ~2.7 bug. {{- include "helm-toolkit.snippets.values_template_renderer" (dict "envAll" $envAll "template" .Values.conf.httpd "key" "httpd.conf" "format" "Secret") | indent 2 }} diff --git a/nagios/templates/deployment.yaml b/nagios/templates/deployment.yaml index bf56cac685..5e32f0e6d4 100644 --- a/nagios/templates/deployment.yaml +++ b/nagios/templates/deployment.yaml @@ -190,12 +190,12 @@ spec: mountPath: /opt/nagios/etc/nagios_objects.cfg subPath: nagios_objects.cfg readOnly: true -{{- if .Values.conf.es_query_clauses }} +{{- if not (empty .Values.conf.nagios.query_es_clauses) }} - name: nagios-etc mountPath: /opt/nagios/etc/objects/query_es_clauses.json subPath: query_es_clauses.json readOnly: true -{{ end }} +{{- end }} - name: pod-var-log mountPath: /opt/nagios/var/log readOnly: false diff --git a/nagios/values.yaml b/nagios/values.yaml index a11df1d580..7e7ea570ae 100644 --- a/nagios/values.yaml +++ b/nagios/values.yaml @@ -1190,4 +1190,4 @@ conf: http: primary_target: 127.0.0.1:3904/events secondary_target: 127.0.0.1:3904/events - query_es_clauses: "null" + query_es_clauses: null diff --git a/tools/deployment/multinode/110-nagios.sh b/tools/deployment/multinode/110-nagios.sh index e40ffd9d33..359c93db1c 100755 --- a/tools/deployment/multinode/110-nagios.sh +++ b/tools/deployment/multinode/110-nagios.sh @@ -20,12 +20,26 @@ set -xe make nagios #NOTE: Deploy command +tee /tmp/nagios.yaml << EOF +pod: + replicas: + nagios: 3 +conf: + nagios: + query_es_clauses: + test_es_query: + hello: world +EOF helm upgrade --install nagios ./nagios \ --namespace=osh-infra \ - --set pod.replicas.nagios=3 + --values=/tmp/nagios.yaml #NOTE: Wait for deploy ./tools/deployment/common/wait-for-pods.sh osh-infra #NOTE: Validate Deployment info helm status nagios + +#NOTE: Verify elasticsearch query clauses are functional by execing into pod +NAGIOS_POD=$(kubectl -n osh-infra get pods -l='application=nagios,component=monitoring' --output=jsonpath='{.items[0].metadata.name}') +kubectl exec $NAGIOS_POD -n osh-infra -c nagios -- cat /opt/nagios/etc/objects/query_es_clauses.json | python -m json.tool diff --git a/tools/deployment/osh-infra-monitoring/110-nagios.sh b/tools/deployment/osh-infra-monitoring/110-nagios.sh index f47e25556d..d9f1085fac 100755 --- a/tools/deployment/osh-infra-monitoring/110-nagios.sh +++ b/tools/deployment/osh-infra-monitoring/110-nagios.sh @@ -20,11 +20,23 @@ set -xe make nagios #NOTE: Deploy command +tee /tmp/nagios.yaml << EOF +conf: + nagios: + query_es_clauses: + test_es_query: + hello: world +EOF helm upgrade --install nagios ./nagios \ - --namespace=osh-infra + --namespace=osh-infra \ + --values=/tmp/nagios.yaml #NOTE: Wait for deploy ./tools/deployment/common/wait-for-pods.sh osh-infra #NOTE: Validate Deployment info helm status nagios + +#NOTE: Verify elasticsearch query clauses are functional by execing into pod +NAGIOS_POD=$(kubectl -n osh-infra get pods -l='application=nagios,component=monitoring' --output=jsonpath='{.items[0].metadata.name}') +kubectl exec $NAGIOS_POD -n osh-infra -c nagios -- cat /opt/nagios/etc/objects/query_es_clauses.json | python -m json.tool