From a63f3b3662f00515b877b81bf7f11074b919972c Mon Sep 17 00:00:00 2001 From: Steve Wilkerson Date: Tue, 9 Apr 2019 08:39:57 -0500 Subject: [PATCH] MariaDB: Add network policy template for mysql exporter This adds the network policy template and overrides for the mysql prometheus exporter. Change-Id: I83b526d11fe25f45b02a7e797b785b8ad59c7848 --- .../prometheus/exporter-deployment.yaml | 6 +++--- .../prometheus/exporter-job-create-user.yaml | 2 +- .../prometheus/exporter-network-policy.yaml | 20 +++++++++++++++++++ .../prometheus/exporter-service.yaml | 4 ++-- mariadb/values.yaml | 1 + .../deployment/network-policy/045-mariadb.sh | 15 ++++++++++++++ 6 files changed, 42 insertions(+), 6 deletions(-) create mode 100644 mariadb/templates/monitoring/prometheus/exporter-network-policy.yaml diff --git a/mariadb/templates/monitoring/prometheus/exporter-deployment.yaml b/mariadb/templates/monitoring/prometheus/exporter-deployment.yaml index 275d1c798..20019269c 100644 --- a/mariadb/templates/monitoring/prometheus/exporter-deployment.yaml +++ b/mariadb/templates/monitoring/prometheus/exporter-deployment.yaml @@ -25,17 +25,17 @@ kind: Deployment metadata: name: prometheus-mysql-exporter labels: -{{ tuple $envAll "prometheus_mysql_exporter" "exporter" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }} +{{ tuple $envAll "prometheus-mysql-exporter" "exporter" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }} spec: replicas: {{ .Values.pod.replicas.prometheus_mysql_exporter }} selector: matchLabels: -{{ tuple $envAll "prometheus_mysql_exporter" "exporter" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 6 }} +{{ tuple $envAll "prometheus-mysql-exporter" "exporter" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 6 }} {{ tuple $envAll | include "helm-toolkit.snippets.kubernetes_upgrades_deployment" | indent 2 }} template: metadata: labels: -{{ tuple $envAll "prometheus_mysql_exporter" "exporter" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }} +{{ tuple $envAll "prometheus-mysql-exporter" "exporter" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }} namespace: {{ .Values.endpoints.prometheus_mysql_exporter.namespace }} spec: {{ dict "envAll" $envAll "application" "mysql_exporter" | include "helm-toolkit.snippets.kubernetes_pod_security_context" | indent 6 }} diff --git a/mariadb/templates/monitoring/prometheus/exporter-job-create-user.yaml b/mariadb/templates/monitoring/prometheus/exporter-job-create-user.yaml index 69c15ed8e..f7688a538 100644 --- a/mariadb/templates/monitoring/prometheus/exporter-job-create-user.yaml +++ b/mariadb/templates/monitoring/prometheus/exporter-job-create-user.yaml @@ -29,7 +29,7 @@ spec: template: metadata: labels: -{{ tuple $envAll "prometheus_mysql_exporter" "create-sql-user" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }} +{{ tuple $envAll "prometheus-mysql-exporter" "create-sql-user" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }} spec: shareProcessNamespace: true serviceAccountName: {{ $serviceAccountName }} diff --git a/mariadb/templates/monitoring/prometheus/exporter-network-policy.yaml b/mariadb/templates/monitoring/prometheus/exporter-network-policy.yaml new file mode 100644 index 000000000..10433ef4c --- /dev/null +++ b/mariadb/templates/monitoring/prometheus/exporter-network-policy.yaml @@ -0,0 +1,20 @@ +{{/* +Copyright 2019 The Openstack-Helm Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/}} + +{{- if and .Values.manifests.monitoring.prometheus.network_policy_exporter .Values.monitoring.prometheus.enabled -}} +{{- $netpol_opts := dict "envAll" . "name" "application" "label" "prometheus-mysql-exporter" -}} +{{ $netpol_opts | include "helm-toolkit.manifests.kubernetes_network_policy" }} +{{- end -}} diff --git a/mariadb/templates/monitoring/prometheus/exporter-service.yaml b/mariadb/templates/monitoring/prometheus/exporter-service.yaml index 71bfd5cea..df5bcedb7 100644 --- a/mariadb/templates/monitoring/prometheus/exporter-service.yaml +++ b/mariadb/templates/monitoring/prometheus/exporter-service.yaml @@ -23,7 +23,7 @@ kind: Service metadata: name: {{ tuple "prometheus_mysql_exporter" "internal" . | include "helm-toolkit.endpoints.hostname_short_endpoint_lookup" }} labels: -{{ tuple $envAll "prometheus_mysql_exporter" "metrics" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }} +{{ tuple $envAll "prometheus-mysql-exporter" "metrics" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }} annotations: {{- if .Values.monitoring.prometheus.enabled }} {{ tuple $prometheus_annotations | include "helm-toolkit.snippets.prometheus_service_annotations" | indent 4 }} @@ -33,5 +33,5 @@ spec: - name: metrics port: {{ tuple "prometheus_mysql_exporter" "internal" "metrics" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }} selector: -{{ tuple $envAll "prometheus_mysql_exporter" "exporter" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }} +{{ tuple $envAll "prometheus-mysql-exporter" "exporter" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }} {{- end }} diff --git a/mariadb/values.yaml b/mariadb/values.yaml index 8d0d0cec0..2fbcaa284 100644 --- a/mariadb/values.yaml +++ b/mariadb/values.yaml @@ -392,6 +392,7 @@ manifests: job_user_create: true secret_etc: true service_exporter: true + network_policy_exporter: false pdb_server: true network_policy: false pod_test: true diff --git a/tools/deployment/network-policy/045-mariadb.sh b/tools/deployment/network-policy/045-mariadb.sh index 011b0a707..32a3c992b 100755 --- a/tools/deployment/network-policy/045-mariadb.sh +++ b/tools/deployment/network-policy/045-mariadb.sh @@ -22,7 +22,19 @@ make mariadb tee /tmp/mariadb.yaml <