deployment.yaml 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. volumeMounts:
  59. - name: nextcloud-data
  60. mountPath: /var/www/
  61. subPath: "root"
  62. - name: nextcloud-data
  63. mountPath: /var/www/html
  64. subPath: "html"
  65. - name: nextcloud-data
  66. mountPath: {{ .Values.nextcloud.datadir }}
  67. subPath: "data"
  68. - name: nextcloud-data
  69. mountPath: /var/www/html/config
  70. subPath: "config"
  71. - name: nextcloud-data
  72. mountPath: /var/www/html/custom_apps
  73. subPath: "custom_apps"
  74. - name: nextcloud-data
  75. mountPath: /var/www/tmp
  76. subPath: "tmp"
  77. - name: nextcloud-data
  78. mountPath: /var/www/html/themes
  79. subPath: "themes"
  80. {{ range $index, $hostPathConfiguration := .Values.extraAppVolumeMounts }}
  81. - name: extrappvolume-{{ $index }}
  82. mountPath: {{ $hostPathConfiguration.mountPath }}
  83. {{ end }}
  84. {{- if .Values.nextcloud.install_ffmpeg }}
  85. lifecycle:
  86. postStart:
  87. exec:
  88. command:
  89. - /bin/sh
  90. - -c
  91. - |
  92. echo "Installing ffmpeg..."
  93. apt update && \
  94. apt install -y --no-install-recommends \
  95. ffmpeg || echo "Failed to install ffmpeg"
  96. echo "Finished."
  97. {{- end }}
  98. {{ include "common.networking.dnsConfiguration" .Values | nindent 6 }}
  99. volumes:
  100. - name: nginx-configuration
  101. configMap:
  102. defaultMode: 0700
  103. name: "nginx-configuration"
  104. {{ include "nginx.tlsKeysVolume" . | nindent 8 }}
  105. {{ if .Values.appVolumeMounts }}
  106. {{ include "common.storage.configureAppVolumes" .Values | nindent 8 }}
  107. {{ end }}
  108. {{ range $index, $hostPathConfiguration := .Values.extraAppVolumeMounts }}
  109. - name: extrappvolume-{{ $index }}
  110. hostPath:
  111. path: {{ $hostPathConfiguration.hostPath }}
  112. {{ end }}
  113. # Will mount configuration files as www-data (id: 33) for nextcloud
  114. securityContext:
  115. fsGroup: 33