seedbox-sync.yaml 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. ---
  2. apiVersion: batch/v1
  3. kind: CronJob
  4. metadata:
  5. name: seedbox-sync
  6. namespace: plex
  7. spec:
  8. schedule: "*/1 * * * *"
  9. successfulJobsHistoryLimit: 1
  10. failedJobsHistoryLimit: 1
  11. concurrencyPolicy: Forbid
  12. jobTemplate:
  13. spec:
  14. template:
  15. metadata:
  16. labels:
  17. app: seedbox-sync
  18. annotations:
  19. backup.velero.io/backup-volumes-excludes: media
  20. spec:
  21. restartPolicy: OnFailure
  22. containers:
  23. - name: seedbox-sync
  24. image: jibby0/seedbox-sync
  25. command:
  26. - /bin/sh
  27. - -c
  28. # User 1000 runs the script to set folder permissions properly.
  29. # We can't change a secret volume owner, so copy the files & chown
  30. # them ourselves.
  31. - |
  32. mkdir /home/nonroot/.ssh &&
  33. cp -Lr /ssh/config /ssh/known_hosts /ssh/seedbox_ecdsa /home/nonroot/.ssh &&
  34. chmod 400 ~/.ssh/* &&
  35. python3 /script/seedbox_sync.py $SEEDBOX_HOST $PATH_TO_COMPLETED $LOCAL_PATH_TO_DOWNLOADING $LOCAL_PATH_TO_PROCESSED $LOCAL_PATH_TO_READY
  36. env:
  37. - name: LIDARR_MUSIC_PATH
  38. value: /media/Music/
  39. - name: SEEDBOX_HOST
  40. valueFrom:
  41. secretKeyRef:
  42. name: seedbox-sync
  43. key: seedbox-host
  44. - name: PATH_TO_COMPLETED
  45. valueFrom:
  46. secretKeyRef:
  47. name: seedbox-sync
  48. key: path-to-completed
  49. - name: LOCAL_PATH_TO_DOWNLOADING
  50. valueFrom:
  51. secretKeyRef:
  52. name: seedbox-sync
  53. key: local-path-to-downloading
  54. - name: LOCAL_PATH_TO_PROCESSED
  55. valueFrom:
  56. secretKeyRef:
  57. name: seedbox-sync
  58. key: local-path-to-processed
  59. - name: LOCAL_PATH_TO_READY
  60. valueFrom:
  61. secretKeyRef:
  62. name: seedbox-sync
  63. key: local-path-to-ready
  64. volumeMounts:
  65. - mountPath: "/media"
  66. name: media
  67. - mountPath: /script
  68. name: seedbox-sync
  69. - mountPath: /ssh
  70. name: seedbox-sync-ssh
  71. securityContext:
  72. runAsUser: 1000
  73. runAsGroup: 1000
  74. volumes:
  75. - name: media
  76. persistentVolumeClaim:
  77. claimName: plex-pvc
  78. - name: seedbox-sync
  79. configMap:
  80. name: seedbox-sync
  81. items:
  82. - key: seedbox_sync.py
  83. path: seedbox_sync.py
  84. - name: seedbox-sync-ssh
  85. secret:
  86. secretName: seedbox-sync-ssh
  87. defaultMode: 0777