{"id":51045572,"url":"https://github.com/stackitcloud/stackit-cmf-replatform-springboot-k8s","last_synced_at":"2026-06-22T13:32:20.998Z","repository":{"id":356551579,"uuid":"1232086635","full_name":"stackitcloud/stackit-cmf-replatform-springboot-k8s","owner":"stackitcloud","description":"STACKIT Cloud Framework Replatform Springboot Example for Kubernetes","archived":false,"fork":false,"pushed_at":"2026-05-08T14:43:04.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-08T16:39:47.920Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stackitcloud.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-07T15:17:39.000Z","updated_at":"2026-05-08T14:43:09.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/stackitcloud/stackit-cmf-replatform-springboot-k8s","commit_stats":null,"previous_names":["stackitcloud/stackit-cmf-replatform-springboot-k8s"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/stackitcloud/stackit-cmf-replatform-springboot-k8s","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackitcloud%2Fstackit-cmf-replatform-springboot-k8s","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackitcloud%2Fstackit-cmf-replatform-springboot-k8s/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackitcloud%2Fstackit-cmf-replatform-springboot-k8s/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackitcloud%2Fstackit-cmf-replatform-springboot-k8s/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stackitcloud","download_url":"https://codeload.github.com/stackitcloud/stackit-cmf-replatform-springboot-k8s/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackitcloud%2Fstackit-cmf-replatform-springboot-k8s/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34651748,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-22T02:00:06.391Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-22T13:32:20.839Z","updated_at":"2026-06-22T13:32:20.989Z","avatar_url":"https://github.com/stackitcloud.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# stackit-cmf-replatform-springboot-k8s\n\nRunnable replatform example for STACKIT: migrate a Spring Boot workload to SKE with DNS and Observability.\n\n## What this example creates\n\n- Optional target project creation\n- SKE cluster (small default node pool)\n- DNS zone and external-dns integration\n- STACKIT Observability instance\n- Spring Boot Deployment + Service (LoadBalancer)\n- Optional Horizontal Pod Autoscaler (HPA) for Spring Boot\n- Optional STACKIT PostgreSQL Flex target database\n- Metrics exporter sidecar on port 9090\n- Observability scrape config for Spring Boot metrics\n- Grafana dashboard import\n- Optional load-generator pod\n- Optional Kubernetes migration job for VM PostgreSQL -\u003e PostgreSQL Flex\n\n## Prerequisites\n\n- Terraform \u003e= 1.5\n- Service account key file\n- Required permissions for SKE, DNS, Observability, and optional project creation\n\n## 1) Configure variables\n\nCopy the example file:\n\n```bash\ncp env.tfvars.example env.tfvars\n```\n\nThen edit `env.tfvars`.\n\n### Common flag wrapper\n\nTo use the common CMF flags, copy and adjust:\n\n```bash\ncp flags.env.example flags.env\n```\n\nThen run:\n\n```bash\n./scripts/apply_with_common_flags.sh flags.env env.tfvars\n```\n\nCommon flags:\n\n- `setup_project`\n- `setup_observability`\n- `setup_database`\n- `setup_workload`\n- `setup_loadgen`\n- `setup_dns`\n\n### Values you must replace (currently `xxxx`)\n\n- `target_project_owner_email`\n- `parent_container_id`\n- `ske_cluster_name`\n- `observability_instance_name`\n- `dns_zone_name`\n- `dns_zone_display_name`\n\n### Notes for these required values\n\n- `target_project_owner_email`: service account or owner email used for project creation\n- `parent_container_id`: folder/container ID (for `create_project = true`)\n- `ske_cluster_name`: max 11 characters\n- `observability_instance_name`: unique readable instance name\n- `dns_zone_name`: delegated DNS zone (for example `cmf-1234.runs.onstackit.cloud`)\n- `dns_zone_display_name`: display name for the DNS zone resource\n\n### Commonly adjusted values\n\n- `service_account_key_path`\n- `target_project_name`\n- `region`, `availability_zone`\n- `node_pool_machine_type`\n- `springboot_image`\n- `enable_postgres_flex`\n- `enable_springboot_hpa`, `springboot_hpa_*`\n- `enable_load_generator`, `load_profile`\n\n## Kubernetes rightsizing options\n\nFor replatformed workloads on SKE, rightsizing can be applied at multiple layers:\n\n- Pod layer: adjust requests/limits and optionally enable HPA.\n- Node pool layer: tune node pool min/max and machine type.\n- Storage layer: choose suitable storage classes for persistence characteristics.\n\n### Enable HPA (optional)\n\nSet in `env.tfvars`:\n\n```hcl\nenable_springboot_hpa                         = true\nspringboot_hpa_min_replicas                   = 1\nspringboot_hpa_max_replicas                   = 5\nspringboot_hpa_target_cpu_utilization_percentage = 70\n```\n\nThen apply:\n\n```bash\nterraform apply -var-file=env.tfvars\n```\n\n## PostgreSQL Flex target option\n\nSet the following values in `env.tfvars` to enable a managed database target:\n\n```hcl\nenable_postgres_flex          = true\npostgres_flex_instance_name   = \"cmf-rpltf-postgres\"\npostgres_flex_app_username    = \"springmusic\"\npostgres_flex_target_database = \"postgres\"\npostgres_flex_target_app_acl_cidrs = [\"203.0.113.10/32\"]\n```\n\nWhen enabled, Terraform creates PostgreSQL Flex (`stackit_postgresflex_instance` and `stackit_postgresflex_user`) and injects datasource settings into the Spring Boot deployment.\n\nACL is intentionally strict by default: only CIDRs in `postgres_flex_target_app_acl_cidrs` (or legacy `postgres_flex_acl`) are allowed.\n\nIf `enable_observability_alerts = true` and PostgreSQL Flex metrics scraping is enabled,\nthe baseline alert group also includes PostgreSQL-focused alerts for exporter availability,\nconnection saturation, cache-hit ratio, and temp file usage.\n\n## VM PostgreSQL to PostgreSQL Flex migration job\n\nTo migrate source data from the VM-based PostgreSQL (for example from the Rehost setup), enable:\n\n```hcl\nenable_postgres_flex         = true\ndeploy_postgres_migration_job = true\nsource_postgres_host          = \"\u003crehost-vm-ip-or-dns\u003e\"\nsource_postgres_port          = 5432\nsource_postgres_database      = \"springmusic\"\nsource_postgres_username      = \"springmusic\"\nsource_postgres_password      = \"\u003csource-password\u003e\"\ninclude_source_postgres_host_in_temp_acl = true\n```\n\nThe migration job runs a `pg_dump` from source and restores the dump into PostgreSQL Flex using `pg_restore`.\n\nIf migration is executed from a source-side client that must connect directly to PostgreSQL Flex,\ntemporarily add its CIDR via `postgres_flex_temp_migration_acl_cidrs`.\nTerraform output `postgres_flex_source_host_acl_suggestion` provides `source_postgres_host/32` when source host is an IPv4 address.\n\nAfter migration, remove temporary migration CIDRs and apply again.\n\n## 2) Deploy\n\n```bash\nterraform init\nterraform validate\nterraform plan -var-file=env.tfvars\nterraform apply -var-file=env.tfvars\n```\n\n## 3) Verify workload\n\n```bash\nmkdir -p .tmp\nterraform output -raw kubeconfig \u003e .tmp/replatform.kubeconfig\nexport KUBECONFIG=$PWD/.tmp/replatform.kubeconfig\nkubectl get ns\nkubectl get deploy,svc -n springboot\nkubectl get pods -n springboot\n```\n\n## 4) Verify metrics path\n\n```bash\nHOST=$(terraform output -raw springboot_hostname)\ncurl -sS \"http://$HOST:9090/metrics\" | head -n 30\n```\n\nExpected: lines beginning with `springboot_legacy_counter`, `springboot_legacy_gauge`, `springboot_legacy_metric`.\n\n## 5) Verify outputs\n\n```bash\nterraform output\n```\n\nImportant outputs:\n\n- `springboot_url`\n- `springboot_hostname`\n- `observability_grafana_url`\n- `project_id`\n- `postgres_flex_host`\n- `postgres_flex_jdbc_url`\n- `postgres_flex_effective_acl_cidrs`\n- `postgres_flex_source_host_acl_suggestion`\n\n## Troubleshooting\n\n- If `metrics-exporter` restarts, inspect logs:\n\n```bash\nPOD=$(kubectl get pod -n springboot -l app=springboot -o jsonpath='{.items[0].metadata.name}')\nkubectl logs -n springboot \"$POD\" -c metrics-exporter --tail=200\nkubectl logs -n springboot \"$POD\" -c metrics-exporter --previous --tail=200\n```\n\n- If scrape exists but no data arrives, check target health in Prometheus/Grafana datasource (`up{job=\"\u003cscrape-job\u003e\"}`).\n- Scrape interval must be greater than `60s` for this environment (`61s` is set by default).\n\n## Destroy\n\n```bash\nterraform destroy -var-file=env.tfvars\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstackitcloud%2Fstackit-cmf-replatform-springboot-k8s","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstackitcloud%2Fstackit-cmf-replatform-springboot-k8s","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstackitcloud%2Fstackit-cmf-replatform-springboot-k8s/lists"}