charts icon indicating copy to clipboard operation
charts copied to clipboard

[stable/prometheus-operator] not recognizing matchNames in *NamespaceSelector

Open ryuheechul opened this issue 6 years ago • 37 comments

Describe the bug A clear and concise description of what the bug is.

Version of Helm and Kubernetes: helm: v3.0.3, k8s: v1.15.8-gke.2

Which chart: stable/prometheus-operator

What happened: I got the error below when I try to install a chart via terraform

Error: unable to build kubernetes objects from release manifest: error validating "": error validating data: [ValidationError(Prometheus.spec.ruleNamespaceSelector): unknown field "matchNames" in com.coreos.monitoring.v1.Prometheus.spec.ruleNamespaceSelector, ValidationError(Prometheus.spec.serviceMonitorNamespaceSelector): unknown field "matchNames" in com.coreos.monitoring.v1.Prometheus.spec.serviceMonitorNamespaceSelector]

So I checked code in CRD https://github.com/helm/charts/blob/a97695fcdfbe61599ffd3a92f1ca672e5319ee54/stable/prometheus-operator/crds/crd-prometheus.yaml#L3247-L3290 https://github.com/helm/charts/blob/a97695fcdfbe61599ffd3a92f1ca672e5319ee54/stable/prometheus-operator/crds/crd-prometheus.yaml#L3890-L3934 https://github.com/helm/charts/blob/a97695fcdfbe61599ffd3a92f1ca672e5319ee54/stable/prometheus-operator/crds/crd-prometheus.yaml#L4136-L4169

and it turns out there is no matchNames in the spec but instead there is matchLabels which I think maybe wrong? according to https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#namespaceselector

What you expected to happen:

recognise matchNames in *NamespaceSelector and properly install

How to reproduce it (as minimally and precisely as possible): pick any NamespaceSelector and add matchNames and try installing

# values.yaml
prometheus:
  prometheusSpec:
    serviceMonitorNamespaceSelector:
      matchNames:
        - my-namespace

Anything else we need to know:

even though I don't think it's related to terraform or helm provider I will leave the version info here. So I used terraform 0.12.20 and terraform helm provider 1.0.0

ryuheechul avatar Feb 06 '20 12:02 ryuheechul

Version of Helm and Kubernetes: helm: v3.0.3, k8s: v1.16.3

Error:

error validating "": error validating data: ValidationError(Prometheus.spec.storage.volumeClaimTemplate): unknown field "selector" in com.coreos.monitoring.v1.Prometheus.spec.storage.volumeClaimTemplate

I don't know if my issue is directly linked with this one..

tux-00 avatar Feb 07 '20 10:02 tux-00

I'm getting the same error when trying to use the any: true option that is also described in the documentation. It looks like either the documentation or the CRD is incorrect. How can one have it select all namespaces?

Error: UPGRADE FAILED: error validating "": error validating data: [ValidationError(Prometheus.spec.podMonitorNamespaceSelector): unknown field "any" in com.coreos.monitoring.v1.Prometheus.spec.podMonitorNamespaceSelector, ValidationError(Prometheus.spec.ruleNamespaceSelector): unknown field "any" in com.coreos.monitoring.v1.Prometheus.spec.ruleNamespaceSelector, ValidationError(Prometheus.spec.serviceMonitorNamespaceSelector): unknown field "any" in com.coreos.monitoring.v1.Prometheus.spec.serviceMonitorNamespaceSelector]

bekriebel avatar Feb 25 '20 02:02 bekriebel

Same here with Helm v3.1.1 and latest chart 8.10.0 with any: true

