nextcloud

by ScriptonBasestar

Helm chartv0.4.0App 31.0.10BSD-3-Clause

Self-hosted productivity platform with file sync, calendar, contacts, and collaboration tools

About this chart

Nextcloud Helm Chart

Production-ready Nextcloud deployment on Kubernetes with external PostgreSQL 16 and Redis 8 support.

Features

  • Nextcloud Apache Image: Official Nextcloud with Apache HTTP Server
  • External Database: PostgreSQL 16 support (no embedded database)
  • External Cache: Redis 8 for session and memory cache
  • Persistent Storage: Separate volumes for data, config, and custom apps
  • Security: Running as non-root user (www-data)
  • High Availability: Configurable replicas and autoscaling
  • Production Ready: Resource limits, health checks, and monitoring
  • Background Jobs: Kubernetes CronJob for Nextcloud background tasks

Prerequisites

Deployment Scenarios

This chart includes three pre-configured deployment scenarios optimized for different use cases:

Home Server (values-home-single.yaml)

Minimal resources for personal servers, home labs, Raspberry Pi, or Intel NUC:

helm install nextcloud-home charts/nextcloud \
  -f charts/nextcloud/values-home-single.yaml \
  --set nextcloud.admin.password=your-secure-password \
  --set postgresql.external.password=your-db-password \
  --set postgresql.external.host=postgres.default.svc.cluster.local

Resource allocation: 100-500m CPU, 256-512Mi RAM, 10Gi storage

Startup Environment (values-startup-single.yaml)

Balanced configuration for small teams, startups, and development environments:

helm install nextcloud-startup charts/nextcloud \
  -f charts/nextcloud/values-startup-single.yaml \
  --set nextcloud.admin.password=your-secure-password \
  --set postgresql.external.password=your-db-password \
  --set postgresql.external.host=postgres.default.svc.cluster.local

Resource allocation: 250m-1000m CPU, 512Mi-1Gi RAM, 20Gi storage

Production HA (values-prod-master-replica.yaml)

High availability deployment with multiple replicas and monitoring:

helm install nextcloud-prod charts/nextcloud \
  -f charts/nextcloud/values-prod-master-replica.yaml \
  --set nextcloud.admin.password=your-secure-password \
  --set postgresql.external.password=your-db-password \
  --set postgresql.external.host=postgres.default.svc.cluster.local

Features: 3 replicas, pod anti-affinity, HPA, PodDisruptionBudget, NetworkPolicy, ServiceMonitor

Resource allocation: 500m-2000m CPU, 1-2Gi RAM, 50Gi storage per pod

For detailed comparison and configuration examples, see the Scenario Values Guide.

  • Kubernetes 1.19+
  • Helm 3.0+
  • External PostgreSQL 16 database
  • External Redis 8 server
  • PersistentVolume support (for data persistence)
  • Ingress controller (for external access)

Quick Start

1. Prepare External Dependencies

Before installing Nextcloud, ensure you have:

PostgreSQL 16:

# Create database and user
CREATE DATABASE nextcloud;
CREATE USER nextcloud WITH ENCRYPTED PASSWORD 'your-secure-password';
GRANT ALL PRIVILEGES ON DATABASE nextcloud TO nextcloud;

Redis 8:

# Redis should be accessible with host:port
# Optional: Configure password for Redis

2. Create Values File

Create a my-values.yaml file:

# Basic Nextcloud configuration
nextcloud:
  adminUser: admin
  adminPassword: "YourSecureAdminPassword"
  trustedDomains:
    - nextcloud.example.com

# External PostgreSQL configuration
postgresql:
  external:
    enabled: true
    host: "postgres-postgresql.default.svc.cluster.local"
    port: 5432
    database: "nextcloud"
    username: "nextcloud"
    password: "your-secure-password"

# External Redis configuration
redis:
  external:
    enabled: true
    host: "redis-master.default.svc.cluster.local"
    port: 6379
    password: "your-redis-password"  # Optional

# Ingress configuration
ingress:
  enabled: true
  className: "nginx"
  hosts:
    - host: nextcloud.example.com
      paths:
        - path: /
          pathType: Prefix
  tls:
    - secretName: nextcloud-tls
      hosts:
        - nextcloud.example.com

# Storage configuration
persistence:
  data:
    size: 20Gi  # Adjust based on your needs
  config:
    size: 1Gi
  apps:
    size: 2Gi

