Prechádzať zdrojové kódy

Merge pull request #175 from truenas/NAS-111274

NAS-111274 / 22.02-RC.2 / Add HTTPS support for nextcloud
Waqar Ahmed 3 rokov pred
rodič
commit
c2db867cee
56 zmenil súbory, kde vykonal 426 pridanie a 74 odobranie
  1. 0 30
      charts/nextcloud/1.3.5/default_values.yaml
  2. 0 4
      charts/nextcloud/1.3.5/ix_values.yaml
  3. 0 0
      charts/nextcloud/1.3.5/values.yaml
  4. 0 0
      charts/nextcloud/1.3.6/.helmignore
  5. 0 0
      charts/nextcloud/1.3.6/Chart.lock
  6. 1 1
      charts/nextcloud/1.3.6/Chart.yaml
  7. 0 0
      charts/nextcloud/1.3.6/README.md
  8. 0 0
      charts/nextcloud/1.3.6/app-readme.md
  9. 0 0
      charts/nextcloud/1.3.6/charts/common-2105.0.0.tgz
  10. 9 0
      charts/nextcloud/1.3.6/ix_values.yaml
  11. 0 0
      charts/nextcloud/1.3.6/migrations/migrate_from_1.1.0
  12. 10 1
      charts/nextcloud/1.3.6/questions.yaml
  13. 0 0
      charts/nextcloud/1.3.6/templates/NOTES.txt
  14. 79 0
      charts/nextcloud/1.3.6/templates/_nginx.tpl
  15. 0 0
      charts/nextcloud/1.3.6/templates/_postgres.tpl
  16. 0 0
      charts/nextcloud/1.3.6/templates/backup-postgres-config.yaml
  17. 0 0
      charts/nextcloud/1.3.6/templates/backup-postgres-hook.yaml
  18. 30 1
      charts/nextcloud/1.3.6/templates/deployment.yaml
  19. 65 0
      charts/nextcloud/1.3.6/templates/nginx-configmap.yaml
  20. 10 0
      charts/nextcloud/1.3.6/templates/nginx-secret.yaml
  21. 0 0
      charts/nextcloud/1.3.6/templates/nuke-deployments-hook.yaml
  22. 0 0
      charts/nextcloud/1.3.6/templates/postgres-deployment.yaml
  23. 0 0
      charts/nextcloud/1.3.6/templates/postgres-secret.yaml
  24. 0 0
      charts/nextcloud/1.3.6/templates/postgres-service.yaml
  25. 0 0
      charts/nextcloud/1.3.6/templates/secrets.yaml
  26. 4 0
      charts/nextcloud/1.3.6/templates/service.yaml
  27. 0 0
      charts/nextcloud/1.3.6/templates/serviceaccount.yaml
  28. 5 0
      charts/nextcloud/1.3.6/test_values.yaml
  29. 0 30
      test/nextcloud/1.3.5/default_values.yaml
  30. 0 4
      test/nextcloud/1.3.5/ix_values.yaml
  31. 0 0
      test/nextcloud/1.3.5/values.yaml
  32. 0 0
      test/nextcloud/1.3.6/.helmignore
  33. 0 0
      test/nextcloud/1.3.6/Chart.lock
  34. 1 1
      test/nextcloud/1.3.6/Chart.yaml
  35. 0 0
      test/nextcloud/1.3.6/README.md
  36. 0 0
      test/nextcloud/1.3.6/app-readme.md
  37. 0 0
      test/nextcloud/1.3.6/charts/common-2105.0.0.tgz
  38. 9 0
      test/nextcloud/1.3.6/ix_values.yaml
  39. 0 0
      test/nextcloud/1.3.6/migrations/migrate_from_1.1.0
  40. 10 1
      test/nextcloud/1.3.6/questions.yaml
  41. 0 0
      test/nextcloud/1.3.6/templates/NOTES.txt
  42. 79 0
      test/nextcloud/1.3.6/templates/_nginx.tpl
  43. 0 0
      test/nextcloud/1.3.6/templates/_postgres.tpl
  44. 0 0
      test/nextcloud/1.3.6/templates/backup-postgres-config.yaml
  45. 0 0
      test/nextcloud/1.3.6/templates/backup-postgres-hook.yaml
  46. 30 1
      test/nextcloud/1.3.6/templates/deployment.yaml
  47. 65 0
      test/nextcloud/1.3.6/templates/nginx-configmap.yaml
  48. 10 0
      test/nextcloud/1.3.6/templates/nginx-secret.yaml
  49. 0 0
      test/nextcloud/1.3.6/templates/nuke-deployments-hook.yaml
  50. 0 0
      test/nextcloud/1.3.6/templates/postgres-deployment.yaml
  51. 0 0
      test/nextcloud/1.3.6/templates/postgres-secret.yaml
  52. 0 0
      test/nextcloud/1.3.6/templates/postgres-service.yaml
  53. 0 0
      test/nextcloud/1.3.6/templates/secrets.yaml
  54. 4 0
      test/nextcloud/1.3.6/templates/service.yaml
  55. 0 0
      test/nextcloud/1.3.6/templates/serviceaccount.yaml
  56. 5 0
      test/nextcloud/1.3.6/test_values.yaml

