_syncthing.tpl 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. {{- define "syncthing.workload" -}}
  2. workload:
  3. syncthing:
  4. enabled: true
  5. primary: true
  6. type: Deployment
  7. podSpec:
  8. hostNetwork: {{ .Values.syncthingNetwork.hostNetwork }}
  9. securityContext:
  10. fsGroup: {{ .Values.syncthingID.group }}
  11. containers:
  12. syncthing:
  13. enabled: true
  14. primary: true
  15. imageSelector: image
  16. securityContext:
  17. runAsUser: 0
  18. runAsGroup: 0
  19. runAsNonRoot: false
  20. readOnlyRootFilesystem: false
  21. # This is needed to allow syncthing assign
  22. # PCAPs to its child processes
  23. allowPrivilegeEscalation: true
  24. capabilities:
  25. add:
  26. - FOWNER
  27. - DAC_OVERRIDE
  28. - CHOWN
  29. - SETUID
  30. - SETGID
  31. - SETFCAP
  32. - SETPCAP
  33. env:
  34. PCAP: cap_chown,cap_dac_override,cap_fowner+ep
  35. STGUIADDRESS: "0.0.0.0:{{ .Values.syncthingNetwork.webPort }}"
  36. # Disable automatic upgrades
  37. STNOUPGRADE: "true"
  38. fixedEnv:
  39. PUID: {{ .Values.syncthingID.user }}
  40. probes:
  41. liveness:
  42. enabled: true
  43. type: http
  44. path: /rest/noauth/health
  45. port: "{{ .Values.syncthingNetwork.webPort }}"
  46. readiness:
  47. enabled: true
  48. type: http
  49. path: /rest/noauth/health
  50. port: "{{ .Values.syncthingNetwork.webPort }}"
  51. startup:
  52. enabled: true
  53. type: http
  54. path: /rest/noauth/health
  55. port: "{{ .Values.syncthingNetwork.webPort }}"
  56. # We use this hook as we need the API
  57. # to be running when we run the configure script
  58. lifecycle:
  59. postStart:
  60. type: exec
  61. command:
  62. - su-exec
  63. - "{{ .Values.syncthingID.user }}:{{ .Values.syncthingID.group }}"
  64. - /configure.sh
  65. {{- if .Values.syncthingNetwork.certificateID }}
  66. initContainers:
  67. {{- include "syncthing.certContainer" $ | nindent 8 -}}
  68. {{- end }}
  69. {{/* Service */}}
  70. service:
  71. syncthing-web:
  72. enabled: true
  73. primary: true
  74. type: NodePort
  75. targetSelector: syncthing
  76. ports:
  77. webui:
  78. enabled: true
  79. primary: true
  80. port: {{ .Values.syncthingNetwork.webPort }}
  81. nodePort: {{ .Values.syncthingNetwork.webPort }}
  82. targetSelector: syncthing
  83. syncthing-discovery:
  84. # Only enable this service if local discovery is enabled
  85. enabled: {{ .Values.syncthingConfig.localDiscovery }}
  86. type: NodePort
  87. targetSelector: syncthing
  88. ports:
  89. discovery:
  90. enabled: true
  91. port: {{ .Values.syncthingNetwork.localDiscoveryPort }}
  92. nodePort: {{ .Values.syncthingNetwork.localDiscoveryPort }}
  93. targetPort: 21017
  94. protocol: udp
  95. targetSelector: syncthing
  96. syncthing-transfer:
  97. enabled: true
  98. type: NodePort
  99. targetSelector: syncthing
  100. ports:
  101. tcp:
  102. enabled: true
  103. primary: true
  104. port: {{ .Values.syncthingNetwork.tcpPort }}
  105. nodePort: {{ .Values.syncthingNetwork.tcpPort }}
  106. targetPort: 22000
  107. targetSelector: syncthing
  108. quic:
  109. enabled: true
  110. port: {{ .Values.syncthingNetwork.quicPort }}
  111. nodePort: {{ .Values.syncthingNetwork.quicPort }}
  112. targetPort: 22000
  113. protocol: udp
  114. targetSelector: syncthing
  115. {{/* Persistence */}}
  116. persistence:
  117. home:
  118. enabled: true
  119. type: {{ .Values.syncthingStorage.home.type }}
  120. datasetName: {{ .Values.syncthingStorage.home.datasetName | default "" }}
  121. hostPath: {{ .Values.syncthingStorage.home.hostPath | default "" }}
  122. targetSelector:
  123. syncthing:
  124. syncthing:
  125. mountPath: /var/syncthing
  126. 01-certs:
  127. mountPath: /var/syncthing
  128. configure:
  129. enabled: true
  130. type: configmap
  131. objectName: syncthing-configure
  132. defaultMode: "0770"
  133. targetSelector:
  134. syncthing:
  135. syncthing:
  136. mountPath: /configure.sh
  137. subPath: configure.sh
  138. {{- if not .Values.syncthingStorage.additionalStorages -}}
  139. {{- fail "Syncthing - Expected at least one additional storage defined" -}}
  140. {{- end -}}
  141. {{- range $idx, $storage := .Values.syncthingStorage.additionalStorages }}
  142. {{ printf "sync-%v" (int $idx) }}:
  143. enabled: true
  144. type: {{ $storage.type }}
  145. datasetName: {{ $storage.datasetName | default "" }}
  146. hostPath: {{ $storage.hostPath | default "" }}
  147. targetSelector:
  148. syncthing:
  149. syncthing:
  150. mountPath: {{ $storage.mountPath }}
  151. {{- end }}
  152. {{- if .Values.syncthingNetwork.certificateID }}
  153. certs:
  154. enabled: true
  155. type: secret
  156. objectName: syncthing-cert
  157. defaultMode: "0600"
  158. items:
  159. - key: tls.key
  160. path: https-key.pem
  161. - key: tls.crt
  162. path: https-cert.pem
  163. targetSelector:
  164. syncthing:
  165. 01-certs:
  166. mountPath: /certs
  167. readOnly: true
  168. scaleCertificate:
  169. syncthing-cert:
  170. enabled: true
  171. id: {{ .Values.syncthingNetwork.certificateID }}
  172. {{- end -}}
  173. {{- end -}}