# Resource limits
resources:
  limits:
    cpu: 2000m
    memory: 2Gi
  requests:
    cpu: 500m
    memory: 512Mi

3. Install the Chart

# Add the repository (if needed)
# helm repo add scripton https://your-helm-repo.example.com
# helm repo update

# Install Nextcloud
helm install nextcloud ./nextcloud -f my-values.yaml

# Or upgrade if already installed
helm upgrade --install nextcloud ./nextcloud -f my-values.yaml

4. Access Nextcloud

# Check the deployment status
kubectl get pods -l app.kubernetes.io/name=nextcloud

# Get the Ingress URL
kubectl get ingress -l app.kubernetes.io/name=nextcloud

# Access via browser
https://nextcloud.example.com

Configuration

Nextcloud Settings

ParameterDescriptionDefault
nextcloud.adminUserAdmin usernameadmin
nextcloud.adminPasswordAdmin password (required)""
nextcloud.versionNextcloud version"28.0"
nextcloud.trustedDomainsList of trusted domains[]

Image Configuration

ParameterDescriptionDefault
image.repositoryNextcloud image repositorynextcloud
image.tagImage tag"28.0-apache"
image.pullPolicyImage pull policyIfNotPresent

External PostgreSQL

ParameterDescriptionDefault
postgresql.external.enabledEnable external PostgreSQLtrue
postgresql.external.hostPostgreSQL host""
postgresql.external.portPostgreSQL port5432
postgresql.external.databaseDatabase name"nextcloud"
postgresql.external.usernameDatabase username"nextcloud"
postgresql.external.passwordDatabase password""
postgresql.external.existingSecret.enabledUse existing secretfalse

External Redis

ParameterDescriptionDefault
redis.external.enabledEnable external Redistrue
redis.external.hostRedis host""
redis.external.portRedis port6379
redis.external.passwordRedis password (optional)""
redis.external.databaseRedis database number0
redis.external.existingSecret.enabledUse existing secretfalse

Persistent Storage

ParameterDescriptionDefault
persistence.enabledEnable persistencetrue
persistence.data.enabledEnable data volumetrue
persistence.data.sizeData volume size8Gi
persistence.data.storageClassStorage class"" (default)
persistence.config.enabledEnable config volumetrue
persistence.config.sizeConfig volume size1Gi
persistence.apps.enabledEnable custom apps volumetrue
persistence.apps.sizeApps volume size1Gi

S3 Object Storage

Nextcloud can use S3-compatible object storage as its primary storage backend, replacing local file storage entirely.

Quick Configuration

Add S3 configuration to your values:

nextcloud:
  configs:
    s3.config.php: |-
      <?php
      $CONFIG = array(
        'objectstore' => [
          'class' => '\\OC\\Files\\ObjectStore\\S3',
          'arguments' => [
            'bucket' => 'nextcloud-data',
            'autocreate' => true,
            'key' => 'nextcloud-user',
            'secret' => getenv('S3_SECRET_KEY'),
            'hostname' => 'minio.default.svc.cluster.local',
            'port' => 9000,
            'use_ssl' => false,
            'region' => 'us-east-1',
            'use_path_style' => true
          ],
        ],
      );

  extraEnv:
    - name: S3_SECRET_KEY
      valueFrom:
        secretKeyRef:
          name: nextcloud-s3-credentials
          key: secret-access-key

Create S3 credentials secret:

kubectl create secret generic nextcloud-s3-credentials \
  --from-literal=secret-access-key=nextcloud-secure-password

Important Notes

Migration: Moving existing data to S3 requires manual migration. S3 object storage must be configured before first installation or during a clean install.

Database: Nextcloud still requires PostgreSQL for metadata, even when using S3 for files.

Performance: Enable Redis caching for better performance with S3:

redis:
  external:
    enabled: true
    host: "redis.default.svc.cluster.local"

Benefits:

  • Unlimited scalable storage
  • Multi-region replication support
  • Reduced PVC costs (only config/apps need local storage)
  • Simplified backup and disaster recovery

For complete S3 integration guide including MinIO setup, bucket creation, and security best practices, see the S3 Integration Guide.

Ingress

ParameterDescriptionDefault
ingress.enabledEnable ingressfalse
ingress.classNameIngress class name"nginx"
ingress.annotationsIngress annotationsSee values.yaml
ingress.hostsIngress hosts configuration[]
ingress.tlsIngress TLS configuration[]

