deployment.yaml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. apiVersion: apps/v1
  2. kind: Deployment
  3. metadata:
  4. name: {{ template "nextcloud.fullname" . }}
  5. labels:
  6. app.kubernetes.io/name: {{ include "nextcloud.name" . }}
  7. helm.sh/chart: {{ include "nextcloud.chart" . }}
  8. app.kubernetes.io/instance: {{ .Release.Name }}
  9. app.kubernetes.io/managed-by: {{ .Release.Service }}
  10. app.kubernetes.io/component: app
  11. {{- if .Values.deploymentAnnotations }}
  12. annotations:
  13. {{ toYaml .Values.deploymentAnnotations | indent 4 }}
  14. {{- end }}
  15. spec:
  16. replicas: {{ .Values.replicaCount }}
  17. strategy:
  18. type: {{ .Values.nextcloud.strategy }}
  19. selector:
  20. matchLabels:
  21. app.kubernetes.io/name: {{ include "nextcloud.name" . }}
  22. app.kubernetes.io/instance: {{ .Release.Name }}
  23. app.kubernetes.io/component: app
  24. template:
  25. metadata:
  26. labels:
  27. app.kubernetes.io/name: {{ include "nextcloud.name" . }}
  28. app.kubernetes.io/instance: {{ .Release.Name }}
  29. app.kubernetes.io/component: app
  30. {{- if .Values.podAnnotations }}
  31. annotations:
  32. {{ toYaml .Values.podAnnotations | indent 8 }}
  33. {{- end }}
  34. spec:
  35. {{- if .Values.image.pullSecrets }}
  36. imagePullSecrets:
  37. {{- range .Values.image.pullSecrets }}
  38. - name: {{ . }}
  39. {{- end}}
  40. {{- end }}
  41. containers:
  42. - name: {{ .Chart.Name }}
  43. image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
  44. imagePullPolicy: {{ .Values.image.pullPolicy }}
  45. {{- if .Values.lifecycle }}
  46. lifecycle:
  47. {{- if .Values.lifecycle.postStartCommand }}
  48. postStart:
  49. exec:
  50. command:
  51. {{- toYaml .Values.lifecycle.postStartCommand | nindent 16 -}}
  52. {{- end }}
  53. {{- if .Values.lifecycle.preStopCommand }}
  54. preStop:
  55. exec:
  56. command:
  57. {{- toYaml .Values.lifecycle.preStopCommand | nindent 16 -}}
  58. {{- end }}
  59. {{- end }}
  60. env:
  61. {{- if .Values.internalDatabase.enabled }}
  62. - name: SQLITE_DATABASE
  63. value: {{ .Values.internalDatabase.name | quote }}
  64. {{- else }}
  65. {{- if eq .Values.externalDatabase.type "postgresql" }}
  66. - name: POSTGRES_HOST
  67. value: {{ .Values.externalDatabase.host | quote }}
  68. - name: POSTGRES_DB
  69. value: {{ .Values.externalDatabase.database | quote }}
  70. - name: POSTGRES_USER
  71. valueFrom:
  72. secretKeyRef:
  73. name: {{ .Values.externalDatabase.existingSecret.secretName | default (printf "%s-%s" .Release.Name "db") }}
  74. key: {{ .Values.externalDatabase.existingSecret.usernameKey | default "db-username" }}
  75. - name: POSTGRES_PASSWORD
  76. valueFrom:
  77. secretKeyRef:
  78. name: {{ .Values.externalDatabase.existingSecret.secretName | default (printf "%s-%s" .Release.Name "db") }}
  79. key: {{ .Values.externalDatabase.existingSecret.passwordKey | default "db-password" }}
  80. {{- else }}
  81. - name: MYSQL_HOST
  82. value: {{ .Values.externalDatabase.host | quote }}
  83. - name: MYSQL_DATABASE
  84. value: {{ .Values.externalDatabase.database | quote }}
  85. - name: MYSQL_USER
  86. valueFrom:
  87. secretKeyRef:
  88. name: {{ .Values.externalDatabase.existingSecret.secretName | default (printf "%s-%s" .Release.Name "db") }}
  89. key: {{ .Values.externalDatabase.existingSecret.usernameKey | default "db-username" }}
  90. - name: MYSQL_PASSWORD
  91. valueFrom:
  92. secretKeyRef:
  93. name: {{ .Values.externalDatabase.existingSecret.secretName | default (printf "%s-%s" .Release.Name "db") }}
  94. key: {{ .Values.externalDatabase.existingSecret.passwordKey | default "db-password" }}
  95. {{- end }}
  96. {{- end }}
  97. - name: NEXTCLOUD_ADMIN_USER
  98. valueFrom:
  99. secretKeyRef:
  100. name: {{ template "nextcloud.fullname" . }}
  101. key: nextcloud-username
  102. - name: NEXTCLOUD_ADMIN_PASSWORD
  103. valueFrom:
  104. secretKeyRef:
  105. name: {{ template "nextcloud.fullname" . }}
  106. key: nextcloud-password
  107. - name: NEXTCLOUD_TRUSTED_DOMAINS
  108. value: {{ .Values.nextcloud.host }}
  109. {{- if ne (int .Values.nextcloud.update) 0 }}
  110. - name: NEXTCLOUD_UPDATE
  111. value: {{ .Values.nextcloud.update | quote }}
  112. {{- end }}
  113. - name: NEXTCLOUD_DATA_DIR
  114. value: {{ .Values.nextcloud.datadir | quote }}
  115. {{- if .Values.nextcloud.tableprefix }}
  116. - name: NEXTCLOUD_TABLE_PREFIX
  117. value: {{ .Values.nextcloud.tableprefix | quote }}
  118. {{- end }}
  119. {{- if .Values.nextcloud.mail.enabled }}
  120. - name: MAIL_FROM_ADDRESS
  121. value: {{ .Values.nextcloud.mail.fromAddress | quote }}
  122. - name: MAIL_DOMAIN
  123. value: {{ .Values.nextcloud.mail.domain | quote }}
  124. - name: SMTP_HOST
  125. value: {{ .Values.nextcloud.mail.smtp.host | quote }}
  126. - name: SMTP_SECURE
  127. value: {{ .Values.nextcloud.mail.smtp.secure | quote }}
  128. - name: SMTP_PORT
  129. value: {{ .Values.nextcloud.mail.smtp.port | quote }}
  130. - name: SMTP_AUTHTYPE
  131. value: {{ .Values.nextcloud.mail.smtp.authtype | quote }}
  132. - name: SMTP_NAME
  133. valueFrom:
  134. secretKeyRef:
  135. name: {{ template "nextcloud.fullname" . }}
  136. key: smtp-username
  137. - name: SMTP_PASSWORD
  138. valueFrom:
  139. secretKeyRef:
  140. name: {{ template "nextcloud.fullname" . }}
  141. key: smtp-password
  142. {{- end }}
  143. {{- if .Values.nextcloud.extraEnv }}
  144. {{ toYaml .Values.nextcloud.extraEnv | indent 8 }}
  145. {{- end }}
  146. {{- if not .Values.nginx.enabled }}
  147. ports:
  148. - name: http
  149. containerPort: 80
  150. protocol: TCP
  151. {{- end }}
  152. {{- if and .Values.livenessProbe.enabled (not .Values.nginx.enabled) }}
  153. livenessProbe:
  154. httpGet:
  155. path: /status.php
  156. port: http
  157. httpHeaders:
  158. - name: Host
  159. value: {{ .Values.nextcloud.host | quote }}
  160. initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
  161. periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
  162. timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
  163. successThreshold: {{ .Values.livenessProbe.successThreshold }}
  164. failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
  165. {{- end }}
  166. {{- if and .Values.readinessProbe.enabled (not .Values.nginx.enabled) }}
  167. readinessProbe:
  168. httpGet:
  169. path: /status.php
  170. port: http
  171. httpHeaders:
  172. - name: Host
  173. value: {{ .Values.nextcloud.host | quote }}
  174. initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
  175. periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
  176. timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
  177. successThreshold: {{ .Values.readinessProbe.successThreshold }}
  178. failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
  179. {{- end }}
  180. resources:
  181. {{ toYaml .Values.resources | indent 10 }}
  182. volumeMounts:
  183. - name: nextcloud-data
  184. mountPath: /var/www/
  185. subPath: {{ ternary "root" (printf "%s/%s" .Values.nextcloud.persistence.subPath "root") (empty .Values.nextcloud.persistence.subPath) }}
  186. - name: nextcloud-data
  187. mountPath: /var/www/html
  188. subPath: {{ ternary "html" (printf "%s/%s" .Values.nextcloud.persistence.subPath "html") (empty .Values.nextcloud.persistence.subPath) }}
  189. - name: nextcloud-data
  190. mountPath: {{ .Values.nextcloud.datadir }}
  191. subPath: {{ ternary "data" (printf "%s/%s" .Values.nextcloud.persistence.subPath "data") (empty .Values.nextcloud.persistence.subPath) }}
  192. - name: nextcloud-data
  193. mountPath: /var/www/html/config
  194. subPath: {{ ternary "config" (printf "%s/%s" .Values.nextcloud.persistence.subPath "config") (empty .Values.nextcloud.persistence.subPath) }}
  195. - name: nextcloud-data
  196. mountPath: /var/www/html/custom_apps
  197. subPath: {{ ternary "custom_apps" (printf "%s/%s" .Values.nextcloud.persistence.subPath "custom_apps") (empty .Values.nextcloud.persistence.subPath) }}
  198. - name: nextcloud-data
  199. mountPath: /var/www/tmp
  200. subPath: {{ ternary "tmp" (printf "%s/%s" .Values.nextcloud.persistence.subPath "tmp") (empty .Values.nextcloud.persistence.subPath) }}
  201. - name: nextcloud-data
  202. mountPath: /var/www/html/themes
  203. subPath: {{ ternary "themes" (printf "%s/%s" .Values.nextcloud.persistence.subPath "themes") (empty .Values.nextcloud.persistence.subPath) }}
  204. {{- range $key, $value := .Values.nextcloud.configs }}
  205. - name: nextcloud-config
  206. mountPath: /var/www/html/config/{{ $key }}
  207. subPath: {{ $key }}
  208. {{- end }}
  209. {{- if .Values.nextcloud.configs }}
  210. {{- range $key, $value := .Values.nextcloud.defaultConfigs }}
  211. {{- if $value }}
  212. - name: nextcloud-config
  213. mountPath: /var/www/html/config/{{ $key }}
  214. subPath: {{ $key }}
  215. {{- end }}
  216. {{- end }}
  217. {{- end }}
  218. {{- range $key, $value := .Values.nextcloud.phpConfigs }}
  219. - name: nextcloud-phpconfig
  220. mountPath: /usr/local/etc/php/conf.d/{{ $key }}
  221. subPath: {{ $key }}
  222. {{- end }}
  223. {{- if .Values.nextcloud.extraVolumeMounts }}
  224. {{ toYaml .Values.nextcloud.extraVolumeMounts | indent 8 }}
  225. {{- end }}
  226. {{- if .Values.nginx.enabled }}
  227. - name: {{ .Chart.Name }}-nginx
  228. image: "{{ .Values.nginx.image.repository }}:{{ .Values.nginx.image.tag }}"
  229. imagePullPolicy: {{ .Values.nginx.image.pullPolicy }}
  230. ports:
  231. - name: http
  232. containerPort: 80
  233. protocol: TCP
  234. {{- if .Values.livenessProbe.enabled }}
  235. livenessProbe:
  236. httpGet:
  237. path: /status.php
  238. port: http
  239. httpHeaders:
  240. - name: Host
  241. value: {{ .Values.nextcloud.host | quote }}
  242. initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
  243. periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
  244. timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
  245. successThreshold: {{ .Values.livenessProbe.successThreshold }}
  246. failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
  247. {{- end }}
  248. {{- if .Values.readinessProbe.enabled }}
  249. readinessProbe:
  250. httpGet:
  251. path: /status.php
  252. port: http
  253. httpHeaders:
  254. - name: Host
  255. value: {{ .Values.nextcloud.host | quote }}
  256. initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
  257. periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
  258. timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
  259. successThreshold: {{ .Values.readinessProbe.successThreshold }}
  260. failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
  261. {{- end }}
  262. resources:
  263. {{ toYaml .Values.nginx.resources | indent 10 }}
  264. volumeMounts:
  265. - name: nextcloud-data
  266. mountPath: /var/www/
  267. subPath: {{ ternary "root" (printf "%s/%s" .Values.nextcloud.persistence.subPath "root") (empty .Values.nextcloud.persistence.subPath) }}
  268. - name: nextcloud-data
  269. mountPath: /var/www/html
  270. subPath: {{ ternary "html" (printf "%s/%s" .Values.nextcloud.persistence.subPath "html") (empty .Values.nextcloud.persistence.subPath) }}
  271. - name: nextcloud-data
  272. mountPath: {{ .Values.nextcloud.datadir }}
  273. subPath: {{ ternary "data" (printf "%s/%s" .Values.nextcloud.persistence.subPath "data") (empty .Values.nextcloud.persistence.subPath) }}
  274. - name: nextcloud-data
  275. mountPath: /var/www/html/config
  276. subPath: {{ ternary "config" (printf "%s/%s" .Values.nextcloud.persistence.subPath "config") (empty .Values.nextcloud.persistence.subPath) }}
  277. - name: nextcloud-data
  278. mountPath: /var/www/html/custom_apps
  279. subPath: {{ ternary "custom_apps" (printf "%s/%s" .Values.nextcloud.persistence.subPath "custom_apps") (empty .Values.nextcloud.persistence.subPath) }}
  280. - name: nextcloud-data
  281. mountPath: /var/www/tmp
  282. subPath: {{ ternary "tmp" (printf "%s/%s" .Values.nextcloud.persistence.subPath "tmp") (empty .Values.nextcloud.persistence.subPath) }}
  283. - name: nextcloud-data
  284. mountPath: /var/www/html/themes
  285. subPath: {{ ternary "themes" (printf "%s/%s" .Values.nextcloud.persistence.subPath "themes") (empty .Values.nextcloud.persistence.subPath) }}
  286. - name: nextcloud-nginx-config
  287. mountPath: /etc/nginx/nginx.conf
  288. subPath: nginx.conf
  289. {{- end }}
  290. {{- with .Values.nodeSelector }}
  291. nodeSelector:
  292. {{- toYaml . | nindent 8 }}
  293. {{- end }}
  294. {{- with .Values.affinity }}
  295. affinity:
  296. {{- toYaml . | nindent 8 }}
  297. {{- end }}
  298. {{- with .Values.tolerations }}
  299. tolerations:
  300. {{- toYaml . | nindent 8 }}
  301. {{- end }}
  302. volumes:
  303. - name: nextcloud-data
  304. {{- if ne (include "configuredHostPath" .) "" }}
  305. hostPath:
  306. path: {{ template "configuredHostPath" . }}
  307. {{- else }}
  308. emptyDir: {}
  309. {{- end }}
  310. {{- if .Values.nextcloud.configs }}
  311. - name: nextcloud-config
  312. configMap:
  313. name: {{ template "nextcloud.fullname" . }}-config
  314. {{- end }}
  315. {{- if .Values.nextcloud.phpConfigs }}
  316. - name: nextcloud-phpconfig
  317. configMap:
  318. name: {{ template "nextcloud.fullname" . }}-phpconfig
  319. {{- end }}
  320. {{- if .Values.nginx.enabled }}
  321. - name: nextcloud-nginx-config
  322. configMap:
  323. name: {{ template "nextcloud.fullname" . }}-nginxconfig
  324. {{- end }}
  325. {{- if .Values.nextcloud.extraVolumes }}
  326. {{ toYaml .Values.nextcloud.extraVolumes | indent 6 }}
  327. {{- end }}
  328. {{- if .Values.nginx.enabled }}
  329. # Will mount configuration files as www-data (id: 82) for nextcloud
  330. securityContext:
  331. fsGroup: 82
  332. {{- else }}
  333. # Will mount configuration files as www-data (id: 33) for nextcloud
  334. securityContext:
  335. fsGroup: 33
  336. {{- end }}