deployment.yaml 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 -h {{ template "common.names.fullname" $postgres_values }}; do echo waiting for postgres; sleep 2; done"]
  12. imagePullPolicy: {{ .Values.image.pullPolicy }}
  13. containers:
  14. {{ if eq (include "nginx.certAvailable" .) "true" }}
  15. - name: nginx
  16. {{ include "common.containers.imageConfig" .Values.nginx.image | nindent 8 }}
  17. volumeMounts:
  18. - name: nginx-configuration
  19. mountPath: /etc/nginx/nginx.conf
  20. subPath: nginx.conf
  21. {{ include "nginx.tlsKeysVolumeMount" . | nindent 10 }}
  22. ports:
  23. - name: nginx-http
  24. containerPort: 8000
  25. protocol: TCP
  26. - name: nginx-https
  27. containerPort: 443
  28. protocol: TCP
  29. {{ end }}
  30. - name: {{ .Chart.Name }}
  31. {{ include "common.resources.limitation" . | nindent 8 }}
  32. {{ include "common.containers.imageConfig" .Values.image | nindent 8 }}
  33. env: {{ include "postgres.envVariableConfiguration" $postgres_values | nindent 10 }}
  34. {{ $envList := list }}
  35. {{ $secretName := (include "common.names.fullname" .) }}
  36. {{ $envList = mustAppend $envList (dict "name" "POSTGRES_HOST" "value" (printf "%s:5432" (include "common.names.fullname" $postgres_values))) }}
  37. {{ $envList = mustAppend $envList (dict "name" "POSTGRES_DB" "value" (include "postgres.DatabaseName" .)) }}
  38. {{ $envList = mustAppend $envList (dict "name" "NEXTCLOUD_DATA_DIR" "value" .Values.nextcloud.datadir) }}
  39. {{ if eq (include "nginx.certAvailable" .) "true" }}
  40. {{ $envList = mustAppend $envList (dict "name" "APACHE_DISABLE_REWRITE_IP" "value" "1") }}
  41. {{ $envList = mustAppend $envList (dict "name" "OVERWRITEHOST" "value" (printf "%v:%v" .Values.nextcloud.host .Values.service.nodePort)) }}
  42. {{ $envList = mustAppend $envList (dict "name" "OVERWRITEPROTOCOL" "value" "https") }}
  43. {{ $envList = mustAppend $envList (dict "name" "TRUSTED_PROXIES" "value" "127.0.0.1") }}
  44. {{ end }}
  45. {{ $hostName := .Values.nextcloud.host }}
  46. {{ if .Values.useServiceNameForHost }}
  47. {{ $hostName = (include "common.names.fullname" .) }}
  48. {{ end }}
  49. {{ $envList = mustAppend $envList (dict "name" "NEXTCLOUD_TRUSTED_DOMAINS" "value" $hostName) }}
  50. {{ $envList = mustAppend $envList (dict "name" "NEXTCLOUD_ADMIN_USER" "valueFromSecret" true "secretName" $secretName "secretKey" "nextcloud-username") }}
  51. {{ $envList = mustAppend $envList (dict "name" "NEXTCLOUD_ADMIN_PASSWORD" "valueFromSecret" true "secretName" $secretName "secretKey" "nextcloud-password") }}
  52. {{ include "common.containers.environmentVariables" (dict "environmentVariables" $envList) | nindent 10 }}
  53. ports:
  54. - name: http
  55. containerPort: 80
  56. protocol: TCP
  57. volumeMounts:
  58. - name: nextcloud-data
  59. mountPath: /var/www/
  60. subPath: "root"
  61. - name: nextcloud-data
  62. mountPath: /var/www/html
  63. subPath: "html"
  64. - name: nextcloud-data
  65. mountPath: {{ .Values.nextcloud.datadir }}
  66. subPath: "data"
  67. - name: nextcloud-data
  68. mountPath: /var/www/html/config
  69. subPath: "config"
  70. - name: nextcloud-data
  71. mountPath: /var/www/html/custom_apps
  72. subPath: "custom_apps"
  73. - name: nextcloud-data
  74. mountPath: /var/www/tmp
  75. subPath: "tmp"
  76. - name: nextcloud-data
  77. mountPath: /var/www/html/themes
  78. subPath: "themes"
  79. {{ range $index, $hostPathConfiguration := .Values.extraAppVolumeMounts }}
  80. - name: extrappvolume-{{ $index }}
  81. mountPath: {{ $hostPathConfiguration.mountPath }}
  82. {{ end }}
  83. {{ include "common.networking.dnsConfiguration" .Values | nindent 6 }}
  84. volumes:
  85. - name: nginx-configuration
  86. configMap:
  87. defaultMode: 0700
  88. name: "nginx-configuration"
  89. {{ include "nginx.tlsKeysVolume" . | nindent 8 }}
  90. {{ if .Values.appVolumeMounts }}
  91. {{ include "common.storage.configureAppVolumes" .Values | nindent 8 }}
  92. {{ end }}
  93. {{ range $index, $hostPathConfiguration := .Values.extraAppVolumeMounts }}
  94. - name: extrappvolume-{{ $index }}
  95. hostPath:
  96. path: {{ $hostPathConfiguration.hostPath }}
  97. {{ end }}
  98. # Will mount configuration files as www-data (id: 33) for nextcloud
  99. securityContext:
  100. fsGroup: 33