---
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
  name: mastodon-web
  namespace: fediverse
  labels:
    app: mastodon
    component: web
spec:
  interval: 30m
  chart:
    spec:
      chart: app-template
      version: 1.5.1
      sourceRef:
        kind: HelmRepository
        name: bjw-s
        namespace: flux-system
  values:
    controller:
      replicas: 2
      strategy: Recreate
      annotations:
        reloader.stakater.com/auto: "true"
      labels:
        app: mastodon
        component: web
    image:
      repository: ghcr.io/mastodon/mastodon
      tag: v4.1.6@sha256:51405bec6529860c88640bbca3d30bf3a9a82456a3fdae122dc52f4f941808ff
    command:
      - bundle
      - exec
      - puma
      - -C
      - config/puma.rb
    envFrom:
      - secretRef:
          name: mastodon-secret
    env:
      DB_NAME: "$(CP_MASTODON_WEB)"
      DB_PORT: "$(DB_PORT)"
      PREPARED_STATEMENTS: "false" # neccessary for pgbouncer
    resources:
      requests:
        cpu: 15m
        memory: 500Mi
      # limits:
      #   memory: 1Gi
    service:
      main:
        ports:
          http:
            port: 3000
    livenessProbe:
      tcpSocket:
        port: http
    readinessProbe:
      httpGet:
        path: /health
        port: http
    startupProbe:
      httpGet:
        path: /health
        port: http
      failureThreshold: 30
      periodSeconds: 5
    affinity:
      podAntiAffinity:
        requiredDuringSchedulingIgnoredDuringExecution:
          - labelSelector:
              matchExpressions:
                - key: app.kubernetes.io/name
                  operator: In
                  values: ["mastodon-web"]
            topologyKey: kubernetes.io/hostname