apiVersion: apps/v1
kind: Deployment
metadata:
  name: tubearchivist
  labels:
    app.kubernetes.io/controller: main
    app.kubernetes.io/instance: tubearchivist
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/name: tubearchivist
    helm.sh/chart: tubearchivist-5.0.1
  namespace: tubearchivist
spec:
  revisionHistoryLimit: 3
  replicas: 1
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app.kubernetes.io/controller: main
      app.kubernetes.io/name: tubearchivist
      app.kubernetes.io/instance: tubearchivist
  template:
    metadata:
      labels:
        app.kubernetes.io/controller: main
        app.kubernetes.io/instance: tubearchivist
        app.kubernetes.io/name: tubearchivist
    spec:
      enableServiceLinks: false
      serviceAccountName: tubearchivist
      automountServiceAccountToken: false
      securityContext:
        fsGroup: 1000
        fsGroupChangePolicy: OnRootMismatch
      hostIPC: false
      hostNetwork: false
      hostPID: false
      dnsPolicy: ClusterFirst
      initContainers:
        - env:
            - name: VPN_SERVICE_PROVIDER
              value: protonvpn
            - name: VPN_TYPE
              value: wireguard
            - name: WIREGUARD_PRIVATE_KEY
              valueFrom:
                secretKeyRef:
                  key: private-key
                  name: protonvpn-wireguard-conf
            - name: FIREWALL_OUTBOUND_SUBNETS
              value: 127.0.0.0/8,192.168.1.0/24,10.244.0.0/16,10.96.0.0/12
            - name: FIREWALL_INPUT_PORTS
              value: "24000"
            - name: DNS_CACHING
              value: "off"
          image: ghcr.io/qdm12/gluetun:v3.41.1@sha256:1a5bf4b4820a879cdf8d93d7ef0d2d963af56670c9ebff8981860b6804ebc8ab
          lifecycle:
            postStart:
              exec:
                command:
                  - /bin/sh
                  - -c
                  - (ip rule del table 51820; ip -6 rule del table 51820) || true
          name: gluetun
          readinessProbe:
            exec:
              command:
                - /gluetun-entrypoint
                - healthcheck
            failureThreshold: 5
            initialDelaySeconds: 15
            periodSeconds: 10
            successThreshold: 1
            timeoutSeconds: 5
          resources:
            limits:
              devic.es/tun: "1"
            requests:
              devic.es/tun: "1"
          restartPolicy: Always
          securityContext:
            capabilities:
              add:
                - NET_ADMIN
                - SYS_MODULE
            privileged: true
      containers:
        - image: brainicism/bgutil-ytdlp-pot-provider:1.3.1@sha256:1aaa43a0ca72dfca6a6d2129a0fb4a23465c25adb1b043f8aff829a20825646b
          name: bgutil
        - env:
            - name: TZ
              value: America/Chicago
            - name: HOST_UID
              value: "1000"
            - name: HOST_GID
              value: "1000"
            - name: ES_URL
              value: https://elasticsearch-tubearchivist-es-http.tubearchivist:9200
            - name: ES_DISABLE_VERIFY_SSL
              value: "true"
            - name: REDIS_CON
              value: redis://tubearchivist-valkey.tubearchivist.svc.cluster.local:6379
            - name: TA_HOST
              value: https://tubearchivist.alexlebens.net http://tubearchivist.tubearchivist:80/
            - name: TA_PORT
              value: "24000"
            - name: TA_USERNAME
              value: admin
          envFrom:
            - secretRef:
                name: tubearchivist-config
          image: bbilly1/tubearchivist:v0.5.10@sha256:dfe723cf008520e1758ecc3e59e6ea8761dd10d5bb099cd87289e80f5bd66567
          livenessProbe:
            exec:
              command:
                - curl
                - -f
                - http://localhost:24000/api/health/
            failureThreshold: 5
            initialDelaySeconds: 30
            periodSeconds: 30
            successThreshold: 1
            timeoutSeconds: 15
          name: main
          resources:
            requests:
              cpu: 10m
              memory: 1Gi
          volumeMounts:
            - mountPath: /cache
              name: data
            - mountPath: /youtube
              name: youtube
      volumes:
        - name: data
          persistentVolumeClaim:
            claimName: tubearchivist
        - name: youtube
          persistentVolumeClaim:
            claimName: tubearchivist-nfs-storage
