deployment.yaml 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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. {{ if and .Values.nextcloud.host .Values.service.nodePort }}
  82. {{ $envList = mustAppend $envList (dict "name" "OVERWRITEHOST" "value" (printf "%v:%v" .Values.nextcloud.host .Values.service.nodePort)) }}
  83. {{ end }}
  84. {{ $envList = mustAppend $envList (dict "name" "OVERWRITEPROTOCOL" "value" "https") }}
  85. {{ $envList = mustAppend $envList (dict "name" "TRUSTED_PROXIES" "value" "127.0.0.1") }}
  86. {{ end }}
  87. {{ $hostName := .Values.nextcloud.host }}
  88. {{ if .Values.useServiceNameForHost }}
  89. {{ $hostName = (include "common.names.fullname" .) }}
  90. {{ end }}
  91. {{ $envList = mustAppend $envList (dict "name" "NEXTCLOUD_TRUSTED_DOMAINS" "value" $hostName) }}
  92. {{ $envList = mustAppend $envList (dict "name" "NEXTCLOUD_ADMIN_USER" "valueFromSecret" true "secretName" $secretName "secretKey" "nextcloud-username") }}
  93. {{ $envList = mustAppend $envList (dict "name" "NEXTCLOUD_ADMIN_PASSWORD" "valueFromSecret" true "secretName" $secretName "secretKey" "nextcloud-password") }}
  94. {{ include "common.containers.environmentVariables" (dict "environmentVariables" $envList) | nindent 10 }}
  95. ports:
  96. - name: http
  97. containerPort: 80
  98. protocol: TCP
  99. livenessProbe:
  100. httpGet:
  101. path: /status.php
  102. port: http
  103. httpHeaders:
  104. - name: Host
  105. value: localhost
  106. initialDelaySeconds: 10
  107. periodSeconds: 10
  108. timeoutSeconds: 5
  109. failureThreshold: 5
  110. successThreshold: 1
  111. readinessProbe:
  112. httpGet:
  113. path: /status.php
  114. port: http
  115. httpHeaders:
  116. - name: Host
  117. value: localhost
  118. initialDelaySeconds: 10
  119. periodSeconds: 10
  120. timeoutSeconds: 5
  121. failureThreshold: 5
  122. successThreshold: 1
  123. startupProbe:
  124. {{- if .Values.nextcloud.install_ffmpeg }}
  125. exec:
  126. command:
  127. - /bin/sh
  128. - -c
  129. - |
  130. command -v ffmpeg /dev/null 2>&1 || exit 1
  131. {{- else }}
  132. httpGet:
  133. path: /status.php
  134. port: http
  135. httpHeaders:
  136. - name: Host
  137. value: localhost
  138. {{- end }}
  139. initialDelaySeconds: 10
  140. periodSeconds: 10
  141. timeoutSeconds: 5
  142. failureThreshold: 5
  143. successThreshold: 1
  144. volumeMounts:
  145. - name: nextcloud-data
  146. mountPath: /var/www/
  147. subPath: "root"
  148. - name: nextcloud-data
  149. mountPath: /var/www/html
  150. subPath: "html"
  151. - name: nextcloud-data
  152. mountPath: {{ .Values.nextcloud.datadir }}
  153. subPath: "data"
  154. - name: nextcloud-data
  155. mountPath: /var/www/html/config
  156. subPath: "config"
  157. - name: nextcloud-data
  158. mountPath: /var/www/html/custom_apps
  159. subPath: "custom_apps"
  160. - name: nextcloud-data
  161. mountPath: /var/www/tmp
  162. subPath: "tmp"
  163. - name: nextcloud-data
  164. mountPath: /var/www/html/themes
  165. subPath: "themes"
  166. {{ range $index, $hostPathConfiguration := .Values.extraAppVolumeMounts }}
  167. - name: extrappvolume-{{ $index }}
  168. mountPath: {{ $hostPathConfiguration.mountPath }}
  169. {{ end }}
  170. {{- if .Values.nextcloud.install_ffmpeg }}
  171. lifecycle:
  172. postStart:
  173. exec:
  174. command:
  175. - /bin/sh
  176. - -c
  177. - |
  178. echo "Installing ffmpeg..."
  179. apt update && \
  180. apt install -y --no-install-recommends \
  181. ffmpeg || echo "Failed to install ffmpeg"
  182. echo "Finished."
  183. {{- end }}
  184. {{ include "common.networking.dnsConfiguration" .Values | nindent 6 }}
  185. volumes:
  186. - name: nginx-configuration
  187. configMap:
  188. defaultMode: 0700
  189. name: "nginx-configuration"
  190. {{ include "nginx.tlsKeysVolume" . | nindent 8 }}
  191. {{ if .Values.appVolumeMounts }}
  192. {{ include "common.storage.configureAppVolumes" .Values | nindent 8 }}
  193. {{ end }}
  194. {{ range $index, $hostPathConfiguration := .Values.extraAppVolumeMounts }}
  195. - name: extrappvolume-{{ $index }}
  196. hostPath:
  197. path: {{ $hostPathConfiguration.hostPath }}
  198. {{ end }}
  199. # Will mount configuration files as www-data (id: 33) for nextcloud
  200. securityContext:
  201. fsGroup: 33