# GitOps Tools
# Continuous delivery and deployment automation for Kubernetes
workloads:
  argocd:
    category: gitops
    description: GitOps continuous delivery tool for Kubernetes
    chart:
      repo: argo
      name: argo/argo-cd
      # renovate: datasource=helm depName=argo-cd repositoryUrl=https://argoproj.github.io/argo-helm
      version: "9.4.17"
    defaults:
      namespace: loko-system
      ports: []
      storage:
        size: 5Gi
    secrets:
      admin:
        name: admin
        type: user-pass
        description: ArgoCD admin user credentials
        fields:
          - name: username
            type: static
            value: admin
            sensitive: false
          - name: password
            type: password
            length: 16
          - name: password_hash
            type: htpasswd
            derived-from: password
        mappings:
          password_hash: configs.secret.argocdServerAdminPassword  # pragma: allowlist secret
      server:
        name: server
        type: generic
        description: ArgoCD server secret key for signing sessions and tokens
        fields:
          - name: secretkey
            type: password
            length: 32
        mappings:
          secretkey: configs.secret.argocdServerSecretKey  # pragma: allowlist secret
    mappings:
      storage: redis.master.persistence.size
    presets:
      # Basic configuration for ArgoCD server
      global:
        domain: argocd.${LOKO_DOMAIN}
      configs:
        params:
          server.insecure: "true"
      server:
        service:
          type: ClusterIP
        ingress:
          <<: *ingress-traefik
          enabled: true
          hosts:
            - argocd.${LOKO_DOMAIN}
          extraTls:
            - hosts:
                - argocd.${LOKO_DOMAIN}
              secretName: wildcard-tls  # pragma: allowlist secret
      # Use integrated Redis instead of HA Redis for local dev
      redis-ha:
        enabled: false
      applicationSet:
        readinessProbe:
          enabled: true
          initialDelaySeconds: 5
          periodSeconds: 10
          timeoutSeconds: 2
          successThreshold: 1
          failureThreshold: 3
    endpoints:
      - name: web-ui
        protocol: http
        port: 80
        description: ArgoCD web UI and API
      - name: grpc
        protocol: tcp
        port: 443
        description: ArgoCD gRPC server
    connection-strings:
      - name: web-ui
        template: "https://${HOST}"
      - name: grpc
        template: "${HOST}:443"
    health-checks:
      - name: port
        <<: *health-check-port
        target: web-ui
        description: Check if ArgoCD web UI port is open

  flux-operator:
    category: gitops
    description: Kubernetes operator for managing Flux CD instances (GitOps on Autopilot)
    chart:
      repo: flux-operator
      name: flux-operator/flux-operator
      # renovate: datasource=docker depName=ghcr.io/controlplaneio-fluxcd/charts/flux-operator
      version: "0.45.1"
    defaults:
      namespace: flux-system
      storage:
        size: 1Gi
      ports: []
    mappings:
      storage: persistence.size
    presets:
      # Install CRDs for FluxInstance management
      installCRDs: true
      # Operator watches all namespaces by default
      watchAllNamespaces: true
      # Resource limits for the operator
      resources:
        limits:
          memory: 256Mi
        requests:
          cpu: 100m
          memory: 128Mi
      # Enable Flux web UI with Traefik ingress
      web:
        enabled: true
        ingress:
          <<: *ingress-traefik
          enabled: true
          hosts:
            - host: flux.${LOKO_DOMAIN}
              paths:
                - path: /
                  pathType: Prefix
          tls:
            - hosts:
                - flux.${LOKO_DOMAIN}
              secretName: wildcard-tls  # pragma: allowlist secret
    endpoints:
      - name: web-ui
        protocol: http
        port: 9080
        description: Flux web UI (Mission control dashboard)
    connection-strings:
      - name: web-ui
        template: "https://${HOST}"
    health-checks:
      - name: port
        <<: *health-check-port
        target: web-ui
        description: Check if Flux web UI port is open

  flux-instance:
    category: gitops
    description: Flux CD instance managed by flux-operator
    chart:
      repo: flux-operator
      name: flux-operator/flux-instance
      # renovate: datasource=docker depName=ghcr.io/controlplaneio-fluxcd/charts/flux-instance
      version: "0.45.1"  # linked to flux-operator version
    defaults:
      namespace: flux-system
    presets:
      instance:
        distribution:
          version: "2.x"