+ 0 - 30
charts/nextcloud/1.3.5/default_values.yaml

@@ -1,30 +0,0 @@
-## Official nextcloud image version
-## ref: https://hub.docker.com/r/library/nextcloud/tags/
-##
-image:
-  repository: nextcloud
-  tag: 19.0.3-apache
-  pullPolicy: IfNotPresent
-
-nextcloud:
-  host: nextcloud.kube.home
-  username: admin
-  password: changeme
-  datadir: /var/www/html/data
-  strategy: "Recreate"
-
-service:
-  nodePort: 9001
-
-appVolumeMounts:
-  nextcloud-data:
-    emptyDir: true
-    mountPath: "/var/www"
-
-postgresAppVolumeMounts:
-  postgres-data:
-    emptyDir: true
-    mountPath: "/var/lib/postgresql/data"
-  postgres-backup:
-    emptyDir: true
-    mountPath: "/postgres_backups"

+ 0 - 4
charts/nextcloud/1.3.5/ix_values.yaml

@@ -1,4 +0,0 @@
-image:
-  pullPolicy: IfNotPresent
-  repository: nextcloud
-  tag: '22.2'

+ 0 - 0
charts/nextcloud/1.3.5/values.yaml


+ 0 - 0
charts/nextcloud/1.3.5/.helmignore → charts/nextcloud/1.3.6/.helmignore


+ 0 - 0
charts/nextcloud/1.3.5/Chart.lock → charts/nextcloud/1.3.6/Chart.lock


+ 1 - 1
charts/nextcloud/1.3.5/Chart.yaml → charts/nextcloud/1.3.6/Chart.yaml

@@ -19,4 +19,4 @@ sources:
 - https://github.com/nextcloud/docker
 - https://github.com/nextcloud/helm
 upstream_version: 2.3.2
-version: 1.3.5
+version: 1.3.6

+ 0 - 0
charts/nextcloud/1.3.5/README.md → charts/nextcloud/1.3.6/README.md


+ 0 - 0
charts/nextcloud/1.3.5/app-readme.md → charts/nextcloud/1.3.6/app-readme.md


+ 0 - 0
charts/nextcloud/1.3.5/charts/common-2105.0.0.tgz → charts/nextcloud/1.3.6/charts/common-2105.0.0.tgz


+ 9 - 0
charts/nextcloud/1.3.6/ix_values.yaml

@@ -0,0 +1,9 @@
+image:
+  pullPolicy: IfNotPresent
+  repository: nextcloud
+  tag: '22.2'
+nginx:
+  image:
+    repository: nginx
+    tag: 1.21.3
+    pullPolicy: IfNotPresent

+ 0 - 0
charts/nextcloud/1.3.5/migrations/migrate_from_1.1.0 → charts/nextcloud/1.3.6/migrations/migrate_from_1.1.0


+ 10 - 1
test/nextcloud/1.3.5/questions.yaml → charts/nextcloud/1.3.6/questions.yaml

@@ -17,7 +17,7 @@ groups:
 portals:
   web_portal:
     protocols:
-      - "http"
+      - "$kubernetes-resource_configmap_nginx-configuration_protocol"
     host:
       - "$variable-nextcloud.host"
     ports:
@@ -52,6 +52,15 @@ questions:
                         type: string
                         required: true
 
+  - variable: certificate
+    description: "Configure Certificate for Nextcloud"
+    label: "Certificate Configuration"
+    group: "Nextcloud Configuration"
+    schema:
+      type: int
+      $ref:
+        - "definitions/certificate"
+
   - variable: nextcloud
     description: "Nextcloud configuration details"
     label: "Nextcloud Configuration"

+ 0 - 0
charts/nextcloud/1.3.5/templates/NOTES.txt → charts/nextcloud/1.3.6/templates/NOTES.txt


+ 79 - 0
charts/nextcloud/1.3.6/templates/_nginx.tpl

