---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: &app media-browser
  namespace: media
  labels:
    app.kubernetes.io/instance: *app
    app.kubernetes.io/name: *app
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: *app
      app.kubernetes.io/instance: *app
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app.kubernetes.io/name: *app
        app.kubernetes.io/instance: *app
    spec:
      containers:
        - name: media-browser
          image: docker.io/filebrowser/filebrowser:v2.21.1
          imagePullPolicy: IfNotPresent
          env:
            - name: FB_DATABASE
              value: /config/filebrowser.db
            - name: FB_LOG
              value: stdout
            - name: FB_NOAUTH
              value: "true"
            - name: FB_ROOT
              value: /media
            - name: TZ
              value: "${TIMEZONE}"
          ports:
            - name: &port http
              containerPort: 80
              protocol: TCP
          livenessProbe:
            httpGet:
              path: /health
              port: *port
            initialDelaySeconds: 0
            periodSeconds: 10
            timeoutSeconds: 1
            failureThreshold: 3
          readinessProbe:
            httpGet:
              path: /health
              port: *port
            initialDelaySeconds: 0
            periodSeconds: 10
            timeoutSeconds: 1
            failureThreshold: 3
          startupProbe:
            httpGet:
              path: /health
              port: *port
            failureThreshold: 30
            periodSeconds: 10
          volumeMounts:
            - name: config
              mountPath: /config
            - name: media
              mountPath: /media
          resources:
            requests:
              cpu: 10m
              memory: 50Mi
            limits:
              cpu: 200m
              memory: 500Mi
      volumes:
        - name: config
          persistentVolumeClaim:
            claimName: media-browser-config-v1
        - name: media
          nfs:
            path: /tycho/Media
            server: "expanse.${SECRET_PRIVATE_DOMAIN}"
