deployment.yaml 4.8 KB

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