deployment.yaml 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. {{ include "common.storage.hostPathValidate" .Values }}
  2. {{ $postgres_values := (. | mustDeepCopy) }}
  3. {{ $_ := set $postgres_values "common" (dict "nameSuffix" "postgres") }}
  4. {{ include "common.deployment.common_config" . | nindent 0 }}
  5. spec: {{ include "common.deployment.common_spec" . | nindent 2 }}
  6. template: {{ include "common.deployment.pod.metadata" . | nindent 4 }}
  7. spec:
  8. initContainers:
  9. - name: init-postgresdb
  10. image: {{ template "postgres.imageName" . }}
  11. command: ['sh', '-c', "until pg_isready -U $POSTGRES_USER -d {{ include "postgres.DatabaseName" .Values }} -h {{ template "common.names.fullname" $postgres_values }}; do echo waiting for postgres; sleep 2; done"]
  12. imagePullPolicy: {{ .Values.image.pullPolicy }}
  13. env: {{ include "postgres.envVariableConfiguration" $postgres_values | nindent 10 }}
  14. containers:
  15. {{ if eq (include "nginx.certAvailable" .) "true" }}
  16. - name: nginx
  17. {{ include "common.containers.imageConfig" .Values.nginx.image | nindent 8 }}
  18. volumeMounts:
  19. - name: nginx-configuration
  20. mountPath: /etc/nginx/nginx.conf
  21. subPath: nginx.conf
  22. {{ include "nginx.tlsKeysVolumeMount" . | nindent 10 }}
  23. ports:
  24. - name: nginx-http
  25. containerPort: 8000
  26. protocol: TCP
  27. - name: nginx-https
  28. containerPort: 443
  29. protocol: TCP
  30. livenessProbe:
  31. httpGet:
  32. scheme: HTTPS
  33. path: /status.php
  34. port: 443
  35. httpHeaders:
  36. - name: Host
  37. value: localhost
  38. initialDelaySeconds: 10
  39. periodSeconds: 10
  40. timeoutSeconds: 5
  41. failureThreshold: 5
  42. successThreshold: 1
  43. readinessProbe:
  44. httpGet:
  45. scheme: HTTPS
  46. path: /status.php
  47. port: 443
  48. httpHeaders:
  49. - name: Host
  50. value: localhost
  51. initialDelaySeconds: 10
  52. periodSeconds: 10
  53. timeoutSeconds: 5
  54. failureThreshold: 5
  55. successThreshold: 2
  56. startupProbe:
  57. httpGet:
  58. scheme: HTTPS
  59. path: /status.php
  60. port: 443
  61. httpHeaders:
  62. - name: Host
  63. value: localhost
  64. initialDelaySeconds: 10
  65. periodSeconds: 5
  66. timeoutSeconds: 2
  67. failureThreshold: 60
  68. successThreshold: 1
  69. {{ end }}
  70. - name: {{ .Chart.Name }}
  71. {{ include "common.resources.limitation" . | nindent 8 }}
  72. {{ include "common.containers.imageConfig" .Values.image | nindent 8 }}
  73. env: {{ include "postgres.envVariableConfiguration" $postgres_values | nindent 10 }}
  74. {{ $secretName := (include "common.names.fullname" .) }}
  75. {{ $envList := (default list .Values.environmentVariables) }}
  76. {{ $envList = mustAppend $envList (dict "name" "POSTGRES_HOST" "value" (printf "%s:5432" (include "common.names.fullname" $postgres_values))) }}
  77. {{ $envList = mustAppend $envList (dict "name" "POSTGRES_DB" "value" (include "postgres.DatabaseName" .)) }}
  78. {{ $envList = mustAppend $envList (dict "name" "NEXTCLOUD_DATA_DIR" "value" .Values.nextcloud.datadir) }}
  79. {{ if eq (include "nginx.certAvailable" .) "true" }}
  80. {{ $envList = mustAppend $envList (dict "name" "APACHE_DISABLE_REWRITE_IP" "value" "1") }}
  81. {{ $envList = mustAppend $envList (dict "name" "OVERWRITEHOST" "value" (printf "%v:%v" .Values.nextcloud.host .Values.service.nodePort)) }}
  82. {{ $envList = mustAppend $envList (dict "name" "OVERWRITEPROTOCOL" "value" "https") }}
  83. {{ $envList = mustAppend $envList (dict "name" "TRUSTED_PROXIES" "value" "127.0.0.1") }}
  84. {{ end }}
  85. {{ $hostName := .Values.nextcloud.host }}
  86. {{ if .Values.useServiceNameForHost }}
  87. {{ $hostName = (include "common.names.fullname" .) }}
  88. {{ end }}
  89. {{ $envList = mustAppend $envList (dict "name" "NEXTCLOUD_TRUSTED_DOMAINS" "value" $hostName) }}
  90. {{ $envList = mustAppend $envList (dict "name" "NEXTCLOUD_ADMIN_USER" "valueFromSecret" true "secretName" $secretName "secretKey" "nextcloud-username") }}
  91. {{ $envList = mustAppend $envList (dict "name" "NEXTCLOUD_ADMIN_PASSWORD" "valueFromSecret" true "secretName" $secretName "secretKey" "nextcloud-password") }}
  92. {{ include "common.containers.environmentVariables" (dict "environmentVariables" $envList) | nindent 10 }}
  93. ports:
  94. - name: http
  95. containerPort: 80
  96. protocol: TCP
  97. livenessProbe:
  98. httpGet:
  99. path: /status.php
  100. port: http
  101. httpHeaders:
  102. - name: Host
  103. value: localhost
  104. initialDelaySeconds: 10
  105. periodSeconds: 10
  106. timeoutSeconds: 5
  107. failureThreshold: 5
  108. successThreshold: 1
  109. readinessProbe:
  110. httpGet:
  111. path: /status.php
  112. port: http
  113. httpHeaders:
  114. - name: Host
  115. value: localhost
  116. initialDelaySeconds: 10
  117. periodSeconds: 10
  118. timeoutSeconds: 5
  119. failureThreshold: 5
  120. successThreshold: 1
  121. startupProbe:
  122. {{- if .Values.nextcloud.install_ffmpeg }}
  123. exec:
  124. command:
  125. - /bin/sh
  126. - -c
  127. - |
  128. command -v ffmpeg /dev/null 2>&1 || exit 1
  129. {{- else }}
  130. httpGet:
  131. path: /status.php
  132. port: http
  133. httpHeaders:
  134. - name: Host
  135. value: localhost
  136. {{- end }}
  137. initialDelaySeconds: 10
  138. periodSeconds: 10
  139. timeoutSeconds: 5
  140. failureThreshold: 5
  141. successThreshold: 1
  142. volumeMounts:
  143. - name: nextcloud-data
  144. mountPath: /var/www/
  145. subPath: "root"
  146. - name: nextcloud-data
  147. mountPath: /var/www/html
  148. subPath: "html"
  149. - name: nextcloud-data
  150. mountPath: {{ .Values.nextcloud.datadir }}
  151. subPath: "data"
  152. - name: nextcloud-data
  153. mountPath: /var/www/html/config
  154. subPath: "config"
  155. - name: nextcloud-data
  156. mountPath: /var/www/html/custom_apps
  157. subPath: "custom_apps"
  158. - name: nextcloud-data
  159. mountPath: /var/www/tmp
  160. subPath: "tmp"
  161. - name: nextcloud-data
  162. mountPath: /var/www/html/themes
  163. subPath: "themes"
  164. {{ range $index, $hostPathConfiguration := .Values.extraAppVolumeMounts }}
  165. - name: extrappvolume-{{ $index }}
  166. mountPath: {{ $hostPathConfiguration.mountPath }}
  167. {{ end }}
  168. {{- if .Values.nextcloud.install_ffmpeg }}
  169. lifecycle:
  170. postStart:
  171. exec:
  172. command:
  173. - /bin/sh
  174. - -c
  175. - |
  176. echo "Installing ffmpeg..."
  177. apt update && \
  178. apt install -y --no-install-recommends \
  179. ffmpeg || echo "Failed to install ffmpeg"
  180. echo "Finished."
  181. {{- end }}
  182. {{ include "common.networking.dnsConfiguration" .Values | nindent 6 }}
  183. volumes:
  184. - name: nginx-configuration
  185. configMap:
  186. defaultMode: 0700
  187. name: "nginx-configuration"
  188. {{ include "nginx.tlsKeysVolume" . | nindent 8 }}
  189. {{ if .Values.appVolumeMounts }}
  190. {{ include "common.storage.configureAppVolumes" .Values | nindent 8 }}
  191. {{ end }}
  192. {{ range $index, $hostPathConfiguration := .Values.extraAppVolumeMounts }}
  193. - name: extrappvolume-{{ $index }}
  194. hostPath:
  195. path: {{ $hostPathConfiguration.hostPath }}
  196. {{ end }}
  197. # Will mount configuration files as www-data (id: 33) for nextcloud
  198. securityContext:
  199. fsGroup: 33