---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: tdarr-node
  namespace: "{{ .Release.Namespace }}"
  labels:
    app: tdarr-node
    io.kompose.service: tdarr-node
spec:
  replicas: 1
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app: tdarr-node
      io.kompose.service: tdarr-node
  template:
    metadata:
      labels:
        app: tdarr-node
        io.kompose.service: tdarr-node
        io.kompose.network/chrome-default: "true"
    spec:
      runtimeClassName: nvidia
      containers:
        - name: tdarr-node
          image: "{{ .Values.image }}"
          env:
            - name: PUID
              value: "1029"
            - name: PGID
              value: "100"
            - name: TZ
              value: "{{ .Values.timezone }}"
            - name: UMASK
              value: "022"
            - name: nodeName
              value: "{{ .Values.nodeName }}"
            - name: serverIP
              value: "{{ .Values.serverIP }}"
            - name: serverPort
              value: "{{ .Values.serverPort }}"
            - name: inContainer
              value: "true"
            - name: ffmpegVersion
              value: "6"
            - name: NVIDIA_VISIBLE_DEVICES
              value: "all"
            - name: NVIDIA_DRIVER_CAPABILITIES
              value: "all"
          resources:
            limits:
              cpu: "8"
              memory: 16Gi
            requests:
              cpu: 500m
              memory: 2Gi
          volumeMounts:
            - name: config
              mountPath: /app/configs
            - name: logs
              mountPath: /app/logs
            - name: media
              mountPath: /media
            - name: cache-temp
              mountPath: /temp
            - name: cache
              mountPath: /cache
      volumes:
        - name: config
          hostPath:
            path: "{{ .Values.configPath }}/configs"
            type: DirectoryOrCreate
        - name: logs
          hostPath:
            path: "{{ .Values.configPath }}/logs"
            type: DirectoryOrCreate
        - name: media
          hostPath:
            path: "{{ .Values.mediaPath }}"
            type: Directory
        - name: cache-temp
          hostPath:
            path: "{{ .Values.cachePath }}"
            type: Directory
        - name: cache
          hostPath:
            path: "{{ .Values.cachePath }}"
            type: Directory
      restartPolicy: Always
