diff --git a/charts/nextcloud/Chart.yaml b/charts/nextcloud/Chart.yaml index 991b1e46..fb6b6871 100644 --- a/charts/nextcloud/Chart.yaml +++ b/charts/nextcloud/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v2 name: nextcloud -version: 4.4.0 +version: 4.4.1 appVersion: 27.1.3 description: A file sharing server that puts the control and security of your own data back into your hands. keywords: diff --git a/charts/nextcloud/README.md b/charts/nextcloud/README.md index 4dfdb9cc..965a5f5e 100644 --- a/charts/nextcloud/README.md +++ b/charts/nextcloud/README.md @@ -20,6 +20,7 @@ helm install my-release nextcloud/nextcloud * [Persistence Configurations](#persistence-configurations) * [Metrics Configurations](#metrics-configurations) * [Cron jobs](#cron-jobs) +* [Using the nextcloud docker image auto-configuration via env vars](#using-the-nextcloud-docker-image-auto-configuration-via-env-vars) * [Multiple config.php file](#multiple-configphp-file) * [Using nginx](#using-nginx) * [Preserving Source IP](#preserving-source-ip) @@ -31,6 +32,7 @@ helm install my-release nextcloud/nextcloud * [Backups](#backups) * [Upgrades](#upgrades) + ## Introduction This chart bootstraps an [nextcloud](https://hub.docker.com/_/nextcloud/) deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager. @@ -128,6 +130,7 @@ The following table lists the configurable parameters of the nextcloud chart and | `nextcloud.defaultConfigs.apps\.config\.php` | Default configuration for apps | `true` | | `nextcloud.defaultConfigs.autoconfig\.php` | Default auto-configuration for databases | `true` | | `nextcloud.defaultConfigs.smtp\.config\.php` | Default configuration for smtp | `true` | +| `nextcloud.defaultConfigs.s3\.config\.php` | Default configuration for S3 as primary Object Storage | `true` | | `nextcloud.strategy` | specifies the strategy used to replace old Pods by new ones | `type: Recreate` | | `nextcloud.extraEnv` | specify additional environment variables | `{}` | | `nextcloud.extraSidecarContainers` | specify additional sidecar containers | `[]` | @@ -337,31 +340,88 @@ To execute [background tasks](https://docs.nextcloud.com/server/latest/admin_man Enabling this option will create a sidecar container in the Nextcloud pod, which will start a [`crond` daemon](https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/background_jobs_configuration.html#cron) responsible for running the Nextcloud cron.php script. At first launch, the background jobs mode in your Nextcloud basic settings will automatically be set to ***Cron***. + +## Using the nextcloud docker image auto-configuration via env vars + +The [nextcloud/docker](https://github.com/nextcloud/docker/tree/master) image provides an auto-configuration via environment variables. See [their docs](https://github.com/nextcloud/docker/tree/master#auto-configuration-via-environment-variables) for more info. + +For example, if you want to enable S3 as your primary object storage, you can set the following environment variables: + +```yaml +# To use an external S3 compatible object store as primary storage, set the following variables: + +nextcloud: + extraEnv: + - name: "OBJECTSTORE_S3_HOST" + valueFrom: + secretKeyRef: + name: my-existing-kubernetes-secret + key: S3_HOSTNAME + + - name: "OBJECTSTORE_S3_BUCKET" + valueFrom: + secretKeyRef: + name: my-existing-kubernetes-secret + key: S3_BUCKET + + - name: "OBJECTSTORE_S3_KEY" + valueFrom: + secretKeyRef: + name: my-existing-kubernetes-secret + key: S3_USER + + - name: "OBJECTSTORE_S3_SECRET" + valueFrom: + secretKeyRef: + name: my-existing-kubernetes-secret + key: S3_PASSWORD + + - name: "OBJECTSTORE_S3_PORT" + value: "443" + + - name: "OBJECTSTORE_S3_SSL" + value: "true" + + - name: "OBJECTSTORE_S3_REGION" + value: "eu-west-1" + + - name: "OBJECTSTORE_S3_USEPATH_STYLE" + value: "true" + + - name: "OBJECTSTORE_S3_SSE_C_KEY" + valueFrom: + secretKeyRef: + name: my-existing-kubernetes-secret + key: S3_ENCRYPTION_KEY +``` + ## Multiple config.php file Nextcloud supports loading configuration parameters from multiple files. You can add arbitrary files ending with `.config.php` in the `config/` directory. -See [documentation](https://docs.nextcloud.com/server/15/admin_manual/configuration_server/config_sample_php_parameters.html#multiple-config-php-file). +See [documentation](https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/config_sample_php_parameters.html#multiple-config-php-file). For example, to enable image and document previews: -For example, following config will configure Nextcloud with [S3 as primary storage](https://docs.nextcloud.com/server/13/admin_manual/configuration_files/primary_storage.html#simple-storage-service-s3) by creating file `/var/www/html/config/s3.config.php`: ```yaml nextcloud: configs: - s3.config.php: |- + previews.config.php: |- array( - 'class' => '\\OC\\Files\\ObjectStore\\S3', - 'arguments' => array( - 'bucket' => 'my-bucket', - 'autocreate' => true, - 'key' => 'xxx', - 'secret' => 'xxx', - 'region' => 'us-east-1', - 'use_ssl' => true - ) - ) + 'enable_previews' => true, + 'enabledPreviewProviders' => array ( + 'OC\Preview\Movie', + 'OC\Preview\PNG', + 'OC\Preview\JPEG', + 'OC\Preview\GIF', + 'OC\Preview\BMP', + 'OC\Preview\XBitmap', + 'OC\Preview\MP3', + 'OC\Preview\MP4', + 'OC\Preview\TXT', + 'OC\Preview\MarkDown', + 'OC\Preview\PDF' + ), ); ``` diff --git a/charts/nextcloud/templates/config.yaml b/charts/nextcloud/templates/config.yaml index 2e811f16..181e7a27 100644 --- a/charts/nextcloud/templates/config.yaml +++ b/charts/nextcloud/templates/config.yaml @@ -123,5 +123,55 @@ data: ); } {{- end }} +{{- if index .Values.nextcloud.defaultConfigs "smtp.config.php" }} + s3.config.php: |- + array( + 'class' => '\OC\Files\ObjectStore\S3', + 'arguments' => array( + 'bucket' => getenv('OBJECTSTORE_S3_BUCKET'), + 'region' => getenv('OBJECTSTORE_S3_REGION') ?: '', + 'hostname' => getenv('OBJECTSTORE_S3_HOST') ?: '', + 'port' => getenv('OBJECTSTORE_S3_PORT') ?: '', + 'objectPrefix' => getenv("OBJECTSTORE_S3_OBJECT_PREFIX") ? getenv("OBJECTSTORE_S3_OBJECT_PREFIX") : "urn:oid:", + 'autocreate' => (strtolower($autocreate) === 'false' || $autocreate == false) ? false : true, + 'use_ssl' => (strtolower($use_ssl) === 'false' || $use_ssl == false) ? false : true, + // required for some non Amazon S3 implementations + 'use_path_style' => $use_path == true && strtolower($use_path) !== 'false', + // required for older protocol versions + 'legacy_auth' => $use_legacyauth == true && strtolower($use_legacyauth) !== 'false' + ) + ) + ); + + if (getenv('OBJECTSTORE_S3_SSE_C_KEY_FILE') && file_exists(getenv('OBJECTSTORE_S3_SSE_C_KEY_FILE'))) { + $CONFIG['objectstore']['arguments']['sse_c_key'] = trim(file_get_contents(getenv('OBJECTSTORE_S3_SSE_C_KEY_FILE')); + } elseif (getenv('OBJECTSTORE_S3_SSE_C_KEY')) { + $CONFIG['objectstore']['arguments']['sse_c_key'] = getenv('OBJECTSTORE_S3_SSE_C_KEY'); + } + + if (getenv('OBJECTSTORE_S3_KEY_FILE') && file_exists(getenv('OBJECTSTORE_S3_KEY_FILE'))) { + $CONFIG['objectstore']['arguments']['key'] = trim(file_get_contents(getenv('OBJECTSTORE_S3_KEY_FILE'))); + } elseif (getenv('OBJECTSTORE_S3_KEY')) { + $CONFIG['objectstore']['arguments']['key'] = getenv('OBJECTSTORE_S3_KEY'); + } else { + $CONFIG['objectstore']['arguments']['key'] = ''; + } + + if (getenv('OBJECTSTORE_S3_SECRET_FILE') && file_exists(getenv('OBJECTSTORE_S3_SECRET_FILE'))) { + $CONFIG['objectstore']['arguments']['secret'] = trim(file_get_contents(getenv('OBJECTSTORE_S3_SECRET_FILE'))); + } elseif (getenv('OBJECTSTORE_S3_SECRET')) { + $CONFIG['objectstore']['arguments']['secret'] = getenv('OBJECTSTORE_S3_SECRET'); + } else { + $CONFIG['objectstore']['arguments']['secret'] = ''; + } + } +{{- end }} {{- end }} {{- end }} diff --git a/charts/nextcloud/values.yaml b/charts/nextcloud/values.yaml index 4d4d93c4..415068fe 100644 --- a/charts/nextcloud/values.yaml +++ b/charts/nextcloud/values.yaml @@ -104,9 +104,10 @@ nextcloud: # PHP Configuration files # Will be injected in /usr/local/etc/php/conf.d for apache image and in /usr/local/etc/php-fpm.d when nginx.enabled: true phpConfigs: {} - # Default config files + # Default config files that utilize environment variables: + # see: https://github.com/nextcloud/docker/tree/master#auto-configuration-via-environment-variables # IMPORTANT: Will be used only if you put extra configs, otherwise default will come from nextcloud itself - # Default confgurations can be found here: https://github.com/nextcloud/docker/tree/master/16.0/apache/config + # Default confgurations can be found here: https://github.com/nextcloud/docker/tree/master/.config defaultConfigs: # To protect /var/www/html/config .htaccess: true @@ -120,31 +121,33 @@ nextcloud: apps.config.php: true # Used for auto configure database autoconfig.php: true - # SMTP default configuration + # SMTP default configuration via environment variables smtp.config.php: true + # S3 Object Storage as primary storage + s3.config.php: true + # Extra config files created in /var/www/html/config/ - # ref: https://docs.nextcloud.com/server/15/admin_manual/configuration_server/config_sample_php_parameters.html#multiple-config-php-file + # ref: https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/config_sample_php_parameters.html#multiple-config-php-file configs: {} - - # For example, to use S3 as primary storage - # ref: https://docs.nextcloud.com/server/13/admin_manual/configuration_files/primary_storage.html#simple-storage-service-s3 - # - # configs: - # s3.config.php: |- - # array( - # 'class' => '\\OC\\Files\\ObjectStore\\S3', - # 'arguments' => array( - # 'bucket' => 'my-bucket', - # 'autocreate' => true, - # 'key' => 'xxx', - # 'secret' => 'xxx', - # 'region' => 'us-east-1', - # 'use_ssl' => true - # ) - # ) - # ); + # For example, to enable image and text file previews: + # previews.config.php: |- + # true, + # 'enabledPreviewProviders' => array ( + # 'OC\Preview\Movie', + # 'OC\Preview\PNG', + # 'OC\Preview\JPEG', + # 'OC\Preview\GIF', + # 'OC\Preview\BMP', + # 'OC\Preview\XBitmap', + # 'OC\Preview\MP3', + # 'OC\Preview\MP4', + # 'OC\Preview\TXT', + # 'OC\Preview\MarkDown', + # 'OC\Preview\PDF' + # ), + # ); ## Strategy used to replace old pods ## IMPORTANT: use with care, it is suggested to leave as that for upgrade purposes