@@ -0,0 +1,79 @@
+{{/*
+Retrieve true/false if certificate is configured
+*/}}
+{{- define "nginx.certAvailable" -}}
+{{- if .Values.certificate -}}
+{{- $values := (. | mustDeepCopy) -}}
+{{- $_ := set $values "commonCertOptions" (dict "certKeyName" $values.Values.certificate) -}}
+{{- template "common.resources.cert_present" $values -}}
+{{- else -}}
+{{- false -}}
+{{- end -}}
+{{- end -}}
+
+
+{{/*
+Retrieve public key of certificate
+*/}}
+{{- define "nginx.cert.publicKey" -}}
+{{- $values := (. | mustDeepCopy) -}}
+{{- $_ := set $values "commonCertOptions" (dict "certKeyName" $values.Values.certificate "publicKey" true) -}}
+{{ include "common.resources.cert" $values }}
+{{- end -}}
+
+
+{{/*
+Retrieve private key of certificate
+*/}}
+{{- define "nginx.cert.privateKey" -}}
+{{- $values := (. | mustDeepCopy) -}}
+{{- $_ := set $values "commonCertOptions" (dict "certKeyName" $values.Values.certificate) -}}
+{{ include "common.resources.cert" $values }}
+{{- end -}}
+
+
+{{/*
+Retrieve configured protocol scheme for nextcloud
+*/}}
+{{- define "nginx.scheme" -}}
+{{- if eq (include "nginx.certAvailable" .) "true" -}}
+{{- print "https" -}}
+{{- else -}}
+{{- print "http" -}}
+{{- end -}}
+{{- end -}}
+
+
+{{/*
+Retrieve nginx certificate secret name
+*/}}
+{{- define "nginx.secretName" -}}
+{{- print "nginx-secret" -}}
+{{- end -}}
+
+
+{{/*
+Formats volumeMount for tls keys and trusted certs
+*/}}
+{{- define "nginx.tlsKeysVolumeMount" -}}
+{{- if eq (include "nginx.certAvailable" .) "true" -}}
+- name: cert-secret-volume
+  mountPath: "/etc/nginx-certs"
+{{- end -}}
+{{- end -}}
+
+{{/*
+Formats volume for tls keys and trusted certs
+*/}}
+{{- define "nginx.tlsKeysVolume" -}}
+{{- if eq (include "nginx.certAvailable" .) "true" -}}
+- name: cert-secret-volume
+  secret:
+    secretName: {{ include "nginx.secretName" . }}
+    items:
+    - key: certPublicKey
+      path: public.crt
+    - key: certPrivateKey
+      path: private.key
+{{- end -}}
+{{- end -}}

+ 0 - 0
charts/nextcloud/1.3.5/templates/_postgres.tpl → charts/nextcloud/1.3.6/templates/_postgres.tpl


+ 0 - 0
charts/nextcloud/1.3.5/templates/backup-postgres-config.yaml → charts/nextcloud/1.3.6/templates/backup-postgres-config.yaml


+ 0 - 0
charts/nextcloud/1.3.5/templates/backup-postgres-hook.yaml → charts/nextcloud/1.3.6/templates/backup-postgres-hook.yaml


+ 30 - 1
charts/nextcloud/1.3.5/templates/deployment.yaml → charts/nextcloud/1.3.6/templates/deployment.yaml

@@ -10,6 +10,22 @@ spec: {{ include "common.deployment.common_spec" . | nindent 2 }}
           command: ['sh', '-c', "until pg_isready -h {{ template "common.names.fullname" $postgres_values }}; do echo waiting for postgres; sleep 2; done"]
           imagePullPolicy: {{ .Values.image.pullPolicy }}
       containers:
+      {{ if eq (include "nginx.certAvailable" .) "true" }}
+      - name: nginx
+        {{ include "common.containers.imageConfig" .Values.nginx.image | nindent 8 }}
+        volumeMounts:
+          - name: nginx-configuration
+            mountPath: /etc/nginx/nginx.conf
+            subPath: nginx.conf
+          {{ include "nginx.tlsKeysVolumeMount" . | nindent 10 }}
+        ports:
+          - name: nginx-http
+            containerPort: 8000
+            protocol: TCP
+          - name: nginx-https
+            containerPort: 443
+            protocol: TCP
+      {{ end }}
       - name: {{ .Chart.Name }}
         {{ include "common.containers.imageConfig" .Values.image | nindent 8 }}
         env: {{ include "postgres.envVariableConfiguration" $postgres_values | nindent 10 }}
