argoproj / argo-helm

ArgoProj Helm Charts
https://argoproj.github.io/argo-helm/
Apache License 2.0
1.65k stars 1.82k forks source link

[argo-cd helm] ServiceMonitors from argoCD helm installation not working #2637

Open ellipsis-me opened 3 months ago

ellipsis-me commented 3 months ago

Describe the bug

I was trying to install argoCD with metrics and serviceMonitors enabled, but I noticed a error with serviceMonitors template, which the if condition to enable the serviceMonitor was not being satisfied. Turning impossible my installation with the remote official Charts repository, in which I must need to install with Metrics for my prometheus exporter. My label for prometheus was already checked.

Related helm chart

argo-cd

Helm chart version

6.7.11

To Reproduce

My configuration accordingly the documentation:

controller:
    metrics:
      enabled: true
      serviceMonitor:
        enabled: true
        selector:
        release: kube-prometheus
dex:
    metrics:
      enabled: true
      serviceMonitor:
        enabled: true
        selector:
        release: kube-prometheus

redis:
    metrics:
      enabled: true
      serviceMonitor:
        enabled: true
        selector:
        release: kube-prometheus

server:
    metrics:
      enabled: true
      serviceMonitor:
        enabled: true
        selector:
        release: kube-prometheus

Refering to the official template, the if condition that tried to render locally isn't working: https://github.com/argoproj/argo-helm/blob/main/charts/argo-cd/templates/argocd-application-controller/servicemonitor.yaml#L1

As above, metrics.enabled AND serviceMonitor.enabled was defined as true, and my cluster has the necessary API to handle that:
image

Expected behavior

I was expecting, the serviceMonitors resources for argoCD beeing deployed in my installation, but it isn't beeing possible so far.

Screenshots

image

Additional context

No response

yu-croco commented 3 months ago

Hi @ellipsis-me , In the yaml you shared above, metrics has 4 indent, not 2 indent. So I wonder if your values.yaml is correct. 🤔

# This doesn't work
controller:
    metrics:
      enabled: true
      serviceMonitor:
        enabled: true
        selector:
        release: kube-prometheus

# But this works, I think.
controller:
  metrics:
    enabled: true
    serviceMonitor:
      enabled: true
      selector:
      release: kube-prometheus
ellipsis-me commented 3 months ago

Hi @yu-croco YAML don't have the need of more spaces, I already did 1 indent, more than that is the same. https://yaml.org/spec/1.2-old/spec.html#id2777534

I even used yq tool to find the value

But ignore that indentation, I just typed more in my comment, but the code is Ok.

yu-croco commented 3 months ago

Hi @ellipsis-me , thank you for your reply.

Maybe this is the cause... 👀 https://github.com/helm/helm/issues/10760#issuecomment-1065225097

QustodioPablo commented 2 months ago

The issue I faced was that that the dex deployment metric's port is named metrics, but the default value used in the service monitor is http-metrics. If you change .Values.dex.metrics.service.portName to metrics it should work.

pdrastil commented 2 months ago

@ellipsis-me The helm template will not check for installed manifests on the K8s cluster. If you want to try templating see command below. The check for CRD is done only during helm install and condition will pass only if Prometheus CRDs are installed before Argo CD or on subsequent upgrade.

@QustodioPablo Hi - I've checked the output of the manifests and they are fine. The ServiceMonitor watches the Service that has correct http-metrics port.

❯ helm template argocd . -f monitors.yaml --api-versions monitoring.coreos.com/v1

results:

apiVersion: v1
kind: Service
metadata:
  name: argocd-dex-server
  namespace: "argocd"
  labels:
    helm.sh/chart: argo-cd-6.8.1
    app.kubernetes.io/name: argocd-dex-server
    app.kubernetes.io/instance: argocd
    app.kubernetes.io/component: dex-server
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/part-of: argocd
    app.kubernetes.io/version: "v2.11.0"
spec:
  ports:
  - name: http
    protocol: TCP
    port: 5556
    targetPort: http
  - name: grpc
    protocol: TCP
    port: 5557
    targetPort: grpc
  - name: http-metrics
    protocol: TCP
    port: 5558
    targetPort: metrics
  selector:
    app.kubernetes.io/name: argocd-dex-server
    app.kubernetes.io/instance: argocd
---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: argocd-dex-server
  namespace: "argocd"
  labels:
    helm.sh/chart: argo-cd-6.8.1
    app.kubernetes.io/name: argocd-dex-server
    app.kubernetes.io/instance: argocd
    app.kubernetes.io/component: dex-server
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/part-of: argocd
    app.kubernetes.io/version: "v2.11.0"
spec:
  endpoints:
    - port: http-metrics
      interval: 30s
      path: /metrics
  namespaceSelector:
    matchNames:
      - argocd
  selector:
    matchLabels:
      app.kubernetes.io/name: argocd-dex-server
      app.kubernetes.io/instance: argocd
      app.kubernetes.io/component: dex-server
mogopz commented 2 months ago

I seem to be having the same issue using v6.11.1 of the chart. The metrics services are created but the ServiceMonitors are not.

applicationSet:
  metrics:
    enabled: true
    serviceMonitor:
      enabled: true

controller:
  metrics:
    enabled: true
    serviceMonitor:
      enabled: true

dex:
  metrics:
    enabled: true
    serviceMonitor:
      enabled: true

redis:
  metrics:
    enabled: true
    serviceMonitor:
      enabled: true

repoServer:
  metrics:
    enabled: true
    serviceMonitor:
      enabled: true

server:
  ingress:
    enabled: true
    ingressClassName: nginx
    hostname: xxxxx
  metrics:
    enabled: true
    serviceMonitor:
      enabled: true
$ k api-resources | grep servicemonitor
servicemonitors                     smon                    monitoring.coreos.com/v1                  true         ServiceMonitor
$ k get svc | grep metrics
argocd-application-controller-metrics      ClusterIP   172.20.164.16    <none>        8082/TCP                     2d14h
argocd-applicationset-controller-metrics   ClusterIP   172.20.206.219   <none>        8080/TCP                     2d14h
argocd-redis-metrics                       ClusterIP   None             <none>        9121/TCP                     2d14h
argocd-repo-server-metrics                 ClusterIP   172.20.70.237    <none>        8084/TCP                     2d14h
argocd-server-metrics                      ClusterIP   172.20.178.181   <none>        8083/TCP                     2d13h
$ k get servicemonitor
No resources found in argocd namespace.
github-actions[bot] commented 22 hours ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.