Selected work / Database automation

Database automation · Devtron OSS

Automating PostgreSQL 11 to 14 for 20K+ OSS users

Built a three-job PostgreSQL migration with backup prerequisites, PVC discovery, staged recovery, and version verification for self-hosted installations.

Three coordinated Kubernetes Jobs migrating PostgreSQL 11 to 14 with ConfigMap checkpointsBACKUP VERIFIED / THREE COORDINATED JOBSPOSTGRESQL 11 → 14DEVTRON-PRE-UPGRADEDiscover PVCNew PVC +5GiStart upgrade-initDEVTRON-UPGRADE-INITQuiesce installScale down appsClose DB connectionsDEVTRON-UPGRADEMigrate + restorePreserve schedulingInstall PG14, scale upCONFIGMAP CHECKPOINTS + RECOVERYPOSTGRES_MIGRATED = 14Logs + PVC recovery path
20K+open-source users covered by the upgrade path
3 jobscoordinated through the migration workflow
11 → 14PostgreSQL major versions

The problem

Devtron’s self-hosted open-source installations needed to move from Bitnami PostgreSQL 11 to Official PostgreSQL 14. The upgrade had to work across user-operated clusters rather than one centrally controlled database.

Those environments could differ in storage classes, PVC sizes, scheduling constraints, and admission policies. A reliable upgrade needed to preserve each installation’s configuration while providing clear checkpoints and recovery instructions.

A three-job migration workflow

I designed the upgrade as three coordinated Kubernetes Jobs. Each job has a specific responsibility and produces observable state for the next stage.

Prepare storage and migration state

The devtron-pre-upgrade job creates the devtron-postgres-upgrade ConfigMap, discovers the existing PostgreSQL PVC’s storage class and size, and creates a new upgrade PVC with 5Gi of additional storage.

A successful backup through the Devtron Backup Chart is a prerequisite. The job then automatically starts the next stage.

Quiesce the installation

The devtron-upgrade-init job scales down Devtron components to establish database consistency, terminates active database connections, and starts the migration process.

Operators can monitor the job logs and inspect the ConfigMap for stage-specific errors rather than guessing where a failure occurred.

Replace, migrate, and restore

After confirming the backup, the operator applies the final devtron-upgrade job. It verifies that upgrade initialization succeeded and extracts nodeSelectors and tolerations from the existing PostgreSQL StatefulSet.

The job removes the PostgreSQL 11 components, installs PostgreSQL 14 with the same scheduling configuration, migrates the data, and scales the Devtron components back up.

Verification and recovery

The workflow exposes explicit post-upgrade checks. A successful migration sets POSTGRES_MIGRATED to 14 in the ConfigMap, and operators verify that all pods return to a running state.

The troubleshooting path distinguishes between failed jobs and pending PVC creation. Where an initialization run must be repeated, the documented recovery process recreates the upgrade PVC with the same configuration before reapplying the job.

Outcome

The result is a repeatable, checkpointed upgrade path for Devtron’s 20K+ open-source user base. It replaces a manual sequence of storage, database, scheduling, and restoration steps with three observable Kubernetes Jobs while retaining operator control at the backup and final-upgrade boundaries.

The implementation and recovery instructions are publicly available in the Devtron utilities repository.