deployment.yaml 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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. {{ end }}
  31. - name: {{ .Chart.Name }}
  32. {{ include "common.resources.limitation" . | nindent 8 }}
  33. {{ include "common.containers.imageConfig" .Values.image | nindent 8 }}
  34. env: {{ include "postgres.envVariableConfiguration" $postgres_values | nindent 10 }}
  35. {{ $secretName := (include "common.names.fullname" .) }}
  36. {{ $envList := (default list .Values.environmentVariables) }}
  37. {{ $envList = mustAppend $envList (dict "name" "POSTGRES_HOST" "value" (printf "%s:5432" (include "common.names.fullname" $postgres_values))) }}
  38. {{ $envList = mustAppend $envList (dict "name" "POSTGRES_DB" "value" (include "postgres.DatabaseName" .)) }}
  39. {{ $envList = mustAppend $envList (dict "name" "NEXTCLOUD_DATA_DIR" "value" .Values.nextcloud.datadir) }}
  40. {{ if eq (include "nginx.certAvailable" .) "true" }}
  41. {{ $envList = mustAppend $envList (dict "name" "APACHE_DISABLE_REWRITE_IP" "value" "1") }}
  42. {{ $envList = mustAppend $envList (dict "name" "OVERWRITEHOST" "value" (printf "%v:%v" .Values.nextcloud.host .Values.service.nodePort)) }}
  43. {{ $envList = mustAppend $envList (dict "name" "OVERWRITEPROTOCOL" "value" "https") }}
  44. {{ $envList = mustAppend $envList (dict "name" "TRUSTED_PROXIES" "value" "127.0.0.1") }}
  45. {{ end }}
  46. {{ $hostName := .Values.nextcloud.host }}
  47. {{ if .Values.useServiceNameForHost }}
  48. {{ $hostName = (include "common.names.fullname" .) }}
  49. {{ end }}
  50. {{ $envList = mustAppend $envList (dict "name" "NEXTCLOUD_TRUSTED_DOMAINS" "value" $hostName) }}
  51. {{ $envList = mustAppend $envList (dict "name" "NEXTCLOUD_ADMIN_USER" "valueFromSecret" true "secretName" $secretName "secretKey" "nextcloud-username") }}
  52. {{ $envList = mustAppend $envList (dict "name" "NEXTCLOUD_ADMIN_PASSWORD" "valueFromSecret" true "secretName" $secretName "secretKey" "nextcloud-password") }}
  53. {{ include "common.containers.environmentVariables" (dict "environmentVariables" $envList) | nindent 10 }}
  54. ports:
  55. - name: http
  56. containerPort: 80
  57. protocol: TCP
  58. livenessProbe:
  59. httpGet:
  60. path: /status.php
  61. port: http
  62. httpHeaders:
  63. - name: Host
  64. value: localhost
  65. initialDelaySeconds: 30
  66. periodSeconds: 10
  67. timeoutSeconds: 5
  68. failureThreshold: 5
  69. readinessProbe:
  70. httpGet:
  71. path: /status.php
  72. port: http
  73. httpHeaders:
  74. - name: Host
  75. value: localhost
  76. initialDelaySeconds: 30
  77. periodSeconds: 10
  78. timeoutSeconds: 5
  79. failureThreshold: 5
  80. startupProbe:
  81. {{- if .Values.nextcloud.install_ffmpeg }}
  82. exec:
  83. command:
  84. - /bin/sh
  85. - -c
  86. - |
  87. command -v ffmpeg /dev/null 2>&1 || exit 1
  88. {{- else }}
  89. httpGet:
  90. path: /status.php
  91. port: http
  92. httpHeaders:
  93. - name: Host
  94. value: localhost
  95. {{- end }}
  96. initialDelaySeconds: 60
  97. periodSeconds: 10
  98. timeoutSeconds: 5
  99. failureThreshold: 60
  100. volumeMounts:
  101. - name: nextcloud-data
  102. mountPath: /var/www/
  103. subPath: "root"
  104. - name: nextcloud-data
  105. mountPath: /var/www/html
  106. subPath: "html"
  107. - name: nextcloud-data
  108. mountPath: {{ .Values.nextcloud.datadir }}
  109. subPath: "data"
  110. - name: nextcloud-data
  111. mountPath: /var/www/html/config
  112. subPath: "config"
  113. - name: nextcloud-data
  114. mountPath: /var/www/html/custom_apps
  115. subPath: "custom_apps"
  116. - name: nextcloud-data
  117. mountPath: /var/www/tmp
  118. subPath: "tmp"
  119. - name: nextcloud-data
  120. mountPath: /var/www/html/themes
  121. subPath: "themes"
  122. {{ range $index, $hostPathConfiguration := .Values.extraAppVolumeMounts }}
  123. - name: extrappvolume-{{ $index }}
  124. mountPath: {{ $hostPathConfiguration.mountPath }}
  125. {{ end }}
  126. {{- if .Values.nextcloud.install_ffmpeg }}
  127. lifecycle:
  128. postStart:
  129. exec:
  130. command:
  131. - /bin/sh
  132. - -c
  133. - |
  134. echo "Installing ffmpeg..."
  135. apt update && \
  136. apt install -y --no-install-recommends \
  137. ffmpeg || echo "Failed to install ffmpeg"
  138. echo "Finished."
  139. {{- end }}
  140. {{ include "common.networking.dnsConfiguration" .Values | nindent 6 }}
  141. volumes:
  142. - name: nginx-configuration
  143. configMap:
  144. defaultMode: 0700
  145. name: "nginx-configuration"
  146. {{ include "nginx.tlsKeysVolume" . | nindent 8 }}
  147. {{ if .Values.appVolumeMounts }}
  148. {{ include "common.storage.configureAppVolumes" .Values | nindent 8 }}
  149. {{ end }}
  150. {{ range $index, $hostPathConfiguration := .Values.extraAppVolumeMounts }}
  151. - name: extrappvolume-{{ $index }}
  152. hostPath:
  153. path: {{ $hostPathConfiguration.hostPath }}
  154. {{ end }}
  155. # Will mount configuration files as www-data (id: 33) for nextcloud
  156. securityContext:
  157. fsGroup: 33