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
This commit is contained in:
Steve Wilkerson 2019-01-15 16:07:46 -06:00
parent 6bd70a9fc6
commit 00b40480a3
5 changed files with 33 additions and 5 deletions

View File

@ -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 }}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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