Resources

ParameterDescriptionDefault
resources.limits.cpuCPU limit2000m
resources.limits.memoryMemory limit2Gi
resources.requests.cpuCPU request500m
resources.requests.memoryMemory request512Mi

Cron Job

ParameterDescriptionDefault
cronjob.enabledEnable background cron jobtrue
cronjob.scheduleCron schedule"*/15 * * * *"
cronjob.resourcesCron job resourcesSee values.yaml

High Availability & Security

ParameterDescriptionDefault
podDisruptionBudget.enabledEnable PodDisruptionBudgetfalse
podDisruptionBudget.minAvailableMinimum pods available1
networkPolicy.enabledEnable NetworkPolicyfalse
monitoring.serviceMonitor.enabledEnable Prometheus monitoringfalse

Pod Disruption Budget

Protects Nextcloud during cluster maintenance:

podDisruptionBudget:
  enabled: true
  minAvailable: 1  # Ensure at least 1 pod is always running

Benefits:

  • Prevents all pods from being drained simultaneously
  • Ensures service availability during node maintenance
  • Critical for production deployments

Network Policy

Restricts network access for security:

networkPolicy:
  enabled: true
  ingress:
    - from:
      - namespaceSelector:
          matchLabels:
            name: production
      - podSelector:
          matchLabels:
            app: frontend  # Only allow frontend pods
      ports:
        - protocol: TCP
          port: 80

Benefits:

  • Network-level security isolation
  • Restricts access to authorized clients only
  • Defense-in-depth security posture

Prometheus Monitoring

Enable metrics collection (requires Nextcloud serverinfo app):

monitoring:
  serviceMonitor:
    enabled: true
    path: /ocs/v2.php/apps/serverinfo/api/v1/info?format=json
    interval: 30s
    additionalLabels:
      prometheus: kube-prometheus

Note: The serverinfo app must be installed in Nextcloud for metrics to work.

Advanced Configuration

Using Existing Secrets

Instead of putting passwords in values.yaml, you can use existing Kubernetes secrets:

postgresql:
  external:
    existingSecret:
      enabled: true
      secretName: "postgres-credentials"
      usernameKey: "username"
      passwordKey: "password"

redis:
  external:
    existingSecret:
      enabled: true
      secretName: "redis-credentials"
      passwordKey: "password"

Create the secrets:

# PostgreSQL secret
kubectl create secret generic postgres-credentials \
  --from-literal=username=nextcloud \
  --from-literal=password=your-secure-password

# Redis secret
kubectl create secret generic redis-credentials \
  --from-literal=password=your-redis-password

Using Existing PVCs

If you already have PersistentVolumeClaims:

persistence:
  data:
    existingClaim: "my-nextcloud-data-pvc"
  config:
    existingClaim: "my-nextcloud-config-pvc"
  apps:
    existingClaim: "my-nextcloud-apps-pvc"

SMTP Configuration

Enable email functionality:

nextcloud:
  smtp:
    enabled: true
    host: "smtp.gmail.com"
    port: 587
    secure: "tls"
    authType: "LOGIN"
    from: "[email protected]"
    username: "[email protected]"
    password: "your-app-password"

Custom Environment Variables

Add custom environment variables:

extraEnv:
  - name: PHP_MEMORY_LIMIT
    value: "1024M"
  - name: PHP_UPLOAD_LIMIT
    value: "20G"

Maintenance

Backup

Backup your PersistentVolumes regularly:

# Backup data volume
kubectl exec -it <nextcloud-pod> -- tar czf /backup/nextcloud-data.tar.gz /var/www/html

# Backup database
kubectl exec -it <postgres-pod> -- pg_dump -U nextcloud nextcloud > nextcloud-db-backup.sql

Upgrade Nextcloud

# Update image tag in values.yaml
image:
  tag: "29.0-apache"

# Upgrade the release
helm upgrade nextcloud ./nextcloud -f my-values.yaml

# Check upgrade status
kubectl logs -f <nextcloud-pod> -c init-nextcloud

Scaling

Adjust replicas for high availability:

replicaCount: 3

# Note: Requires ReadWriteMany (RWX) storage class
persistence:
  data:
    accessMode: ReadWriteMany

Troublesho

Deploy nextcloud with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has nextcloud on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartnextcloud is pinned at v0.4.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply