{{- $cozyConfig := lookup "v1" "ConfigMap" "cozy-system" "cozystack" }}
{{- $clusterDomain := (index $cozyConfig.data "cluster-domain") | default "cozy.local" }}

releases:
- name: fluxcd-operator
  releaseName: fluxcd-operator
  chart: cozy-fluxcd-operator
  namespace: cozy-fluxcd
  privileged: true
  dependsOn: []

- name: fluxcd
  releaseName: fluxcd
  chart: cozy-fluxcd
  namespace: cozy-fluxcd
  dependsOn: [fluxcd-operator,cilium]
  values:
    flux-instance:
      instance:
        cluster:
          domain: {{ $clusterDomain }}

- name: cilium
  releaseName: cilium
  chart: cozy-cilium
  namespace: cozy-cilium
  privileged: true
  dependsOn: []
  valuesFiles:
  - values.yaml
  - values-talos.yaml
  values:
    cilium:
      enableIPv4Masquerade: true
      enableIdentityMark: true
      ipv4NativeRoutingCIDR: "{{ index $cozyConfig.data "ipv4-pod-cidr" }}"
      autoDirectNodeRoutes: true
      routingMode: native

- name: cilium-networkpolicy
  releaseName: cilium-networkpolicy
  chart: cozy-cilium-networkpolicy
  namespace: cozy-cilium
  privileged: true
  dependsOn: [cilium]

- name: cozy-proxy
  releaseName: cozystack
  chart: cozy-cozy-proxy
  namespace: cozy-system
  optional: true
  dependsOn: [cilium]

- name: cert-manager-crds
  releaseName: cert-manager-crds
  chart: cozy-cert-manager-crds
  namespace: cozy-cert-manager
  dependsOn: [cilium]

- name: cozystack-controller
  releaseName: cozystack-controller
  chart: cozy-cozystack-controller
  namespace: cozy-system
  dependsOn: [cilium]
  {{- if eq (index $cozyConfig.data "telemetry-enabled") "false" }}
  values:
    cozystackController:
      disableTelemetry: true
  {{- end }}

- name: cert-manager
  releaseName: cert-manager
  chart: cozy-cert-manager
  namespace: cozy-cert-manager
  dependsOn: [cert-manager-crds]

- name: cert-manager-issuers
  releaseName: cert-manager-issuers
  chart: cozy-cert-manager-issuers
  namespace: cozy-cert-manager
  optional: true
  dependsOn: [cilium,cert-manager]

- name: victoria-metrics-operator
  releaseName: victoria-metrics-operator
  chart: cozy-victoria-metrics-operator
  namespace: cozy-victoria-metrics-operator
  optional: true
  dependsOn: [cilium,cert-manager]

- name: monitoring-agents
  releaseName: monitoring-agents
  chart: cozy-monitoring-agents
  namespace: cozy-monitoring
  privileged: true
  optional: true
  dependsOn: [cilium,victoria-metrics-operator]
  values:
    scrapeRules:
      etcd:
        enabled: true

- name: metallb
  releaseName: metallb
  chart: cozy-metallb
  namespace: cozy-metallb
  privileged: true
  dependsOn: [cilium]

- name: etcd-operator
  releaseName: etcd-operator
  chart: cozy-etcd-operator
  namespace: cozy-etcd-operator
  optional: true
  dependsOn: [cilium,cert-manager]

- name: grafana-operator
  releaseName: grafana-operator
  chart: cozy-grafana-operator
  namespace: cozy-grafana-operator
  optional: true
  dependsOn: [cilium]

- name: mariadb-operator
  releaseName: mariadb-operator
  chart: cozy-mariadb-operator
  namespace: cozy-mariadb-operator
  optional: true
  dependsOn: [cilium,cert-manager,victoria-metrics-operator]
  values:
    mariadb-operator:
      clusterName: {{ $clusterDomain }}

- name: postgres-operator
  releaseName: postgres-operator
  chart: cozy-postgres-operator
  namespace: cozy-postgres-operator
  optional: true
  dependsOn: [cilium,cert-manager,victoria-metrics-operator]

- name: kafka-operator
  releaseName: kafka-operator
  chart: cozy-kafka-operator
  namespace: cozy-kafka-operator
  optional: true
  dependsOn: [cilium,victoria-metrics-operator]
  values:
    strimzi-kafka-operator:
      kubernetesServiceDnsDomain: {{ $clusterDomain }}

- name: clickhouse-operator
  releaseName: clickhouse-operator
  chart: cozy-clickhouse-operator
  namespace: cozy-clickhouse-operator
  optional: true
  dependsOn: [cilium,victoria-metrics-operator]

- name: rabbitmq-operator
  releaseName: rabbitmq-operator
  chart: cozy-rabbitmq-operator
  namespace: cozy-rabbitmq-operator
  optional: true
  dependsOn: [cilium]

- name: redis-operator
  releaseName: redis-operator
  chart: cozy-redis-operator
  namespace: cozy-redis-operator
  optional: true
  dependsOn: [cilium]

- name: piraeus-operator
  releaseName: piraeus-operator
  chart: cozy-piraeus-operator
  namespace: cozy-linstor
  dependsOn: [cilium,cert-manager]

- name: snapshot-controller
  releaseName: snapshot-controller
  chart: cozy-snapshot-controller
  namespace: cozy-snapshot-controller
  dependsOn: [cilium]

- name: objectstorage-controller
  releaseName: objectstorage-controller
  chart: cozy-objectstorage-controller
  namespace: cozy-objectstorage-controller
  optional: true
  dependsOn: [cilium]

- name: linstor
  releaseName: linstor
  chart: cozy-linstor
  namespace: cozy-linstor
  privileged: true
  dependsOn: [piraeus-operator,cilium,cert-manager,snapshot-controller]

- name: telepresence
  releaseName: traffic-manager
  chart: cozy-telepresence
  namespace: cozy-telepresence
  optional: true
  dependsOn: []

- name: external-dns
  releaseName: external-dns
  chart: cozy-external-dns
  namespace: cozy-external-dns
  optional: true
  dependsOn: [cilium]

- name: external-secrets-operator
  releaseName: external-secrets-operator
  chart: cozy-external-secrets-operator
  namespace: cozy-external-secrets-operator
  optional: true
  dependsOn: [cilium]

- name: keycloak
  releaseName: keycloak
  chart: cozy-keycloak
  namespace: cozy-keycloak
  optional: true
  dependsOn: [postgres-operator]

- name: keycloak-operator
  releaseName: keycloak-operator
  chart: cozy-keycloak-operator
  namespace: cozy-keycloak
  optional: true
  dependsOn: [keycloak]

- name: bootbox
  releaseName: bootbox
  chart: cozy-bootbox
  namespace: cozy-bootbox
  privileged: true
  optional: true
  dependsOn: [cilium]

- name: reloader
  releaseName: reloader
  chart: cozy-reloader
  namespace: cozy-reloader
