From 6877582cd8adab52bf8bdef64010ce7f0509e491 Mon Sep 17 00:00:00 2001 From: Nick Troast Date: Mon, 18 Feb 2019 02:52:27 -0800 Subject: [PATCH] [stable/prometheus-operator] allow empty ruleSelector and ruleNamespaceSelector (#11395) Currently an empty ruleSelector or ruleNamespaceSelector does not select all PrometheusRules or Namespaces respectively. Fix the prometheus template to allow empty ruleSelector and ruleNamespaceSelector. Signed-off-by: Nick Troast --- stable/prometheus-operator/Chart.yaml | 2 +- stable/prometheus-operator/README.md | 8 ++++---- .../templates/prometheus/prometheus.yaml | 7 +++++-- stable/prometheus-operator/values.yaml | 20 +++++++++---------- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/stable/prometheus-operator/Chart.yaml b/stable/prometheus-operator/Chart.yaml index f8f26ae0aa..e02edba0c1 100644 --- a/stable/prometheus-operator/Chart.yaml +++ b/stable/prometheus-operator/Chart.yaml @@ -9,7 +9,7 @@ name: prometheus-operator sources: - https://github.com/coreos/prometheus-operator - https://coreos.com/operators/prometheus -version: 2.2.2 +version: 2.2.3 appVersion: 0.26.0 home: https://github.com/coreos/prometheus-operator keywords: diff --git a/stable/prometheus-operator/README.md b/stable/prometheus-operator/README.md index e8493f4413..fd046c62a6 100644 --- a/stable/prometheus-operator/README.md +++ b/stable/prometheus-operator/README.md @@ -148,8 +148,8 @@ The following tables lists the configurable parameters of the prometheus-operato | `prometheus.additionalServiceMonitors` | List of `serviceMonitor` objects to create. See https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#servicemonitorspec | `[]` | | `prometheus.prometheusSpec.podMetadata` | Standard object’s metadata. More info: https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#metadata Metadata Labels and Annotations gets propagated to the prometheus pods. | `{}` | | `prometheus.prometheusSpec.serviceMonitorSelectorNilUsesHelmValues` | If true, a nil or {} value for prometheus.prometheusSpec.serviceMonitorSelector will cause the prometheus resource to be created with selectors based on values in the helm deployment, which will also match the servicemonitors created | `true` | -| `prometheus.prometheusSpec.serviceMonitorSelector` | ServiceMonitors to be selected for target discovery. | `{}` | -| `prometheus.prometheusSpec.serviceMonitorNamespaceSelector` | Namespaces to be selected for ServiceMonitor discovery. If nil, only check own namespace. | `{}` | +| `prometheus.prometheusSpec.serviceMonitorSelector` | ServiceMonitors to be selected for target discovery. If {}, select all ServiceMonitors | `{}` | +| `prometheus.prometheusSpec.serviceMonitorNamespaceSelector` | Namespaces to be selected for ServiceMonitor discovery. If nil, select own namespace. If {}, select all namespaces. | `{}` | | `prometheus.prometheusSpec.image.repository` | Base image to use for a Prometheus deployment. | `quay.io/prometheus/prometheus` | | `prometheus.prometheusSpec.image.tag` | Tag of Prometheus container image to be deployed. | `v2.5.0` | | `prometheus.prometheusSpec.paused` | When a Prometheus deployment is paused, no actions except for deletion will be performed on the underlying objects. | `false` | @@ -163,8 +163,8 @@ The following tables lists the configurable parameters of the prometheus-operato | `prometheus.prometheusSpec.routePrefix` | The route prefix Prometheus registers HTTP handlers for. This is useful, if using ExternalURL and a proxy is rewriting HTTP routes of a request, and the actual ExternalURL is still true, but the server serves requests under a different route prefix. For example for use with `kubectl proxy`. | `/` | | `prometheus.prometheusSpec.storageSpec` | Storage spec to specify how storage shall be used. | `{}` | | `prometheus.prometheusSpec.ruleSelectorNilUsesHelmValues` | If true, a nil or {} value for prometheus.prometheusSpec.ruleSelector will cause the prometheus resource to be created with selectors based on values in the helm deployment, which will also match the PrometheusRule resources created. | `true` | -| `prometheus.prometheusSpec.ruleSelector` | A selector to select which PrometheusRules to mount for loading alerting rules from. Until (excluding) Prometheus Operator v0.24.0 Prometheus Operator will migrate any legacy rule ConfigMaps to PrometheusRule custom resources selected by RuleSelector. Make sure it does not match any config maps that you do not want to be migrated. | `{}` | -| `prometheus.prometheusSpec.ruleNamespaceSelector` | Namespaces to be selected for PrometheusRules discovery. If unspecified, only the same namespace as the Prometheus object is in is used. | `{}` | +| `prometheus.prometheusSpec.ruleSelector` | A selector to select which PrometheusRules to mount for loading alerting rules from. Until (excluding) Prometheus Operator v0.24.0 Prometheus Operator will migrate any legacy rule ConfigMaps to PrometheusRule custom resources selected by RuleSelector. Make sure it does not match any config maps that you do not want to be migrated. If {}, select all PrometheusRules | `{}` | +| `prometheus.prometheusSpec.ruleNamespaceSelector` | Namespaces to be selected for PrometheusRules discovery. If nil, select own namespace. If {}, select all namespaces. | `{}` | | `prometheus.prometheusSpec.alertingEndpoints` | Alertmanagers to which alerts will be sent https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#alertmanagerendpoints Default configuration will connect to the alertmanager deployed as part of this release | `[]` | | `prometheus.prometheusSpec.resources` | Define resources requests and limits for single Pods. | `{}` | | `prometheus.prometheusSpec.nodeSelector` | Define which Nodes the Pods are scheduled on. | `{}` | diff --git a/stable/prometheus-operator/templates/prometheus/prometheus.yaml b/stable/prometheus-operator/templates/prometheus/prometheus.yaml index f528b2e151..97fa2da3fa 100644 --- a/stable/prometheus-operator/templates/prometheus/prometheus.yaml +++ b/stable/prometheus-operator/templates/prometheus/prometheus.yaml @@ -93,10 +93,11 @@ spec: securityContext: {{ toYaml .Values.prometheus.prometheusSpec.securityContext | indent 4 }} {{- end }} - {{- if .Values.prometheus.prometheusSpec.ruleNamespaceSelector }} ruleNamespaceSelector: {{ toYaml .Values.prometheus.prometheusSpec.ruleNamespaceSelector | indent 4 }} +{{ else }} + ruleNamespaceSelector: {} {{- end }} {{- if .Values.prometheus.prometheusSpec.ruleSelector }} ruleSelector: @@ -106,7 +107,9 @@ spec: matchLabels: app: {{ template "prometheus-operator.name" . }} release: {{ .Release.Name | quote }} - {{- end }} +{{ else }} + ruleSelector: {} +{{- end }} {{- if .Values.prometheus.prometheusSpec.storageSpec }} storage: {{ toYaml .Values.prometheus.prometheusSpec.storageSpec | indent 4 }} diff --git a/stable/prometheus-operator/values.yaml b/stable/prometheus-operator/values.yaml index 161974cc39..d358325697 100644 --- a/stable/prometheus-operator/values.yaml +++ b/stable/prometheus-operator/values.yaml @@ -798,7 +798,7 @@ prometheus: configMaps: [] ## Namespaces to be selected for PrometheusRules discovery. - ## If unspecified, only the same namespace as the Prometheus object is in is used. + ## If nil, select own namespace. If {}, select all namespaces. ## ruleNamespaceSelector: {} @@ -808,10 +808,8 @@ prometheus: ## ruleSelectorNilUsesHelmValues: true - ## Rules CRD selector - ## ref: https://github.com/coreos/prometheus-operator/blob/master/Documentation/design.md - ## If unspecified the release `app` and `release` will be used as the label selector - ## to load rules + ## PrometheusRules to be selected for target discovery. + ## If {}, select all ServiceMonitors ## ruleSelector: {} ## Example which select all prometheusrules resources @@ -835,17 +833,17 @@ prometheus: ## serviceMonitorSelectorNilUsesHelmValues: true - ## serviceMonitorSelector will limit which servicemonitors are used to create scrape - ## configs in Prometheus. See serviceMonitorSelectorUseHelmLabels + ## ServiceMonitors to be selected for target discovery. + ## If {}, select all ServiceMonitors ## serviceMonitorSelector: {} - - # serviceMonitorSelector: {} + ## Example which selects ServiceMonitors with label "prometheus" set to "somelabel" + # serviceMonitorSelector: # matchLabels: # prometheus: somelabel - ## serviceMonitorNamespaceSelector will limit namespaces from which serviceMonitors are used to create scrape - ## configs in Prometheus. By default all namespaces will be used + ## Namespaces to be selected for ServiceMonitor discovery. + ## If nil, select own namespace. If {}, select all namespaces. ## serviceMonitorNamespaceSelector: {}