Skip to content

Migrating a cPanel application to Kubernetes: the shape that works

cPanel apps land on Kubernetes when the team has tried twice with mixed results. The third attempt succeeds when the database, secrets, and storage are decided up front.

A cPanel-to-Kubernetes migration is rarely a fresh build. It is usually an existing application — often LAMP — that grew on cPanel for three or five years, has thirty .htaccess rewrites, depends on a crontab belonging to the cPanel user, and pulls files from /home/<user>/uploads on disk. Moving it into a cluster requires deciding how each of those concerns becomes Kubernetes-native, not just packaging the codebase into a container.

What’s happening

cPanel hides three things Kubernetes makes explicit: where the database lives, where secrets live, and where persistent files live. On cPanel the answer to all three is “on the same machine”. On Kubernetes the database is a separate service (managed or in-cluster), secrets are mounted from a secret store, and persistent files belong in object storage or a PVC. Skipping that decomposition is how migrations end up with stateful pods that cannot be rescheduled.

How to verify

On the cPanel source, map the dependencies the cluster will need:

crontab -u <user> -l
grep -r 'mysql_connect\|mysqli_connect\|PDO' /home/<user>/public_html
find /home/<user>/public_html -name ".htaccess" -exec cat {} \;
du -sh /home/<user>/public_html/uploads

On the destination cluster, confirm the building blocks:

kubectl get sc        # storage classes for PVC
kubectl get secret    # secret backend wired up
kubectl get ingress   # ingress controller alive

The fix

  1. Containerize without changing behavior — base image PHP-FPM + Apache or Nginx, mount the codebase, expose port 80. Iterate until it serves the same pages as cPanel against the cPanel database (via tunnel).
  2. Move the database — replicate the cPanel MySQL into a managed database (or in-cluster operator). Cut the app over to the new DSN.
  3. Move uploads to object storage — install an S3 plugin (or fork the upload code), backfill the existing /uploads to a bucket, switch the app’s write path.
  4. Translate cron — every cPanel crontab line becomes a CronJob resource. Set timezone explicitly; cPanel cron runs in the server’s local timezone.
  5. Ingress + TLS — provision an Ingress with cert-manager. Run a parallel host (new.example.com) until the application is verified, then cut DNS.

Stack Harbor takes ownership of cPanel-to-Kubernetes migrations end-to-end under migration solutions — book a migration review before the codebase moves.