apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: matrix-t0rt1k
  namespace: argocd
  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/matrix-t0rt1k
      directory:
        recurse: true
        include: "*.yaml"
    - repoURL: ghcr.io
      chart: element-hq/ess-helm/matrix-stack
      targetRevision: 26.6.1
      helm:
        values: |
          serverName: t0rt1k.tech

          certManager:
            clusterIssuer: letsencrypt-production

          ingress:
            className: traefik

          postgres:
            enabled: false

          synapse:
            postgres:
              host: shared-pg-rw.cnpg.svc.cluster.local
              database: synapse_t0rt1k
              user: synapse_t0rt1k
              password:
                secret: pg-creds
                secretKey: synapse
            media:
              storage:
                size: 10Gi
            ingress:
              host: matrix.t0rt1k.tech
            resources:
              requests:
                memory: 256Mi
                cpu: 100m
              limits:
                memory: 1.5Gi
            workers:
              federation-sender:
                enabled: true
                replicas: 2
                resources:
                  requests:
                    memory: 256Mi
                    cpu: 50m
                  limits:
                    memory: 512Mi
              federation-reader:
                enabled: true
                resources:
                  requests:
                    memory: 128Mi
                    cpu: 50m
                  limits:
                    memory: 256Mi
              client-reader:
                enabled: true
                replicas: 1
                resources:
                  requests:
                    memory: 128Mi
                    cpu: 50m
                  limits:
                    memory: 512Mi
              initial-synchrotron:
                enabled: true
                resources:
                  requests:
                    memory: 128Mi
                    cpu: 50m
                  limits:
                    memory: 256Mi
              synchrotron:
                enabled: true
                replicas: 1
                resources:
                  requests:
                    memory: 128Mi
                    cpu: 50m
                  limits:
                    memory: 256Mi
            additional:
              0-federation-retry:
                config: |
                  destination_min_retry_interval: "1m"
                  destination_retry_multiplier: 1.5
                  destination_max_retry_interval: "1d"

          matrixAuthenticationService:
            postgres:
              host: shared-pg-rw.cnpg.svc.cluster.local
              database: mas_t0rt1k
              user: mas_t0rt1k
              password:
                secret: pg-creds
                secretKey: mas
            ingress:
              host: auth.t0rt1k.tech
            resources:
              limits:
                memory: 128Mi

          elementWeb:
            ingress:
              host: chat.t0rt1k.tech

          elementAdmin:
            ingress:
              host: admin.t0rt1k.tech

          matrixRTC:
            ingress:
              host: rtc.t0rt1k.tech
            sfu:
              manualIP: "81.26.181.240"
              useStunToDiscoverPublicIP: false
              exposedServices:
                rtcTcp:
                  port: 30007
                  portType: NodePort
                  nodePort: ""
                rtcMuxedUdp:
                  port: 30006
                  portType: NodePort
                  nodePort: ""
              resources:
                requests:
                  memory: 64Mi
                  cpu: 50m
                limits:
                  memory: 512Mi

          hookshot:
            enabled: true
            resources:
              limits:
                memory: 256Mi
            ingress:
              host: hookshot.t0rt1k.tech
              className: traefik
              tlsEnabled: true
            additional:
              0-enable-js-transform:
                config: |
                  generic:
                    allowJsTransformationFunctions: true
  destination:
    server: https://kubernetes.default.svc
    namespace: matrix-t0rt1k
  syncPolicy:
    syncOptions:
      - CreateNamespace=true