@@ -18,6 +34,11 @@ spec: {{ include "common.deployment.common_spec" . | nindent 2 }}
         {{ $envList = mustAppend $envList (dict "name" "POSTGRES_HOST" "value" (printf "%s:5432" (include "common.names.fullname" $postgres_values))) }}
         {{ $envList = mustAppend $envList (dict "name" "POSTGRES_DB" "value" (include "postgres.DatabaseName" .)) }}
         {{ $envList = mustAppend $envList (dict "name" "NEXTCLOUD_DATA_DIR" "value" .Values.nextcloud.datadir) }}
+        {{ if eq (include "nginx.certAvailable" .) "true" }}
+        {{ $envList = mustAppend $envList (dict "name" "APACHE_DISABLE_REWRITE_IP" "value" "1") }}
+        {{ $envList = mustAppend $envList (dict "name" "OVERWRITEHOST" "value" (printf "%v:%v" .Values.nextcloud.host .Values.service.nodePort)) }}
+        {{ $envList = mustAppend $envList (dict "name" "OVERWRITEPROTOCOL" "value" "https") }}
+        {{ end }}
         {{ $envList = mustAppend $envList (dict "name" "NEXTCLOUD_TRUSTED_DOMAINS" "value" .Values.nextcloud.host) }}
         {{ $envList = mustAppend $envList (dict "name" "NEXTCLOUD_ADMIN_USER" "valueFromSecret" true "secretName" $secretName "secretKey" "nextcloud-username") }}
         {{ $envList = mustAppend $envList (dict "name" "NEXTCLOUD_ADMIN_PASSWORD" "valueFromSecret" true "secretName" $secretName "secretKey" "nextcloud-password") }}
@@ -53,7 +74,15 @@ spec: {{ include "common.deployment.common_spec" . | nindent 2 }}
           mountPath: {{ $hostPathConfiguration.mountPath }}
         {{ end }}
 {{ include "common.networking.dnsConfiguration" .Values | nindent 6 }}
-{{ include "common.storage.allAppVolumes" .Values | nindent 6 }}
+      volumes:
+        - name: nginx-configuration
+          configMap:
+            defaultMode: 0700
+            name: "nginx-configuration"
+{{ include "nginx.tlsKeysVolume" . | nindent 8 }}
+{{ if .Values.appVolumeMounts }}
+{{ include "common.storage.configureAppVolumes" .Values | nindent 8 }}
+{{ end }}
       {{ range $index, $hostPathConfiguration := .Values.extraAppVolumeMounts }}
         - name: extrappvolume-{{ $index }}
           hostPath:

+ 65 - 0
charts/nextcloud/1.3.6/templates/nginx-configmap.yaml

@@ -0,0 +1,65 @@
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: "nginx-configuration"
+data:
+  protocol: {{ include "nginx.scheme" . }}
+  nginx.conf: |-
+    events {}
+    http {
+      # redirects all http requests to https requests
+      server {
+        listen 8000 default_server;
+        listen [::]:8000 default_server;
+        return 301 https://$host$request_uri;
+      }
+
+      server {
+        server_name localhost;
+
+        listen 443 ssl http2;
+        listen [::]:433 ssl http2;
+
+        ssl_certificate '/etc/nginx-certs/public.crt';
+        ssl_certificate_key '/etc/nginx-certs/private.key';
+
+        # maximum 3GB Upload File; change to fit your needs
+        client_max_body_size 3G;
+
+        location = /robots.txt {
+          allow all;
+          log_not_found off;
+          access_log off;
+        }
+
+        location = /.well-known/carddav {
+          return 301 $scheme://$host/remote.php/dav;
+        }
+
+        location = /.well-known/caldav {
+          return 301 $scheme://$host/remote.php/dav;
+        }
+
+        location / {
+          proxy_pass http://localhost;
+          proxy_http_version                 1.1;
+          proxy_cache_bypass                 $http_upgrade;
+          proxy_request_buffering            off;
+
+          # Proxy headers
+          proxy_set_header Upgrade           $http_upgrade;
+          proxy_set_header Connection        "upgrade";
+          proxy_set_header Host              $http_host;
+          proxy_set_header X-Real-IP         $remote_addr;
+          proxy_set_header X-Forwarded-For   $proxy_add_x_forwarded_for;
+          proxy_set_header X-Forwarded-Proto https;
+          proxy_set_header X-Forwarded-Host  $host;
+          proxy_set_header X-Forwarded-Port  $server_port;
+
+          # Proxy timeouts
+          proxy_connect_timeout              60s;
+          proxy_send_timeout                 60s;
+          proxy_read_timeout                 60s;
+        }
+      }
+    }

+ 10 - 0
charts/nextcloud/1.3.6/templates/nginx-secret.yaml

