Nextcloud on Kubernetes – Production-Grade Migration and Orchestration
Overview
This project was a major upgrade in my home infrastructure. After many hours of reading and about a month of trial and error, i took my existing Nextcloud setup, which originally ran on Docker Compose, and fully migrated it to Kubernetes. The goal was to gain scalability, better operational control, and a more predictable lifecycle for the application. The work covered everything end-to-end: converting the old compose file into Kubernetes manifests, configuring persistent storage with the nfs-client-provisioner helm chart, and finally moving all my live data from the old Docker server to the new cluster.
1. Converting the Docker Compose Setup to Kubernetes Manifests
I started with my simple docker-compose.yaml that defined Nextcloud, MariaDB, Collabora and Cloudflare tunnel. It worked for the early days, but I wanted something more scalable and maintainable. I broke the compose structure apart and translated each service into Kubernetes-native resources.
Deployments replaced container blocks, Services replaced exposed ports, and environment variables moved into ConfigMaps and Secrets. Instead of one large file, I ended up with a structured and modular set of manifests. This shift let me treat the whole application as declarative infrastructure, which made updates, rollouts, and troubleshooting much easier.
Nextcloud running on my Docker server with public domain

2. Setting Up Persistent Storage with the NFS-Client Provisioner
To make sure Nextcloud worked well across the cluster, I needed reliable persistent storage. I set up an NFS export on my openmediavault NAS and installed the NFS-client provisioner so Kubernetes could dynamically create PersistentVolumes.
Once the provisioner was in place, I created PersistentVolumeClaims for:
- Nextcloud’s data directory
- MariaDB’s database files
- Collabora’s storage needs
I used RWX (ReadWriteMany) access modes so pods could run on any node without storage conflicts. This storage layer was essential for making the whole stack truly portable inside the cluster.
3. Deploying Nextcloud and Configuring LoadBalancer
With manifests and storage ready, I deployed Nextcloud onto the cluster. I exposed it using MetalLB loadbalancher resource and plugged it into my existing Cloudflare tunnel. Health probes, resource limits, and rolling update strategies helped me stabilize the environment.
Once everything was online, the Kubernetes version of the stack behaved much more predictably than the old Compose setup.
4. Migrating Data from Docker to Kubernetes
To complete the transition, I migrated all of my data from the old Docker server to the new Kubernetes environment.
Here’s what I did:
- Stopped the old Docker Compose stack to freeze the data.
- Exported the MariaDB database and backed up the entire Nextcloud data directory.
- Copied the backups into the NFS paths used by the Kubernetes PVCs.
- Restored the database into the MariaDB pod.
- Checked permissions and ownership to match what Nextcloud expected inside the cluster.
- Restarted the pods and validated the instance.
After the migration finished, my Nextcloud instance came up with all users, files, and settings intact.

Conclusion
By the end of this project, I had fully moved Nextcloud from a single Docker Compose deployment into a structured Kubernetes environment. I gained dynamic storage provisioning, modular manifests, standardized configuration, and a far more resilient platform. The migration improved reliability, scaling, and maintainability across the board and set a solid foundation for running more stateful applications in Kubernetes going forward.