kubescape / helm-charts

Kubescape can run as a set of microservices inside a Kubernetes cluster. This allows you to continually monitor the status of a cluster, including for compliance and vulnerability management
Apache License 2.0
29 stars 41 forks source link

ServiceMonitor.monitoring.coreos.com "prometheus-exporter" is invalid: spec.endpoints: Required value #390

Closed dabo-devconsole closed 1 day ago

dabo-devconsole commented 7 months ago

Description

Helm installation fails to deploy the prometheus-exporter ServiceMonitor.

Environment

OS: Ubuntu 22.04 LTS Version: 3.0.3

Steps To Reproduce

  1. --set "capabilities.prometheusExporter=enable" or set value in values.yaml
  2. helm install ...
  3. install all, but prometheus-exporter
  4. error: Error: INSTALL FAILED: failed to create resource: ServiceMonitor.monitoring.coreos.com "prometheus-exporter" is invalid: spec.endpoints: Required value

Expected behavior

ServiceMonitor is created

Actual Behavior

ServiceMonitor is not created

Additional context

The template is missing the required "endpoints" specification.

dwertent commented 6 months ago

Do you have the Prometheus operator running in your cluster?

dabo-devconsole commented 6 months ago

Yes, the kube-prometheus-stack-operator is running in version v0.71.2 in the cluster.

dwertent commented 6 months ago

This is unusual, I'm unable to reproduce the problem. It seems to be working fine without any issues. Perhaps we should consider adding the endpoint here just to be cautious.

aminrj commented 6 months ago

Hi, I am experiencing the same issue but while using Prometheus community Helm chart: │ Error: failed to create resource: ServiceMonitor.monitoring.coreos.com "prometheus-exporter" is invalid: spec.endpoints: Required value

The result is that the pod is in a CrashLoopBackOff: prometheus-exporter-f4dc7988f-dmf2d 0/1 CrashLoopBackOff 4 (25s ago) 117s

Here is the configuration of the Helm chart:

kubescape:

  # Enable prometheus pod annotations,to allow your opensource prometheus (not operator) to scrape metrics
  prometheusAnnotation:
    enabled: true

capabilities:
  # Kubescape integration with Prometheus Community Hlem chart
  prometheusExporter: enable
dabo-devconsole commented 6 months ago

Yes it pretty much looks the same. I'm also using the Prometheus community helm chart, especially the prometheus-community/kube-prometheus-stack.

hyo-shin commented 3 months ago

I have also encountered this issue:

Error: failed to create resource: ServiceMonitor.monitoring.coreos.com "prometheus-exporter" is invalid: spec.endpoints: Required value

I agree with @dwertent suggestion that the spec.endpoints might need to be added here.

lubgi commented 3 months ago

What's the workaround?

dwertent commented 3 months ago

I will look into this today :)

l-spork-cc commented 2 months ago

We are experiencing the same problem, we deployed a separate servicemonitor outside of the helm deployment as a workaround. The following ressource definition works for us, depending on how the prometheus instance is configured one might also need to add a label for the prometheus selector (we disabled it completely).

apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  labels:
    app: prometheus-exporter
  name: kubescape
  namespace: kubescape
spec:
  endpoints:
    - interval: 30s
      targetPort: 8080
      path: /metrics
  namespaceSelector:
    matchNames:
      - kubescape
  selector:
    matchLabels:
      app: prometheus-exporter
matthyx commented 4 days ago

@dabo-devconsole @l-spork-cc can you check with the latest chart please?

dabo-devconsole commented 1 day ago

Hi @matthyx, same error in Chart version 1.21.2. Do I missed something?

matthyx commented 1 day ago

should be fixed in the next release (probably next week)