@@ -0,0 +1,10 @@
+apiVersion: v1
+kind: Secret
+metadata:
+  name: {{ include "nginx.secretName" . }}
+type: Opaque
+data:
+  {{ if eq (include "nginx.certAvailable" .) "true" }}
+  certPublicKey: {{ (include "nginx.cert.publicKey" .) | toString | b64enc | quote }}
+  certPrivateKey: {{ (include "nginx.cert.privateKey" .) | toString | b64enc | quote }}
+  {{ end }}

+ 0 - 0
charts/nextcloud/1.3.5/templates/nuke-deployments-hook.yaml → charts/nextcloud/1.3.6/templates/nuke-deployments-hook.yaml


+ 0 - 0
charts/nextcloud/1.3.5/templates/postgres-deployment.yaml → charts/nextcloud/1.3.6/templates/postgres-deployment.yaml


+ 0 - 0
charts/nextcloud/1.3.5/templates/postgres-secret.yaml → charts/nextcloud/1.3.6/templates/postgres-secret.yaml


+ 0 - 0
charts/nextcloud/1.3.5/templates/postgres-service.yaml → charts/nextcloud/1.3.6/templates/postgres-service.yaml


+ 0 - 0
charts/nextcloud/1.3.5/templates/secrets.yaml → charts/nextcloud/1.3.6/templates/secrets.yaml


+ 4 - 0
charts/nextcloud/1.3.5/templates/service.yaml → charts/nextcloud/1.3.6/templates/service.yaml

@@ -1,6 +1,10 @@
 {{ $svc := .Values.service }}
 {{ $ports := list }}
+{{ if eq (include "nginx.certAvailable" .) "true" }}
+{{ $ports = mustAppend $ports (dict "name" "nginx-https" "targetPort" 443 "port" 443 "nodePort" $svc.nodePort) }}
+{{ else }}
 {{ $ports = mustAppend $ports (dict "name" "http" "port" 80 "nodePort" $svc.nodePort) }}
+{{ end }}
 {{ $params := . }}
 {{ $_ := set $params "commonService" (dict "type" "NodePort" "ports" $ports ) }}
 {{ include "common.classes.service" $params }}

+ 0 - 0
charts/nextcloud/1.3.5/templates/serviceaccount.yaml → charts/nextcloud/1.3.6/templates/serviceaccount.yaml


+ 5 - 0
charts/nextcloud/1.3.5/test_values.yaml → charts/nextcloud/1.3.6/test_values.yaml

@@ -10,6 +10,11 @@ image:
   pullPolicy: IfNotPresent
   repository: nextcloud
   tag: '22.2'
+nginx:
+  image:
+    repository: nginx
+    tag: 1.21.3
+    pullPolicy: IfNotPresent
 ixChartContext: {}
 nextcloud:
   datadir: /var/www/html/data

+ 0 - 30
test/nextcloud/1.3.5/default_values.yaml

@@ -1,30 +0,0 @@
-## Official nextcloud image version
-## ref: https://hub.docker.com/r/library/nextcloud/tags/
-##
-image:
-  repository: nextcloud
-  tag: 19.0.3-apache
-  pullPolicy: IfNotPresent
-
-nextcloud:
-  host: nextcloud.kube.home
-  username: admin
-  password: changeme
-  datadir: /var/www/html/data
-  strategy: "Recreate"
-
-service:
-  nodePort: 9001
-
-appVolumeMounts:
-  nextcloud-data:
-    emptyDir: true
-    mountPath: "/var/www"
-
-postgresAppVolumeMounts:
-  postgres-data:
-    emptyDir: true
-    mountPath: "/var/lib/postgresql/data"
-  postgres-backup:
-    emptyDir: true
-    mountPath: "/postgres_backups"

+ 0 - 4
test/nextcloud/1.3.5/ix_values.yaml

@@ -1,4 +0,0 @@
-image:
-  pullPolicy: IfNotPresent
-  repository: nextcloud
-  tag: '22.2'

+ 0 - 0
test/nextcloud/1.3.5/values.yaml


+ 0 - 0
test/nextcloud/1.3.5/.helmignore → test/nextcloud/1.3.6/.helmignore


+ 0 - 0
test/nextcloud/1.3.5/Chart.lock → test/nextcloud/1.3.6/Chart.lock


+ 1 - 1
test/nextcloud/1.3.5/Chart.yaml → test/nextcloud/1.3.6/Chart.yaml

@@ -19,4 +19,4 @@ sources:
 - https://github.com/nextcloud/docker
 - https://github.com/nextcloud/helm
 upstream_version: 2.3.2
-version: 1.3.5
+version: 1.3.6

+ 0 - 0
test/nextcloud/1.3.5/README.md → test/nextcloud/1.3.6/README.md


