From cae03aa746b77e3a7b8b150925fb22dd612c9486 Mon Sep 17 00:00:00 2001 From: Alexandre Pires Date: Sun, 6 Oct 2024 01:45:58 +0200 Subject: [PATCH] Update Nextcloud configuration and dependencies --- Readme.MD | 15 +++++++ bin/occ | 3 ++ terraform/k8sapps/config.tf | 4 +- terraform/k8sapps/nextcloud.tf | 42 +++++++++++++++---- .../resources/apache2/99-compression.conf | 14 +++++++ .../apache2/99-nextcloudworkers.conf | 1 + 6 files changed, 69 insertions(+), 10 deletions(-) create mode 100755 bin/occ create mode 100644 terraform/k8sapps/resources/apache2/99-compression.conf create mode 100644 terraform/k8sapps/resources/apache2/99-nextcloudworkers.conf diff --git a/Readme.MD b/Readme.MD index d752397..317759f 100644 --- a/Readme.MD +++ b/Readme.MD @@ -3,3 +3,18 @@ This is part of A13Labs project, any unauthorized copy is no allowed. If you got access to this code DELETE immediately. We have been warned. +# Updating Nextcloud + +``` +# Enable maintenance +/bin/occ maintenance:mode --on +# Update config.tf +# Apply +# Run maintenance operations +./bin/occ upgrade +./bin/occ db:add-missing-columns +./bin/occ db:add-missing-indices +./bin/occ db:add-missing-primary-keys +# Disable maintenance +./bin/occ maintenance:mode --off +``` \ No newline at end of file diff --git a/bin/occ b/bin/occ new file mode 100755 index 0000000..b0b128d --- /dev/null +++ b/bin/occ @@ -0,0 +1,3 @@ +#!/bin/bash +POD_NAME=$(kubectl get pods -n nextcloud -l app=nextcloud -o jsonpath="{.items[0].metadata.name}") +kubectl -n nextcloud exec -it $POD_NAME -- /bin/su -s /bin/bash www-data -c "/var/www/html/occ $*" \ No newline at end of file diff --git a/terraform/k8sapps/config.tf b/terraform/k8sapps/config.tf index c2f4383..79a8820 100644 --- a/terraform/k8sapps/config.tf +++ b/terraform/k8sapps/config.tf @@ -6,12 +6,12 @@ locals { wordpress_sql_backup_cron_schedule = "0 2 * * *" wordpress_files_backup_cron_schedule = "10 2 * * *" - gitea_version = "1.21.3" + gitea_version = "1.22.2" gitea_fqdn = "code.alexpires.me" gitea_sql_backup_cron_schedule = "20 2 * * *" gitea_files_backup_cron_schedule = "30 2 * * *" - nextcloud_version = "28.0.7-apache" + nextcloud_version = "30.0.0-apache" nextcloud_fqdn = "cloud.alexpires.me" nextcloud_sql_backup_cron_schedule = "40 2 * * *" nextcloud_files_backup_cron_schedule = "50 2 * * *" diff --git a/terraform/k8sapps/nextcloud.tf b/terraform/k8sapps/nextcloud.tf index 84116a2..9479002 100644 --- a/terraform/k8sapps/nextcloud.tf +++ b/terraform/k8sapps/nextcloud.tf @@ -29,6 +29,9 @@ locals { OVERWRITEHOST = local.nextcloud_fqdn OVERWRITEPROTOCOL = "https" OVERWRITECLIURL = "https://${local.nextcloud_fqdn}" + + # PHP + PHP_MEMORY_LIMIT = "512M" } nextcloud_secrets = { @@ -134,6 +137,18 @@ resource "kubernetes_secret" "nextcloud_admin_credentials" { type = "Opaque" } +resource "kubernetes_config_map" "nextcloud_apache_config" { + metadata { + name = "nextcloud-apache-config" + namespace = kubernetes_namespace.nextcloud.metadata[0].name + } + data = { + "99-nextcloudworkers.conf" = file("${path.module}/resources/apache2/99-nextcloudworkers.conf") + "99-compression.conf" = file("${path.module}/resources/apache2/99-compression.conf") + } + +} + # # Setup MariaDB database # @@ -291,14 +306,6 @@ resource "kubernetes_deployment" "nextcloud_redis" { name = "redis" image = "redis:latest" - resources { - requests = { - memory = "20Mi" - } - limits = { - memory = "50Mi" - } - } security_context { allow_privilege_escalation = false } @@ -428,6 +435,19 @@ resource "kubernetes_deployment" "nextcloud_apache" { mount_path = "/var/www/html" name = "persistent-storage" } + + volume_mount { + mount_path = "/etc/apache2/conf-enabled/99-nextcloudworkers.conf" + name = "apache-config" + sub_path = "99-nextcloudworkers.conf" + read_only = true + } + volume_mount { + mount_path = "/etc/apache2/conf-enabled/99-compression.conf" + name = "apache-config" + sub_path = "99-compression.conf" + read_only = true + } } volume { name = "persistent-storage" @@ -435,6 +455,12 @@ resource "kubernetes_deployment" "nextcloud_apache" { path = local.nextcloud_path } } + volume { + name = "apache-config" + config_map { + name = kubernetes_config_map.nextcloud_apache_config.metadata[0].name + } + } } } } diff --git a/terraform/k8sapps/resources/apache2/99-compression.conf b/terraform/k8sapps/resources/apache2/99-compression.conf new file mode 100644 index 0000000..2366fb1 --- /dev/null +++ b/terraform/k8sapps/resources/apache2/99-compression.conf @@ -0,0 +1,14 @@ + + # Enable compression for the following content types + AddOutputFilterByType DEFLATE text/html + AddOutputFilterByType DEFLATE text/css + AddOutputFilterByType DEFLATE application/javascript + AddOutputFilterByType DEFLATE application/x-javascript + AddOutputFilterByType DEFLATE application/json + AddOutputFilterByType DEFLATE application/xml + AddOutputFilterByType DEFLATE image/svg+xml + AddOutputFilterByType DEFLATE text/xml + + +# Do not compress images +SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png|webp|woff|woff2)$ no-gzip diff --git a/terraform/k8sapps/resources/apache2/99-nextcloudworkers.conf b/terraform/k8sapps/resources/apache2/99-nextcloudworkers.conf new file mode 100644 index 0000000..72e34fe --- /dev/null +++ b/terraform/k8sapps/resources/apache2/99-nextcloudworkers.conf @@ -0,0 +1 @@ +MaxRequestWorkers 10 \ No newline at end of file