---
apiVersion: batch/v1
kind: CronJob
metadata:
  name: plex-media-manager
  namespace: media
spec:
  schedule: "0 0 * * *"
  jobTemplate:
    spec:
      template:
        spec:
          # initContainers:
          #   - name: render-dynamic-config
          #     image: chrisjohnson00/jinja-init:v1.0.0
          #     env:
          #       # source and destination files
          #       - name: JINJA_SRC_FILE
          #         value: /config_src/tv.yaml
          #       - name: JINJA_DEST_FILE
          #         value: /config/tv.yaml
          #       # let's be verbose
          #       - name: VERBOSE
          #         value: "1"
          #     volumeMounts:
          #       # configMap mount point
          #       - name: tv-config-template
          #         mountPath: /config_src
          #       # target directory mount point; the final config file will be created here
          #       - name: config
          #         mountPath: /config
          containers:
            - name: plex-media-manager
              image: meisnate12/plex-meta-manager:nightly
              imagePullPolicy: IfNotPresent
              args: ["--run", "--read-only-config"]
              resources:
                limits:
                  cpu: 100m
                  memory: 256Mi
                requests:
                  cpu: 100m
                  memory: 125Mi
              volumeMounts:
                - name: config
                  mountPath: /config
                - name: pmm-config
                  mountPath: /config/config.yml
                  subPath: config.yml
                - name: movie-config
                  mountPath: /config/movies.yaml
                  subPath: movies.yaml
                - name: movie-overlay-config
                  mountPath: /config/movies_overlays.yaml
                  subPath: movies_overlays.yaml
                - name: tv-config
                  mountPath: /config/tv.yaml
                  subPath: tv.yaml
          volumes:
            - name: config
              persistentVolumeClaim:
                claimName: plex-media-manager-config-v1
            - name: pmm-config
              secret:
                secretName: plex-media-manager
            - configMap:
                name: movie-config
              name: movie-config
            - configMap:
                name: movie-overlay-config
              name: movie-overlay-config
            - configMap:
                name: tv-config
              name: tv-config
          restartPolicy: OnFailure
