Spring Boot and PostgreSQL on One VM with Observability and Backup
STACKIT
Last updated on
Rehost Spring Boot and PostgreSQL to a STACKIT VM with Terraform and Ansible: prepare inputs, provision, rehearse, cut over, validate, and hand over operations.
Use Discovery evidence to confirm that preserving the Spring Boot JAR, systemd service model, and PostgreSQL engine on a VM meets the migration goals; Kubernetes, Cloud Foundry, or PostgreSQL Flex would instead be Replatform. Derive the delivery sequence from that decision: Landing Zone, Terraform infrastructure, Ansible configuration, separate PostgreSQL migration, and the rehearsed runbook.
Rehost (lift-and-shift) migrates workloads with minimal application change. It is primarily a run strategy to reduce transition risk and accelerate migration throughput.
In practical terms, Rehost is application-wave oriented: each workload gets a defined target runtime mapping, cutover path, and runbook package for repeatable factory delivery.
STACKIT
The sovereign European cloud provider behind the framework, delivering IaaS and PaaS from its own data centers in Germany and Austria.
STACKIT
The sovereign European cloud provider behind the framework, delivering IaaS and PaaS from its own data centers in Germany and Austria.
The Migration Framework defines the strategy, design, landing-zone, migration, and operations principles for Rehost workloads. This asset applies those principles to one concrete, runnable Spring Boot and PostgreSQL implementation on STACKIT.
The maintained repository is the source of truth for Terraform, Ansible, application artifacts, migration scripts, validation, and runtime configuration. This asset explains how to use that implementation without duplicating its complete source code.
STACKIT CMF Rehost Spring Boot repository Open the runnable Terraform and Ansible reference implementation for the Spring Boot and PostgreSQL Rehost path. Open the repositorySTACKIT
The sovereign European cloud provider behind the framework, delivering IaaS and PaaS from its own data centers in Germany and Austria.
Use an isolated Linux lab with Git, Terraform, Ansible, ShellCheck, SSH/SCP, curl, jq,
and PostgreSQL server/client tools including pg_config. The sample dump scripts use
runuser and the local postgres OS account and require root privileges in that lab.
When Server Backup is enabled, the cutover workflow also needs an authenticated STACKIT CLI.
Use the Terraform version that created an existing saved plan; plan files are version-specific.
Start in a parent directory without an existing checkout of the same name. This revision contains the migration workflows and declarative Observability management. Its JAR is unchanged from the artifact pinned by the Replatform reference:
umask 077 && git clone https://github.com/stackitcloud/stackit-cmf-Rehost-springboot.git && git -C stackit-cmf-Rehost-springboot checkout --detach b9225eb35c64b9ef4761c208fadb9a2356431793 && test -f stackit-cmf-Rehost-springboot/scripts/run_cutover.sh && cd stackit-cmf-Rehost-springboot && printf '%s\n' "Workspace ready. Continue from this Rehost checkout." || { printf '%s\n' "Preparation failed. Resolve the error before continuing." >&2 false }Run the following steps from that checkout only after preparation succeeds. Preserve an existing checkout, state and evidence rather than replacing them. Keep credentials, plans, state, dumps, inventory and evidence private and outside version control; do not enable shell tracing.
STACKIT
The sovereign European cloud provider behind the framework, delivering IaaS and PaaS from its own data centers in Germany and Austria.
Create the private variable file only when it does not already exist:
umask 077test -e env.tfvars || cp env.tfvars.example env.tfvarschmod 600 env.tfvarsEdit the file before planning. Configure the approved existing project or project-creation scope,
service-account key path, SSH key pair, available image, availability zone, VM flavor and storage.
Restrict SSH and application ingress to the source CIDRs actually observed on the target path.
Verify the SSH host key through a trusted channel before migration scripts use strict host checking.
Set SSH_KEY and SSH_USER for those scripts when they differ from ~/.ssh/id_rsa and ubuntu;
keep them consistent with Terraform’s private_ssh_key_path and ssh_user.
Enable VM-local PostgreSQL, Observability and Server Backup for this walkthrough. For the initial
runtime deployment, leave postgresql_restore_after_copy = false and the source dump path empty:
provisioning must not import the source before rehearsal and cutover approval. Supply the database
password through the approved secret mechanism as TF_VAR_postgresql_app_password and retain it
securely for subsequent plans; do not put it in the variable file, shell history or documentation.
Confirm permissions, quota, cost approval and the private Terraform backend before initialization. This workflow assumes a prepared execution host, not a complete lab installation procedure.
STACKIT
The sovereign European cloud provider behind the framework, delivering IaaS and PaaS from its own data centers in Germany and Austria.
Create a custom-format source dump and record its SHA-256 checksum, expected row count, and a workload-specific deterministic fingerprint. The repository includes a reproducible eight-row sample:
./scripts/create_source_dump.sh./scripts/validate_source_dump.shThe validation script restores into a separate local PostgreSQL cluster before the dump can enter a migration rehearsal. These scripts generate the bundled sample in temporary local clusters; they do not export a running application or the STACKIT VM. Use a fresh artifact directory and do not overwrite a dump already approved for migration. For a real source, export it under the agreed write-freeze procedure and record equivalent checksum, count and fingerprint evidence.
STACKIT
The sovereign European cloud provider behind the framework, delivering IaaS and PaaS from its own data centers in Germany and Austria.
Configure an existing STACKIT project or project creation, restrict SSH and application ingress to
approved source CIDRs, and pass the database password through TF_VAR_postgresql_app_password rather
than a variable file. Review a saved plan before apply.
terraform init && ./scripts/check.sh && terraform plan -input=false -var-file=env.tfvars -out=tfplanStop if initialization, checks or planning fail. Review resource changes, target project, ingress, cost and the disabled initial restore before explicitly applying that saved plan:
terraform apply tfplanTerraform runs Ansible after provisioning. A successful apply proves completion of that orchestration, not acceptance of migrated data. Check the runtime before beginning rehearsal:
./scripts/validate_deployment.shRun the rehearsal against a temporary database on the target VM:
./scripts/run_migration_rehearsal.shThe rehearsal checks the source evidence, restores the dump, compares row count and fingerprint, and
removes its temporary database without changing the production springmusic database.
STACKIT
The sovereign European cloud provider behind the framework, delivering IaaS and PaaS from its own data centers in Germany and Austria.
./scripts/run_migration_rehearsal.sh against a temporary target database../scripts/run_cutover.sh --confirm with the approved source evidence.STACKIT
The sovereign European cloud provider behind the framework, delivering IaaS and PaaS from its own data centers in Germany and Austria.
Set the expected source evidence in env.tfvars:
enable_local_postgresql = truepostgresql_source_dump_local_path = "artifacts/source-postgresql.dump"postgresql_restore_after_copy = truepostgresql_expected_album_count = 8postgresql_expected_album_fingerprint = "<source-fingerprint>"Then execute the explicit approval gate:
./scripts/run_cutover.sh --confirmThe script requires a fully available Server Backup no older than 24 hours, creates a saved Terraform plan that replaces only the Ansible orchestration resource, rejects unrelated infrastructure changes, applies the restore, validates data and runtime behavior, and requires a final no-op Terraform plan. Retries of the same source-dump hash preserve the original database rollback point.
./scripts/rollback_postgresql.sh --confirm to stop Spring Boot and preserve the current target database.STACKIT
The sovereign European cloud provider behind the framework, delivering IaaS and PaaS from its own data centers in Germany and Austria.
Validation checks the source row count and fingerprint, table ownership, a transactionally rolled-back write as the application role, application reachability, services, and the protected rollback dump.
./scripts/validate_migration.sh./scripts/validate_deployment.sh./scripts/verify_rollback.shIf an approved rollback trigger is met during the rollback window, preserve the current target database and restore the original pre-cutover dump:
./scripts/rollback_postgresql.sh --confirmSTACKIT
The sovereign European cloud provider behind the framework, delivering IaaS and PaaS from its own data centers in Germany and Austria.
Every rehearsal, cutover, and rollback writes an evidence.env file below
artifacts/evidence/<timestamp>-<mode>/. Accept a cutover only when the evidence records the expected
checksum, row count, fingerprint, target VM, successful runtime validation, and final Terraform no-op.
./scripts/validate_migration.sh./scripts/validate_deployment.shterraform plan -var-file=env.tfvars -detailed-exitcodeUse the same approved source path, restore flag, expected count and fingerprint as the completed
cutover. Exit code 0 means no changes, 2 means changes are proposed, and 1 means an error.
A plan alone is not proof of apply. The cutover workflow records status=passed and
terraform_noop=true only after applying its saved plan and completing data and runtime validation.
With enable_server_backup = true, Terraform enables STACKIT Server Backup and a daily schedule for
the VM boot volume. The default retention is 14 days. Cutover requires a fully available backup no older
than 24 hours. Backup creation and status were validated against the real target; an in-place Server
Backup restore remains a disruptive disaster-recovery operation and must be rehearsed in a separate
recovery environment.
The Server Backup complements the PostgreSQL pre-restore dump. It does not replace database-level consistency checks or the application rollback procedure.
Return from the concrete migration example to the Migration Framework. Start optimization only after stable cutover, use representative production telemetry, implement one controlled change at a time, and validate its effect on reliability, performance, and cost.
Optimize starts when workloads run on STACKIT and real operating data is available. The module converts post-cutover observations into measurable improvements for performance, stability, and cost efficiency.
Optimize is not a one-time task. It is an iterative cycle that can overlap with early stabilization and post-cutover care.
Many right-sizing and tuning decisions are only reliable under real load patterns. After cutover, teams can use production telemetry to separate assumptions from actual behavior.
STACKIT
The sovereign European cloud provider behind the framework, delivering IaaS and PaaS from its own data centers in Germany and Austria.
This asset continues the same Spring Boot and PostgreSQL reference implementation used for provisioning, migration, cutover, and stabilization. It does not introduce another example or repository. The existing Terraform variables, Ansible configuration, Observability instance, and validation workflows remain the technical baseline for Optimize.
The Optimize extension answers one practical question: how to detect overprovisioning or underprovisioning and then change VM or storage capacity through a controlled IaC workflow.
STACKIT CMF Rehost Spring Boot repository Continue with the same Terraform and Ansible reference implementation used by the preceding Rehost migration steps. Open the repository Rehost implementation assetUse the dashboard to review infrastructure saturation, application health, request behavior, and alert history together before changing VM capacity.

