_qbittorrent.tpl 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. {{- define "qbittorrent.workload" -}}
  2. workload:
  3. qbittorrent:
  4. enabled: true
  5. primary: true
  6. type: Deployment
  7. podSpec:
  8. hostNetwork: {{ .Values.qbitNetwork.hostNetwork }}
  9. containers:
  10. qbittorrent:
  11. enabled: true
  12. primary: true
  13. imageSelector: image
  14. securityContext:
  15. runAsUser: {{ .Values.qbitRunAs.user }}
  16. runAsGroup: {{ .Values.qbitRunAs.group }}
  17. {{ with .Values.qbitConfig.additionalEnvs }}
  18. env:
  19. {{ range $env := . }}
  20. {{ $env.name }}: {{ $env.value }}
  21. {{ end }}
  22. {{ end }}
  23. envFrom:
  24. - configMapRef:
  25. name: qbit-config
  26. probes:
  27. liveness:
  28. enabled: true
  29. type: http
  30. port: "{{ .Values.qbitNetwork.webPort }}"
  31. path: /
  32. readiness:
  33. enabled: true
  34. type: http
  35. port: "{{ .Values.qbitNetwork.webPort }}"
  36. path: /
  37. startup:
  38. enabled: true
  39. type: http
  40. port: "{{ .Values.qbitNetwork.webPort }}"
  41. path: /
  42. initContainers:
  43. check-permissions:
  44. enabled: true
  45. type: init
  46. imageSelector: bashImage
  47. resources:
  48. limits:
  49. cpu: 1000m
  50. memory: 512Mi
  51. securityContext:
  52. runAsUser: 0
  53. runAsGroup: 0
  54. runAsNonRoot: false
  55. readOnlyRootFilesystem: false
  56. capabilities:
  57. add:
  58. - CHOWN
  59. command: bash
  60. args:
  61. - -c
  62. - |
  63. for dir in /mnt/directories/*; do
  64. if [ ! -d "$dir" ]; then
  65. echo "[$dir] is not a directory, skipping"
  66. continue
  67. fi
  68. if [ $(stat -c %u "$dir") -eq {{ .Values.qbitRunAs.user }} ] && [ $(stat -c %g "$dir") -eq {{ .Values.qbitRunAs.group }} ]; then
  69. echo "Permissions on ["$dir"] are correct"
  70. else
  71. echo "Permissions on ["$dir"] are incorrect"
  72. echo "Changing ownership to {{ .Values.qbitRunAs.user }}:{{ .Values.qbitRunAs.group }} on the following directories: ["$dir"]"
  73. chown -R {{ .Values.qbitRunAs.user }}:{{ .Values.qbitRunAs.group }} "$dir"
  74. echo "Finished changing ownership"
  75. echo "Permissions after changing ownership:"
  76. stat -c "%u %g" "$dir"
  77. fi
  78. done
  79. {{/* Service */}}
  80. service:
  81. qbittorrent:
  82. enabled: true
  83. primary: true
  84. type: NodePort
  85. targetSelector: qbittorrent
  86. ports:
  87. webui:
  88. enabled: true
  89. primary: true
  90. port: {{ .Values.qbitNetwork.webPort }}
  91. nodePort: {{ .Values.qbitNetwork.webPort }}
  92. targetSelector: qbittorrent
  93. qbittorrent-bt:
  94. enabled: true
  95. type: NodePort
  96. targetSelector: qbittorrent
  97. ports:
  98. bt-tcp:
  99. enabled: true
  100. primary: true
  101. port: {{ .Values.qbitNetwork.btPort }}
  102. nodePort: {{ .Values.qbitNetwork.btPort }}
  103. targetSelector: qbittorrent
  104. bt-upd:
  105. enabled: true
  106. primary: true
  107. port: {{ .Values.qbitNetwork.btPort }}
  108. nodePort: {{ .Values.qbitNetwork.btPort }}
  109. protocol: udp
  110. targetSelector: qbittorrent
  111. {{/* Persistence */}}
  112. persistence:
  113. config:
  114. enabled: true
  115. type: {{ .Values.qbitStorage.config.type }}
  116. datasetName: {{ .Values.qbitStorage.config.datasetName | default "" }}
  117. hostPath: {{ .Values.qbitStorage.config.hostPath | default "" }}
  118. targetSelector:
  119. qbittorrent:
  120. qbittorrent:
  121. mountPath: /config
  122. check-permissions:
  123. mountPath: /mnt/directories/config
  124. downloads:
  125. enabled: true
  126. type: {{ .Values.qbitStorage.downloads.type }}
  127. datasetName: {{ .Values.qbitStorage.downloads.datasetName | default "" }}
  128. hostPath: {{ .Values.qbitStorage.downloads.hostPath | default "" }}
  129. targetSelector:
  130. qbittorrent:
  131. qbittorrent:
  132. mountPath: /downloads
  133. check-permissions:
  134. mountPath: /mnt/directories/downloads
  135. {{- end -}}