+ 0 - 0
test/nextcloud/1.3.5/app-readme.md → test/nextcloud/1.3.6/app-readme.md


+ 0 - 0
test/nextcloud/1.3.5/charts/common-2105.0.0.tgz → test/nextcloud/1.3.6/charts/common-2105.0.0.tgz


+ 9 - 0
test/nextcloud/1.3.6/ix_values.yaml

@@ -0,0 +1,9 @@
+image:
+  pullPolicy: IfNotPresent
+  repository: nextcloud
+  tag: '22.2'
+nginx:
+  image:
+    repository: nginx
+    tag: 1.21.3
+    pullPolicy: IfNotPresent

+ 0 - 0
test/nextcloud/1.3.5/migrations/migrate_from_1.1.0 → test/nextcloud/1.3.6/migrations/migrate_from_1.1.0


+ 10 - 1
charts/nextcloud/1.3.5/questions.yaml → test/nextcloud/1.3.6/questions.yaml

@@ -17,7 +17,7 @@ groups:
 portals:
   web_portal:
     protocols:
-      - "http"
+      - "$kubernetes-resource_configmap_nginx-configuration_protocol"
     host:
       - "$variable-nextcloud.host"
     ports:
@@ -52,6 +52,15 @@ questions:
                         type: string
                         required: true
 
+  - variable: certificate
+    description: "Configure Certificate for Nextcloud"
+    label: "Certificate Configuration"
+    group: "Nextcloud Configuration"
+    schema:
+      type: int
+      $ref:
+        - "definitions/certificate"
+
   - variable: nextcloud
     description: "Nextcloud configuration details"
     label: "Nextcloud Configuration"

+ 0 - 0
test/nextcloud/1.3.5/templates/NOTES.txt → test/nextcloud/1.3.6/templates/NOTES.txt


+ 79 - 0
test/nextcloud/1.3.6/templates/_nginx.tpl

@@ -0,0 +1,79 @@
+{{/*
+Retrieve true/false if certificate is configured
+*/}}
+{{- define "nginx.certAvailable" -}}
+{{- if .Values.certificate -}}
+{{- $values := (. | mustDeepCopy) -}}
+{{- $_ := set $values "commonCertOptions" (dict "certKeyName" $values.Values.certificate) -}}
+{{- template "common.resources.cert_present" $values -}}
+{{- else -}}
+{{- false -}}
+{{- end -}}
+{{- end -}}
+
+
+{{/*
+Retrieve public key of certificate
+*/}}
+{{- define "nginx.cert.publicKey" -}}
+{{- $values := (. | mustDeepCopy) -}}
+{{- $_ := set $values "commonCertOptions" (dict "certKeyName" $values.Values.certificate "publicKey" true) -}}
+{{ include "common.resources.cert" $values }}
+{{- end -}}
+
+
+{{/*
+Retrieve private key of certificate
+*/}}
+{{- define "nginx.cert.privateKey" -}}
+{{- $values := (. | mustDeepCopy) -}}
+{{- $_ := set $values "commonCertOptions" (dict "certKeyName" $values.Values.certificate) -}}
+{{ include "common.resources.cert" $values }}
+{{- end -}}
+
+
+{{/*
+Retrieve configured protocol scheme for nextcloud
+*/}}
+{{- define "nginx.scheme" -}}
+{{- if eq (include "nginx.certAvailable" .) "true" -}}
+{{- print "https" -}}
+{{- else -}}
+{{- print "http" -}}
+{{- end -}}
+{{- end -}}
+
+
+{{/*
+Retrieve nginx certificate secret name
+*/}}
+{{- define "nginx.secretName" -}}
+{{- print "nginx-secret" -}}
+{{- end -}}
+
+
+{{/*
+Formats volumeMount for tls keys and trusted certs
+*/}}
+{{- define "nginx.tlsKeysVolumeMount" -}}
+{{- if eq (include "nginx.certAvailable" .) "true" -}}
+- name: cert-secret-volume
+  mountPath: "/etc/nginx-certs"
+{{- end -}}
+{{- end -}}
+
+{{/*
+Formats volume for tls keys and trusted certs
+*/}}
+{{- define "nginx.tlsKeysVolume" -}}
+{{- if eq (include "nginx.certAvailable" .) "true" -}}
+- name: cert-secret-volume
+  secret:
+    secretName: {{ include "nginx.secretName" . }}
+    items:
+    - key: certPublicKey
+      path: public.crt
+    - key: certPrivateKey
+      path: private.key
+{{- end -}}
+{{- end -}}

+ 0 - 0
test/nextcloud/1.3.5/templates/_postgres.tpl → test/nextcloud/1.3.6/templates/_postgres.tpl