error validating data: [ValidationError(Prometheus.spec.ruleNamespaceSelector): unknown field \"any\" in com.coreos.monitoring.v1.Prometheus.spec.ruleNamespaceSelector, ValidationError(Prometheus.spec.serviceMonitorNamespaceSelector): unknown field \"any\" in com.coreos.monitoring.v1.Prometheus.spec.serviceMonitorNamespaceSelector]"

ArchiFleKs avatar Mar 02 '20 09:03 ArchiFleKs

Same here with Helm v3.0.0

dbellt avatar Mar 05 '20 02:03 dbellt

Also getting this error with Helm v3:

prometheus:
  prometheusSpec:
      ruleNamespaceSelector:
        any: true

      serviceMonitorNamespaceSelector:
        any: true
error validating data: [ValidationError(Prometheus.spec.ruleNamespaceSelector): unknown field "any" in com.coreos.monitoring.v1.Prometheus.spec.ruleNamespaceSelector, ValidationError(Prometheus.spec.serviceMonitorNamespaceSelector): unknown field "any" in com.coreos.monitoring.v1.Prometheus.spec.serviceMonitorNamespaceSelector]

Edit: Removing the any fields allows the deploy to continue. Looking at the CRD the any field is removed as well, seems like Prometheus might be watching all namespaces by default now? I can see existing service monitors are still active with the fields removed.

servo1x avatar Mar 08 '20 09:03 servo1x

@servo1x The comments say, it would only watch its own namespace by default:

  • https://github.com/helm/charts/blob/master/stable/prometheus-operator/crds/crd-prometheus.yaml#L3890
  • https://github.com/helm/charts/blob/master/stable/prometheus-operator/crds/crd-prometheus.yaml#L4136

sjentzsch avatar Mar 09 '20 19:03 sjentzsch

Also getting this error with Helm v3:

prometheus:
  prometheusSpec:
      ruleNamespaceSelector:
        any: true

      serviceMonitorNamespaceSelector:
        any: true
error validating data: [ValidationError(Prometheus.spec.ruleNamespaceSelector): unknown field "any" in com.coreos.monitoring.v1.Prometheus.spec.ruleNamespaceSelector, ValidationError(Prometheus.spec.serviceMonitorNamespaceSelector): unknown field "any" in com.coreos.monitoring.v1.Prometheus.spec.serviceMonitorNamespaceSelector]

Edit: Removing the any fields allows the deploy to continue. Looking at the CRD the any field is removed as well, seems like Prometheus might be watching all namespaces by default now? I can see existing service monitors are still active with the fields removed.

I'm also having the same problem. How do I get Prometheus to watch all namespaces?

longngn avatar Mar 29 '20 14:03 longngn

the same s.it happened.

alter avatar Apr 07 '20 12:04 alter

From what I understand after asking on slack, the new default here selects all namespace as long as you set serviceMonitorSelectorNilUsesHelmValues: false

ArchiFleKs avatar Apr 07 '20 12:04 ArchiFleKs

So I've set serviceMonitorSelectorNilUsesHelmValues: false but I still get only storage metrics for the monitoring namespace, am I doing something wrong? Is this the same issue or a different one?

shibumi avatar Apr 21 '20 09:04 shibumi

Ok one addition, it looks like I am able to monitor the other PVCs in the other namespaces, however the query kube_persistentvolume_capacity_bytes prints only the PVs in the monitoring namespace. Any idea?

shibumi avatar Apr 21 '20 11:04 shibumi

Hi there! I have a similar issue

prometheus:
  prometheusSpec:
    ruleNamespaceSelector:
      any: "true"
    serviceMonitorNamespaceSelector:
      any: "true"
helm version
version.BuildInfo{Version:"v3.2.0", GitCommit:"e11b7ce3b12db2941e90399e874513fbd24bcb71", GitTreeState:"clean", GoVersion:"go1.13.10"}
helm upgrade --install   monitoring --namespace monitoring -f /opt/ansible/configs/infra/monitoring/resources/helm_values/helm_values.yaml  stable/prometheus-operator --version 8.13.2 --set prometheusOperator.createCustomResource=false
Error: UPGRADE FAILED: error validating "": error validating data: [ValidationError(Prometheus.spec.ruleNamespaceSelector): unknown field "any" in com.coreos.monitoring.v1.Prometheus.spec.ruleNamespaceSelector, ValidationError(Prometheus.spec.serviceMonitorNamespaceSelector): unknown field "any" in com.coreos.monitoring.v1.Prometheus.spec.serviceMonitorNamespaceSelector]

FessAectan avatar Apr 27 '20 12:04 FessAectan

The solution works for me:

prometheus:
  prometheusSpec:
    ruleNamespaceSelector:
      matchLabels:
        prometheus: somelabel
    serviceMonitorNamespaceSelector:
      matchLabels:
        prometheus: somelabel

then create some PrometheusRule

apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
  labels:
    role: alert-rules
    app: strimzi
    prometheus: somelabel
  name: prometheus-k8s-rules
....

prometheus-operator has been deployed, but it doesn't see any ServiceMonitor or PrometheusRule in any NS in the cluster

UPD Finally I've resolved the issue by adding the label to my NS kubectl label ns cassandra prometheus=somelabel

FessAectan avatar Apr 27 '20 13:04 FessAectan

I also get the error:

error validating data: ValidationError(Prometheus.spec.serviceMonitorNamespaceSelector): unknown field "any" in com.coreos.monitoring.v1.Prometheus.spec.serviceMonitorNamespaceSelector;

For me this is working equivalent for any: true:

apiVersion: monitoring.coreos.com/v1
kind: Prometheus
metadata:
  name: some-prometheus
spec:
  serviceMonitorSelector:
    matchLabels:
      prometheus: some
  serviceMonitorNamespaceSelector: {}

CHART: prometheus-operator-8.13.0 APP VERSION: 0.38.1

delfer avatar Apr 28 '20 07:04 delfer

@delfer if you just want to access all namespaces, try setting: serviceMonitorSelectorNilUsesHelmValues: false

shibumi avatar Apr 28 '20 09:04 shibumi

@tux-00 did you get your error resolved? k8s version: v1.16.7 helm version: v3.1.2

i also get error validating data: ValidationError(Prometheus.spec.storage.volumeClaimTemplate): unknown field "selector" in com.coreos.monitoring.v1.Prometheus.spec.storage.volumeClaimTemplate

tarunptala avatar Apr 30 '20 13:04 tarunptala

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Any further update will cause the issue/pull request to no longer be considered stale. Thank you for your contributions.

stale[bot] avatar Jun 05 '20 13:06 stale[bot]

This issue is being automatically closed due to inactivity.

stale[bot] avatar Jun 20 '20 10:06 stale[bot]

storage still have some problem on chart 9.1.1 helm version: v3.2.4

Error: unable to build kubernetes objects from release manifest: error validating "": error validating data: ValidationError(Prometheus.spec.storage.volumeClaimTemplate): unknown field "selector" in com.coreos.monitoring.v1.Prometheus.spec.storage.volumeClaimTemplate

RicoToothless avatar Jul 22 '20 03:07 RicoToothless

same issue here

Error: UPGRADE FAILED: error validating "": error validating data: [ValidationError(Prometheus.spec.ruleNamespaceSelector): unknown field "any" in com.coreos.monitoring.v1.Prometheus.spec.ruleNamespaceSelector, ValidationError(Prometheus.spec.serviceMonitorNamespaceSelector): unknown field "any" in com.coreos.monitoring.v1.Prometheus.spec.serviceMonitorNamespaceSelector]

matchNames also can not be recognized helm 3.3.4 kube-prometheus-stack-9.4.4

yudar1024 avatar Sep 29 '20 12:09 yudar1024