STACKIT
The sovereign European cloud provider behind the framework, delivering IaaS and PaaS from its own data centers in Germany and Austria.
Update VM sizing in env.tfvars:
machine_type = "g3i.2"Apply and inspect plan output:
terraform plan -var-file=env.tfvarsterraform apply -var-file=env.tfvarsThen validate:
systemctl status, synthetic checks)STACKIT
The sovereign European cloud provider behind the framework, delivering IaaS and PaaS from its own data centers in Germany and Austria.
In Rehost scenarios, CPU and memory are only one side of rightsizing. Storage performance can also become the limiting factor.
A Block Storage performance class defines the maximum IOPS and throughput available to the complete volume. Application, database, operating-system, and backup access share this performance envelope. Select the class from measured peak demand, latency requirements, backup activity, and explicit growth headroom before creating the volume.
The following table lists currently available performance classes for the EU01 region:
| Performance class | Name | Max. IOPS | Max. Throughput (MB/s) |
|---|---|---|---|
| Performance class 0 | storage_premium_perf0 | 120 | 25 |
| Performance class 1 | storage_premium_perf1 | 500 | 50 |
| Performance class 2 | storage_premium_perf2 | 1000 | 100 |
| Performance class 4 | storage_premium_perf4 | 2000 | 150 |
| Performance class 6 | storage_premium_perf6 | 5000 | 200 |
| Performance class 8 | storage_premium_perf8 | 10000 | 250 |
| Performance class 10 | storage_premium_perf10 | 15000 | 300 |
| Performance class 12 | storage_premium_perf12 | 20000 | 350 |
| Performance class 13 | storage_premium_perf13 | 20000 | 700 |
| Performance class 14 | storage_premium_perf14 | 25000 | 400 |
| Performance class 15 | storage_premium_perf15 | 25000 | 800 |
| Performance class 16 | storage_premium_perf16 | 30000 | 450 |
| Performance class 17 | storage_premium_perf17 | 30000 | 900 |
| Performance class 18 | storage_premium_perf18 | 35000 | 500 |
| Performance class 19 | storage_premium_perf19 | 35000 | 1000 |
| Performance class 20 | storage_premium_perf20 | 40000 | 550 |
| Performance class 21 | storage_premium_perf21 | 40000 | 1100 |
| Performance class 29 | storage_premium_perf29 | 60000 | 1500 |
IOPS - Input/Output Operations per second
Throughput - Throughput in Megabytes per second
Thus, the classes used can be distinguished in detail based on the naming. Example: “Block Storage Premium - Performance Class 2” corresponds to SSD hard disks with max. 1000 IOPS and max. 100 Mbyte/s throughput.
This section is copied from the STACKIT docs automatically, several times a day. It cannot be changed here. Changes belong in the STACKIT docs.
For the Rehost baseline, the operating system, Spring Boot application, and PostgreSQL data share the boot volume. Changing its performance class therefore requires a controlled replacement target:
Use a separate data volume when storage capacity or performance must evolve independently from the VM lifecycle. To change its performance class, create a new volume in the required availability model with sufficient capacity, stop writes, migrate and verify the data, switch the attachment or mount, and retain the source volume until acceptance and rollback gates have passed.
Migrate data from Block StorageTreat storage checks as part of the same Optimize loop and validate latency, error behavior, recovery, and cost impact after any change.
The Replatform reference reuses this repository’s pinned Spring Music JAR and sample-data generator. Its sample walkthrough therefore needs this checkout and validated dump artifacts, but not a newly provisioned Rehost VM. Do not create another VM solely to generate the local sample.
For an actual migration from the Rehost VM to SKE and PostgreSQL Flex, verify that the VM is currently healthy, freeze its application writes, export its real PostgreSQL database and qualify that export. A historical successful Rehost apply does not establish current reachability or make the local sample equivalent to live VM data. Source export, acceptance and source failback need their own approved procedure.