apiVersion: apps/v1
kind: Deployment
metadata:
  name: soulsync
  labels:
    app.kubernetes.io/controller: main
    app.kubernetes.io/instance: soulsync
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/name: soulsync
    helm.sh/chart: soulsync-4.5.0
  namespace: soulsync
spec:
  revisionHistoryLimit: 3
  replicas: 0
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app.kubernetes.io/controller: main
      app.kubernetes.io/name: soulsync
      app.kubernetes.io/instance: soulsync
  template:
    metadata:
      labels:
        app.kubernetes.io/controller: main
        app.kubernetes.io/instance: soulsync
        app.kubernetes.io/name: soulsync
    spec:
      enableServiceLinks: false
      serviceAccountName: default
      automountServiceAccountToken: true
      hostIPC: false
      hostNetwork: false
      hostPID: false
      dnsPolicy: ClusterFirst
      initContainers:
        - command:
            - /bin/sh
            - -ec
            - |
              echo ">> Coping files ..."
              ls /tmp
              cp -fv /tmp/config.json /app/config/config.json
              echo ">> Files in config:"
              ls /app/config
          image: busybox:1.37.0
          imagePullPolicy: IfNotPresent
          name: init-copy-config
          resources:
            requests:
              cpu: 10m
              memory: 128Mi
          volumeMounts:
            - mountPath: /app/config
              name: config
            - mountPath: /tmp/config.json
              mountPropagation: None
              name: secret
              readOnly: true
              subPath: config.json
      containers:
        - env:
            - name: TZ
              value: US/Central
            - name: PUID
              value: "1000"
            - name: PGID
              value: "1000"
            - name: FLASK_ENV
              value: production
            - name: PYTHONPATH
              value: /app
            - name: SOULSYNC_CONFIG_PATH
              value: /app/config/config.json
          image: boulderbadgedad/soulsync:latest
          imagePullPolicy: IfNotPresent
          livenessProbe:
            exec:
              command:
                - CMD
                - curl
                - -f
                - http://localhost:8888/
            failureThreshold: 5
            initialDelaySeconds: 60
            periodSeconds: 30
            successThreshold: 1
            timeoutSeconds: 10
          name: main
          resources:
            requests:
              cpu: 100m
              memory: 512Mi
          volumeMounts:
            - mountPath: /app/config
              name: config
            - mountPath: /app/database
              name: database
            - mountPath: /app/downloads
              name: downloads
            - mountPath: /music
              name: music
              readOnly: true
            - mountPath: /app/Transfer
              name: transfer
      volumes:
        - name: config
          persistentVolumeClaim:
            claimName: soulsync-config
        - name: database
          persistentVolumeClaim:
            claimName: soulsync-database
        - name: downloads
          persistentVolumeClaim:
            claimName: soulsync-slskd-nfs-storage
        - name: music
          persistentVolumeClaim:
            claimName: soulsync-music-nfs-storage
        - name: secret
          secret:
            secretName: soulsync-config-secret
        - emptyDir: {}
          name: transfer
