apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: monitoring
  namespace: argocd
  annotations:
    argocd.argoproj.io/sync-wave: "0"
  finalizers:
    - resources-finalizer.argocd.argoproj.io
spec:
  project: default
  sources:
    - repoURL: http://gitea.gitea.svc.cluster.local:3000/admin/main.git
      targetRevision: master
      path: manifests/metrics/grafana
      directory:
        recurse: true
        include: "*.yaml"

    - repoURL: https://victoriametrics.github.io/helm-charts/
      chart: victoria-metrics-k8s-stack
      targetRevision: "0.83.0"
      helm:
        values: |
          fullnameOverride: vm-k8s-stack
          namespaceOverride: metrics

          victoria-metrics-operator:
            resources:
              requests:
                memory: 128Mi
                cpu: 25m
              limits:
                memory: 256Mi

          defaultDashboards:
            dashboards:
              node-exporter-full:
                enabled: false

          vmsingle:
            enabled: true
            spec:
              retentionPeriod: "30d"
              replicaCount: 1
              resources:
                requests:
                  cpu: 100m
                  memory: 256Mi
                limits:
                  cpu: 500m
                  memory: 1Gi
              storage:
                accessModes:
                  - ReadWriteOnce
                resources:
                  requests:
                    storage: 30Gi

          alertmanager:
            enabled: true
            spec:
              replicaCount: 1
              resources:
                requests:
                  cpu: 50m
                  memory: 128Mi
                limits:
                  cpu: 200m
                  memory: 512Mi
              storage:
                volumeClaimTemplate:
                  spec:
                    accessModes:
                      - ReadWriteOnce
                    resources:
                      requests:
                        storage: 1Gi
              config:
                route:
                  receiver: blackhole
                receivers:
                  - name: blackhole

          grafana:
            enabled: true
            adminUser: admin
            adminPassword: change-me
            grafana.ini:
              server:
                root_url: https://grafana.prod.t01tt.tech
            persistence:
              enabled: true
              size: 2Gi
            resources:
              requests:
                cpu: 50m
                memory: 256Mi
              limits:
                cpu: 200m
                memory: 512Mi

          prometheus-node-exporter:
            enabled: true

          kube-state-metrics:
            enabled: true

          kubelet:
            enabled: true

          kubeApiServer:
            enabled: false

          kubeControllerManager:
            enabled: false

          kubeScheduler:
            enabled: false

          kubeProxy:
            enabled: false

          kubeEtcd:
            enabled: false

  destination:
    server: https://kubernetes.default.svc
    namespace: metrics
  ignoreDifferences:
    - group: operator.victoriametrics.com
      kind: VMAlertmanager
      jsonPointers:
        - /spec/config
    - kind: Secret
      name: monitoring-victoria-metrics-operator-validation
      jsonPointers:
        - /data
    - kind: ValidatingWebhookConfiguration
      name: monitoring-victoria-metrics-operator-admission
      jsonPointers:
        - /webhooks/0/clientConfig/caBundle
  syncPolicy:
    syncOptions:
      - CreateNamespace=true