+ 0 - 0
test/nextcloud/1.3.5/templates/backup-postgres-config.yaml → test/nextcloud/1.3.6/templates/backup-postgres-config.yaml


+ 0 - 0
test/nextcloud/1.3.5/templates/backup-postgres-hook.yaml → test/nextcloud/1.3.6/templates/backup-postgres-hook.yaml


+ 30 - 1
test/nextcloud/1.3.5/templates/deployment.yaml → test/nextcloud/1.3.6/templates/deployment.yaml

@@ -10,6 +10,22 @@ spec: {{ include "common.deployment.common_spec" . | nindent 2 }}
           command: ['sh', '-c', "until pg_isready -h {{ template "common.names.fullname" $postgres_values }}; do echo waiting for postgres; sleep 2; done"]
           imagePullPolicy: {{ .Values.image.pullPolicy }}
       containers:
+      {{ if eq (include "nginx.certAvailable" .) "true" }}
+      - name: nginx
+        {{ include "common.containers.imageConfig" .Values.nginx.image | nindent 8 }}
+        volumeMounts:
+          - name: nginx-configuration
+            mountPath: /etc/nginx/nginx.conf
+            subPath: nginx.conf
+          {{ include "nginx.tlsKeysVolumeMount" . | nindent 10 }}
+        ports:
+          - name: nginx-http
+            containerPort: 8000
+            protocol: TCP
+          - name: nginx-https
+            containerPort: 443
+            protocol: TCP
+      {{ end }}
       - name: {{ .Chart.Name }}
         {{ include "common.containers.imageConfig" .Values.image | nindent 8 }}
         env: {{ include "postgres.envVariableConfiguration" $postgres_values | nindent 10 }}
@@ -18,6 +34,11 @@ spec: {{ include "common.deployment.common_spec" . | nindent 2 }}
         {{ $envList = mustAppend $envList (dict "name" "POSTGRES_HOST" "value" (printf "%s:5432" (include "common.names.fullname" $postgres_values))) }}
         {{ $envList = mustAppend $envList (dict "name" "POSTGRES_DB" "value" (include "postgres.DatabaseName" .)) }}
         {{ $envList = mustAppend $envList (dict "name" "NEXTCLOUD_DATA_DIR" "value" .Values.nextcloud.datadir) }}
+        {{ if eq (include "nginx.certAvailable" .) "true" }}
+        {{ $envList = mustAppend $envList (dict "name" "APACHE_DISABLE_REWRITE_IP" "value" "1") }}
+        {{ $envList = mustAppend $envList (dict "name" "OVERWRITEHOST" "value" (printf "%v:%v" .Values.nextcloud.host .Values.service.nodePort)) }}
+        {{ $envList = mustAppend $envList (dict "name" "OVERWRITEPROTOCOL" "value" "https") }}
+        {{ end }}
         {{ $envList = mustAppend $envList (dict "name" "NEXTCLOUD_TRUSTED_DOMAINS" "value" .Values.nextcloud.host) }}
         {{ $envList = mustAppend $envList (dict "name" "NEXTCLOUD_ADMIN_USER" "valueFromSecret" true "secretName" $secretName "secretKey" "nextcloud-username") }}
         {{ $envList = mustAppend $envList (dict "name" "NEXTCLOUD_ADMIN_PASSWORD" "valueFromSecret" true "secretName" $secretName "secretKey" "nextcloud-password") }}
@@ -53,7 +74,15 @@ spec: {{ include "common.deployment.common_spec" . | nindent 2 }}
           mountPath: {{ $hostPathConfiguration.mountPath }}
         {{ end }}
 {{ include "common.networking.dnsConfiguration" .Values | nindent 6 }}
-{{ include "common.storage.allAppVolumes" .Values | nindent 6 }}
+      volumes:
+        - name: nginx-configuration
+          configMap:
+            defaultMode: 0700
+            name: "nginx-configuration"
+{{ include "nginx.tlsKeysVolume" . | nindent 8 }}
+{{ if .Values.appVolumeMounts }}
+{{ include "common.storage.configureAppVolumes" .Values | nindent 8 }}
+{{ end }}
       {{ range $index, $hostPathConfiguration := .Values.extraAppVolumeMounts }}
         - name: extrappvolume-{{ $index }}
           hostPath:

+ 65 - 0
test/nextcloud/1.3.6/templates/nginx-configmap.yaml

