loki icon indicating copy to clipboard operation
loki copied to clipboard

helm chart should not install Prometheus CRDs

Open sathieu opened this issue 2 years ago • 13 comments

Describe the bug

Prometheus is installed using another chart (or any other method). The prometheus CRDs are provided by this installation method. Installing also the CRD from the loki chart may produce CRD upgrade and downgrade with possible data lost.

To Reproduce Steps to reproduce the behavior:

  1. Install prometheus-stack and loki charts with ArgoCD

-> There is a diff, between the CRD version in prometheus-stack and in loki.

Expected behavior

No conflict

Environment:

  • Infrastructure: Kubernetes installed with kubespray
  • Deployment tool: helm in ArgoCD

Screenshots, Promtail config, or terminal output If applicable, add any output to help explain your problem.

sathieu avatar Oct 21 '22 13:10 sathieu

If you use ArgoCD, you can simply skip CRD's installation using skipCrds: true:

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: loki
  namespace: argocd
  labels:
    app.kubernetes.io/managed-by: argocd
  finalizers:
  - resources-finalizer.argocd.argoproj.io
spec:
  project: {{ .Values.project }}
  source:
    chart: loki
    repoURL: https://grafana.github.io/helm-charts
    targetRevision: {{ .Values.loki.version }}
    helm:
      skipCrds: true

dotdc avatar Oct 21 '22 16:10 dotdc

@dotdc Thanks for the info, but I still thinks this is a bad practice to include CRDs from other components.

I can move the CRDs to templates (with an if), if requested.

sathieu avatar Oct 21 '22 16:10 sathieu

As I mentioned in the pull requests the CRDs are used by the Grafana Agent Operator that is installed with this Helm Chart. We could couple the. Also, why is the Prometheus chart installing a CRD that's conflicting. E.g. our service monitor soups only target the Loki installation.

jeschkies avatar Oct 24 '22 07:10 jeschkies

The agent-operator chart has ServiceMonitor CRD too and a few others. Maybe move the prometheusrules.yaml CRD there and remove ServiceMonitor from the loki chart? This way, all those CRDs won't be installed when the agent is disabled.

sathieu avatar Oct 24 '22 07:10 sathieu

Hasn't this been merged as part of https://github.com/grafana/loki/pull/7499

trallnag avatar Oct 26 '22 08:10 trallnag

It would be good to have an option to disable prometheus CRD's but for now what I use is:

ignoreDifferences:
  - group: '*'
    jsonPointers:
    - /
    kind: CustomResourceDefinition

pblgomez avatar Mar 09 '23 16:03 pblgomez

Also, why is the Prometheus chart installing a CRD that's conflicting. E.g. our service monitor soups only target the Loki installation.

Well, it's the way around. Why Loki(ok, grafana-agent-operator, which is brought as a dependency for self-monitoring) installs Prometheus CRDs, namely:

monitoring.coreos.com_podmonitors.yaml
monitoring.coreos.com_probes.yaml
monitoring.coreos.com_servicemonitors.yaml

Those clearly belong to Prometheus(-operator) and should be left to it for management and ownership.

I recall seeing somewhere in the CHANGELOG that G-A-O is shipped with the Prometheus library now and it actually can handle those resources by itself, but most of the people do use kube-prometheus-stack in their setups and introducing it's half-way replacement creates a lot of headache.

It would be great if grafana-agent-operator could have this part of functionality switchable and be enabled only if there is no local Prometheus installed.

b-a-t avatar Mar 10 '23 09:03 b-a-t

Or at least update prometheus-crd to the latest versions to avoid conflicts

PR: https://github.com/grafana/loki/pull/9041

batazor avatar Apr 10 '23 12:04 batazor

any updates?

batazor avatar May 20 '23 00:05 batazor

Hasn't this been merged as part of #7499

That PR removed prometheus CRDs from the loki chart itself. However, when the monitoring feature is active, the Loki chart deploys the grafana-agent-operator as a dependency. This operator chart includes Prometheus CRDs. Probably this issue needs to be moved to https://github.com/grafana/helm-charts or to https://github.com/grafana/agent

azkore avatar Jul 12 '23 08:07 azkore

+1 to this thread, another scenario can be to specify which group of crds we can exclude from deploying:

crds:
  grafana-agent:
     enabled: true
  prometheus:
     enabled: true

and skip the installation of Prometheus crds with disable option. inspired by kube-prometheus-stack but haven't tested yet.

For now, I will handle crds in a separate folder with "helm skip crd" option, but it will be good to have something similar to what was proposed.

kuzm1ch avatar Sep 27 '23 08:09 kuzm1ch

+1 to this. The above would be amazing.

Berman510 avatar Nov 06 '23 20:11 Berman510

+1 from me too, please take a look at the PR. It's a pain to skip the installation of CRDs in Argo and then manage installation and upgrades manually.

nicl-dev avatar Feb 16 '24 08:02 nicl-dev

This just completely broke my dev cluster. +1 Loki should not install CRDs of other projects

Nico-Hab avatar Mar 27 '24 09:03 Nico-Hab

Plus 1️⃣ for this issue !

visdmin avatar Jun 24 '24 13:06 visdmin