sftp-deployment.yaml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. {{- if .Values.sftp.enabled }}
  2. apiVersion: apps/v1
  3. kind: Deployment
  4. metadata:
  5. name: {{ template "seaweedfs.name" . }}-sftp
  6. namespace: {{ .Release.Namespace }}
  7. labels:
  8. app.kubernetes.io/name: {{ template "seaweedfs.name" . }}
  9. helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
  10. app.kubernetes.io/managed-by: {{ .Release.Service }}
  11. app.kubernetes.io/instance: {{ .Release.Name }}
  12. app.kubernetes.io/component: sftp
  13. {{- if .Values.sftp.annotations }}
  14. annotations:
  15. {{- toYaml .Values.sftp.annotations | nindent 4 }}
  16. {{- end }}
  17. spec:
  18. replicas: {{ .Values.sftp.replicas }}
  19. selector:
  20. matchLabels:
  21. app.kubernetes.io/name: {{ template "seaweedfs.name" . }}
  22. app.kubernetes.io/instance: {{ .Release.Name }}
  23. app.kubernetes.io/component: sftp
  24. template:
  25. metadata:
  26. labels:
  27. app.kubernetes.io/name: {{ template "seaweedfs.name" . }}
  28. helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
  29. app.kubernetes.io/instance: {{ .Release.Name }}
  30. app.kubernetes.io/component: sftp
  31. {{ with .Values.podLabels }}
  32. {{- toYaml . | nindent 8 }}
  33. {{- end }}
  34. {{- with .Values.sftp.podLabels }}
  35. {{- toYaml . | nindent 8 }}
  36. {{- end }}
  37. annotations:
  38. {{ with .Values.podAnnotations }}
  39. {{- toYaml . | nindent 8 }}
  40. {{- end }}
  41. {{- with .Values.sftp.podAnnotations }}
  42. {{- toYaml . | nindent 8 }}
  43. {{- end }}
  44. spec:
  45. restartPolicy: {{ default .Values.global.restartPolicy .Values.sftp.restartPolicy }}
  46. {{- if .Values.sftp.affinity }}
  47. affinity:
  48. {{ tpl .Values.sftp.affinity . | nindent 8 | trim }}
  49. {{- end }}
  50. {{- if .Values.sftp.topologySpreadConstraints }}
  51. topologySpreadConstraints:
  52. {{ tpl .Values.sftp.topologySpreadConstraint . | nindent 8 | trim }}
  53. {{- end }}
  54. {{- if .Values.sftp.tolerations }}
  55. tolerations:
  56. {{ tpl .Values.sftp.tolerations . | nindent 8 | trim }}
  57. {{- end }}
  58. {{- include "seaweedfs.imagePullSecrets" . | nindent 6 }}
  59. terminationGracePeriodSeconds: 10
  60. {{- if .Values.sftp.priorityClassName }}
  61. priorityClassName: {{ .Values.sftp.priorityClassName | quote }}
  62. {{- end }}
  63. enableServiceLinks: false
  64. {{- if .Values.sftp.serviceAccountName }}
  65. serviceAccountName: {{ .Values.sftp.serviceAccountName | quote }}
  66. {{- end }}
  67. {{- if .Values.sftp.initContainers }}
  68. initContainers:
  69. {{ tpl .Values.sftp.initContainers . | nindent 8 | trim }}
  70. {{- end }}
  71. {{- if .Values.sftp.podSecurityContext.enabled }}
  72. securityContext: {{- omit .Values.sftp.podSecurityContext "enabled" | toYaml | nindent 8 }}
  73. {{- end }}
  74. containers:
  75. - name: seaweedfs
  76. image: {{ template "sftp.image" . }}
  77. imagePullPolicy: {{ default "IfNotPresent" .Values.global.imagePullPolicy }}
  78. env:
  79. - name: POD_IP
  80. valueFrom:
  81. fieldRef:
  82. fieldPath: status.podIP
  83. - name: POD_NAME
  84. valueFrom:
  85. fieldRef:
  86. fieldPath: metadata.name
  87. - name: NAMESPACE
  88. valueFrom:
  89. fieldRef:
  90. fieldPath: metadata.namespace
  91. - name: SEAWEEDFS_FULLNAME
  92. value: "{{ template "seaweedfs.name" . }}"
  93. {{- if .Values.sftp.extraEnvironmentVars }}
  94. {{- range $key, $value := .Values.sftp.extraEnvironmentVars }}
  95. - name: {{ $key }}
  96. {{- if kindIs "string" $value }}
  97. value: {{ $value | quote }}
  98. {{- else }}
  99. valueFrom:
  100. {{ toYaml $value | nindent 16 | trim }}
  101. {{- end -}}
  102. {{- end }}
  103. {{- end }}
  104. {{- if .Values.global.extraEnvironmentVars }}
  105. {{- range $key, $value := .Values.global.extraEnvironmentVars }}
  106. - name: {{ $key }}
  107. {{- if kindIs "string" $value }}
  108. value: {{ $value | quote }}
  109. {{- else }}
  110. valueFrom:
  111. {{ toYaml $value | nindent 16 | trim }}
  112. {{- end -}}
  113. {{- end }}
  114. {{- end }}
  115. command:
  116. - "/bin/sh"
  117. - "-ec"
  118. - |
  119. exec /usr/bin/weed \
  120. {{- if or (eq .Values.sftp.logs.type "hostPath") (eq .Values.sftp.logs.type "emptyDir") }}
  121. -logdir=/logs \
  122. {{- else }}
  123. -logtostderr=true \
  124. {{- end }}
  125. {{- if .Values.sftp.loggingOverrideLevel }}
  126. -v={{ .Values.sftp.loggingOverrideLevel }} \
  127. {{- else }}
  128. -v={{ .Values.global.loggingLevel }} \
  129. {{- end }}
  130. sftp \
  131. -ip.bind={{ .Values.sftp.bindAddress }} \
  132. -port={{ .Values.sftp.port }} \
  133. {{- if .Values.sftp.metricsPort }}
  134. -metricsPort={{ .Values.sftp.metricsPort }} \
  135. {{- end }}
  136. {{- if .Values.sftp.metricsIp }}
  137. -metricsIp={{ .Values.sftp.metricsIp }} \
  138. {{- end }}
  139. {{- if .Values.sftp.sshPrivateKey }}
  140. -sshPrivateKey={{ .Values.sftp.sshPrivateKey }} \
  141. {{- end }}
  142. {{- if .Values.sftp.hostKeysFolder }}
  143. -hostKeysFolder={{ .Values.sftp.hostKeysFolder }} \
  144. {{- end }}
  145. {{- if .Values.sftp.authMethods }}
  146. -authMethods={{ .Values.sftp.authMethods }} \
  147. {{- end }}
  148. {{- if .Values.sftp.maxAuthTries }}
  149. -maxAuthTries={{ .Values.sftp.maxAuthTries }} \
  150. {{- end }}
  151. {{- if .Values.sftp.bannerMessage }}
  152. -bannerMessage="{{ .Values.sftp.bannerMessage }}" \
  153. {{- end }}
  154. {{- if .Values.sftp.loginGraceTime }}
  155. -loginGraceTime={{ .Values.sftp.loginGraceTime }} \
  156. {{- end }}
  157. {{- if .Values.sftp.clientAliveInterval }}
  158. -clientAliveInterval={{ .Values.sftp.clientAliveInterval }} \
  159. {{- end }}
  160. {{- if .Values.sftp.clientAliveCountMax }}
  161. -clientAliveCountMax={{ .Values.sftp.clientAliveCountMax }} \
  162. {{- end }}
  163. {{- if .Values.sftp.dataCenter }}
  164. -dataCenter={{ .Values.sftp.dataCenter }} \
  165. {{- end }}
  166. {{- if .Values.sftp.localSocket }}
  167. -localSocket={{ .Values.sftp.localSocket }} \
  168. {{- end }}
  169. {{- if .Values.global.enableSecurity }}
  170. -cert.file=/usr/local/share/ca-certificates/client/tls.crt \
  171. -key.file=/usr/local/share/ca-certificates/client/tls.key \
  172. {{- end }}
  173. -userStoreFile=/etc/sw/seaweedfs_sftp_config \
  174. -filer={{ template "seaweedfs.name" . }}-filer-client.{{ .Release.Namespace }}:{{ .Values.filer.port }}
  175. volumeMounts:
  176. {{- if or (eq .Values.sftp.logs.type "hostPath") (eq .Values.sftp.logs.type "emptyDir") }}
  177. - name: logs
  178. mountPath: "/logs/"
  179. {{- end }}
  180. {{- if .Values.sftp.enableAuth }}
  181. - mountPath: /etc/sw
  182. name: config-users
  183. readOnly: true
  184. {{- end }}
  185. - mountPath: /etc/sw/ssh
  186. name: config-ssh
  187. readOnly: true
  188. {{- if .Values.global.enableSecurity }}
  189. - name: security-config
  190. readOnly: true
  191. mountPath: /etc/seaweedfs/security.toml
  192. subPath: security.toml
  193. - name: ca-cert
  194. readOnly: true
  195. mountPath: /usr/local/share/ca-certificates/ca/
  196. - name: master-cert
  197. readOnly: true
  198. mountPath: /usr/local/share/ca-certificates/master/
  199. - name: volume-cert
  200. readOnly: true
  201. mountPath: /usr/local/share/ca-certificates/volume/
  202. - name: filer-cert
  203. readOnly: true
  204. mountPath: /usr/local/share/ca-certificates/filer/
  205. - name: client-cert
  206. readOnly: true
  207. mountPath: /usr/local/share/ca-certificates/client/
  208. {{- end }}
  209. {{ tpl .Values.sftp.extraVolumeMounts . | nindent 12 | trim }}
  210. ports:
  211. - containerPort: {{ .Values.sftp.port }}
  212. name: swfs-sftp
  213. {{- if .Values.sftp.metricsPort }}
  214. - containerPort: {{ .Values.sftp.metricsPort }}
  215. name: metrics
  216. {{- end }}
  217. {{- if .Values.sftp.readinessProbe.enabled }}
  218. readinessProbe:
  219. tcpSocket:
  220. port: {{ .Values.sftp.port }}
  221. initialDelaySeconds: {{ .Values.sftp.readinessProbe.initialDelaySeconds }}
  222. periodSeconds: {{ .Values.sftp.readinessProbe.periodSeconds }}
  223. successThreshold: {{ .Values.sftp.readinessProbe.successThreshold }}
  224. failureThreshold: {{ .Values.sftp.readinessProbe.failureThreshold }}
  225. timeoutSeconds: {{ .Values.sftp.readinessProbe.timeoutSeconds }}
  226. {{- end }}
  227. {{- if .Values.sftp.livenessProbe.enabled }}
  228. livenessProbe:
  229. tcpSocket:
  230. port: {{ .Values.sftp.port }}
  231. initialDelaySeconds: {{ .Values.sftp.livenessProbe.initialDelaySeconds }}
  232. periodSeconds: {{ .Values.sftp.livenessProbe.periodSeconds }}
  233. successThreshold: {{ .Values.sftp.livenessProbe.successThreshold }}
  234. failureThreshold: {{ .Values.sftp.livenessProbe.failureThreshold }}
  235. timeoutSeconds: {{ .Values.sftp.livenessProbe.timeoutSeconds }}
  236. {{- end }}
  237. {{- with .Values.sftp.resources }}
  238. resources:
  239. {{- toYaml . | nindent 12 }}
  240. {{- end }}
  241. {{- if .Values.sftp.containerSecurityContext.enabled }}
  242. securityContext: {{- omit .Values.sftp.containerSecurityContext "enabled" | toYaml | nindent 12 }}
  243. {{- end }}
  244. {{- if .Values.sftp.sidecars }}
  245. {{- include "common.tplvalues.render" (dict "value" .Values.sftp.sidecars "context" $) | nindent 8 }}
  246. {{- end }}
  247. volumes:
  248. {{- if .Values.sftp.enableAuth }}
  249. - name: config-users
  250. secret:
  251. defaultMode: 420
  252. {{- if .Values.sftp.existingConfigSecret }}
  253. secretName: {{ .Values.sftp.existingConfigSecret }}
  254. {{- else }}
  255. secretName: seaweedfs-sftp-secret
  256. {{- end }}
  257. {{- end }}
  258. - name: config-ssh
  259. secret:
  260. defaultMode: 420
  261. {{- if .Values.sftp.existingSshConfigSecret }}
  262. secretName: {{ .Values.sftp.existingSshConfigSecret }}
  263. {{- else }}
  264. secretName: seaweedfs-sftp-ssh-secret
  265. {{- end }}
  266. {{- if eq .Values.sftp.logs.type "hostPath" }}
  267. - name: logs
  268. hostPath:
  269. path: {{ .Values.sftp.logs.hostPathPrefix }}/logs/seaweedfs/sftp
  270. type: DirectoryOrCreate
  271. {{- end }}
  272. {{- if eq .Values.sftp.logs.type "emptyDir" }}
  273. - name: logs
  274. emptyDir: {}
  275. {{- end }}
  276. {{- if .Values.global.enableSecurity }}
  277. - name: security-config
  278. configMap:
  279. name: {{ template "seaweedfs.name" . }}-security-config
  280. - name: ca-cert
  281. secret:
  282. secretName: {{ template "seaweedfs.name" . }}-ca-cert
  283. - name: master-cert
  284. secret:
  285. secretName: {{ template "seaweedfs.name" . }}-master-cert
  286. - name: volume-cert
  287. secret:
  288. secretName: {{ template "seaweedfs.name" . }}-volume-cert
  289. - name: filer-cert
  290. secret:
  291. secretName: {{ template "seaweedfs.name" . }}-filer-cert
  292. - name: client-cert
  293. secret:
  294. secretName: {{ template "seaweedfs.name" . }}-client-cert
  295. {{- end }}
  296. {{ tpl .Values.sftp.extraVolumes . | indent 8 | trim }}
  297. {{- if .Values.sftp.nodeSelector }}
  298. nodeSelector:
  299. {{ tpl .Values.sftp.nodeSelector . | indent 8 | trim }}
  300. {{- end }}
  301. {{- end }}