@@ -0,0 +1,65 @@
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: "nginx-configuration"
+data:
+  protocol: {{ include "nginx.scheme" . }}
+  nginx.conf: |-
+    events {}
+    http {
+      # redirects all http requests to https requests
+      server {
+        listen 8000 default_server;
+        listen [::]:8000 default_server;
+        return 301 https://$host$request_uri;
+      }
+
+      server {
+        server_name localhost;
+
+        listen 443 ssl http2;
+        listen [::]:433 ssl http2;
+
+        ssl_certificate '/etc/nginx-certs/public.crt';
+        ssl_certificate_key '/etc/nginx-certs/private.key';
+
+        # maximum 3GB Upload File; change to fit your needs
+        client_max_body_size 3G;
+
+        location = /robots.txt {
+          allow all;
+          log_not_found off;
+          access_log off;
+        }
+
+        location = /.well-known/carddav {
+          return 301 $scheme://$host/remote.php/dav;
+        }
+
+        location = /.well-known/caldav {
+          return 301 $scheme://$host/remote.php/dav;
+        }
+
+        location / {
+          proxy_pass http://localhost;
+          proxy_http_version                 1.1;
+          proxy_cache_bypass                 $http_upgrade;
+          proxy_request_buffering            off;
+
+          # Proxy headers
+          proxy_set_header Upgrade           $http_upgrade;
+          proxy_set_header Connection        "upgrade";
+          proxy_set_header Host              $http_host;
+          proxy_set_header X-Real-IP         $remote_addr;
+          proxy_set_header X-Forwarded-For   $proxy_add_x_forwarded_for;
+          proxy_set_header X-Forwarded-Proto https;
+          proxy_set_header X-Forwarded-Host  $host;
+          proxy_set_header X-Forwarded-Port  $server_port;
+
+          # Proxy timeouts
+          proxy_connect_timeout              60s;
+          proxy_send_timeout                 60s;
+          proxy_read_timeout                 60s;
+        }
+      }
+    }

+ 10 - 0
test/nextcloud/1.3.6/templates/nginx-secret.yaml

@@ -0,0 +1,10 @@
+apiVersion: v1
+kind: Secret
+metadata:
+  name: {{ include "nginx.secretName" . }}
+type: Opaque
+data:
+  {{ if eq (include "nginx.certAvailable" .) "true" }}
+  certPublicKey: {{ (include "nginx.cert.publicKey" .) | toString | b64enc | quote }}
+  certPrivateKey: {{ (include "nginx.cert.privateKey" .) | toString | b64enc | quote }}
+  {{ end }}

+ 0 - 0
test/nextcloud/1.3.5/templates/nuke-deployments-hook.yaml → test/nextcloud/1.3.6/templates/nuke-deployments-hook.yaml


+ 0 - 0
test/nextcloud/1.3.5/templates/postgres-deployment.yaml → test/nextcloud/1.3.6/templates/postgres-deployment.yaml


+ 0 - 0
test/nextcloud/1.3.5/templates/postgres-secret.yaml → test/nextcloud/1.3.6/templates/postgres-secret.yaml


+ 0 - 0
test/nextcloud/1.3.5/templates/postgres-service.yaml → test/nextcloud/1.3.6/templates/postgres-service.yaml


+ 0 - 0
test/nextcloud/1.3.5/templates/secrets.yaml → test/nextcloud/1.3.6/templates/secrets.yaml


+ 4 - 0
test/nextcloud/1.3.5/templates/service.yaml → test/nextcloud/1.3.6/templates/service.yaml

@@ -1,6 +1,10 @@
 {{ $svc := .Values.service }}
 {{ $ports := list }}
+{{ if eq (include "nginx.certAvailable" .) "true" }}
+{{ $ports = mustAppend $ports (dict "name" "nginx-https" "targetPort" 443 "port" 443 "nodePort" $svc.nodePort) }}
+{{ else }}
 {{ $ports = mustAppend $ports (dict "name" "http" "port" 80 "nodePort" $svc.nodePort) }}
+{{ end }}
 {{ $params := . }}
 {{ $_ := set $params "commonService" (dict "type" "NodePort" "ports" $ports ) }}
 {{ include "common.classes.service" $params }}

+ 0 - 0
test/nextcloud/1.3.5/templates/serviceaccount.yaml → test/nextcloud/1.3.6/templates/serviceaccount.yaml


+ 5 - 0
test/nextcloud/1.3.5/test_values.yaml → test/nextcloud/1.3.6/test_values.yaml

@@ -10,6 +10,11 @@ image:
   pullPolicy: IfNotPresent
   repository: nextcloud
   tag: '22.2'
+nginx:
+  image:
+    repository: nginx
+    tag: 1.21.3
+    pullPolicy: IfNotPresent
 ixChartContext: {}
 nextcloud:
   datadir: /var/www/html/data