Skip to content

Commit 71704c2

Browse files
committed
Migrate wg-ci Concourse to us-east1
* and update Postgres to v16.9 * improve migration documentation (in particular, the "concourse" db restore procedure) * update Terraform/Tofu provider file
1 parent 6ea536f commit 71704c2

File tree

5 files changed

+66
-39
lines changed

5 files changed

+66
-39
lines changed

docs/concourse/certificate_regeneration.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ certificates_to_regenerate: "/concourse/main/cert_1,/concourse/main/cert_2"
1717

1818
Next, change to the directory `terragrunt/<concourse-instance>/automatic_certificate_regeneration` and call
1919
```
20-
terragrunt apply --terragrunt-config cert_regen.hcl
20+
terragrunt apply --config=cert_regen.hcl
2121
```
2222
You should see that Terraform creates a new resource:
2323
```
@@ -65,5 +65,5 @@ The (self-signed) CA would be regenerated first and then the two certificates wo
6565

6666
To delete the CronJob, change to the directory `terragrunt/<concourse-instance>/automatic_certificate_regeneration` and call
6767
```
68-
terragrunt destroy --terragrunt-config cert_regen.hcl
68+
terragrunt destroy --config=cert_regen.hcl
6969
```

docs/concourse/region_change.md

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ For cost saving reasons, you can migrate the Concourse deployment to a different
33

44
## Prerequisites
55
- Access to the GCP account and the GKE cluster in the current region.
6+
- You have the "Owner" role in the GCP project ("Editor" is not sufficient).
67
- "pg_dump" v16 is installed on the local machine.
78

89
## Backup Secrets and Databases
@@ -30,7 +31,7 @@ For cost saving reasons, you can migrate the Concourse deployment to a different
3031
```
3132
Copy the file from the pod to the local machine:
3233
```bash
33-
kubectl -n concourse cp credhub-cli-<id>:/credhub_backup.json credhub_backup.json
34+
kubectl -n default cp credhub-cli-<id>:/go/credhub_backup.json credhub_backup.json
3435
```
3536
:warning: The file `credhub_backup.json` contains sensitive data in plaintext, so handle it with care and delete it after the migration.
3637

@@ -59,6 +60,11 @@ For cost saving reasons, you can migrate the Concourse deployment to a different
5960
```yaml
6061
gke_controlplane_version: "1.31"
6162
```
63+
1. Revert the changes in the Terraform files:
64+
- In `terraform-modules/concourse/dr_create/credhub_encryption_key.tf`, uncomment the "lifecycle" block.
65+
- Uncomment module "assertion_encryption_key_identical" (if you commented it before).
66+
- In `terraform-modules/concourse/infra/database.tf`, set `deletion_protection` and `deletion_protection_enabled` to `true`.
67+
- In `terraform-modules/concourse/infra/gke_cluster.tf`, remove `deletion_protection = false`.
6268
1. Now you can check the Terraform plan:
6369
```bash
6470
terragrunt run-all plan
@@ -68,20 +74,43 @@ For cost saving reasons, you can migrate the Concourse deployment to a different
6874
```bash
6975
terragrunt run-all apply
7076
```
71-
1. To make the "e2e_test" pass, you must log on with the fly CLI and run the "apply" step again:
77+
1. Only for wg-ci-test: To make the "e2e_test" pass, you must log on with the fly CLI and run the "apply" step again:
7278
```bash
7379
fly -t wg-ci-test login -c https://concourse-test.app-runtime-interfaces.ci.cloudfoundry.org
7480
```
81+
1. Refresh your `kubectl` context to the new region:
82+
```bash
83+
gcloud container clusters get-credentials wg-ci[-test] --region us-east1-b
84+
```
7585
1. Log on to CredHub with the [start-credhub-cli.sh](../../terragrunt/scripts/concourse/start-credhub-cli.sh) script. Copy the credential backup file from to the pod:
7686
```bash
77-
kubectl -n concourse cp credhub_backup.json credhub-cli-<id>:/credhub_backup.json
87+
kubectl -n default cp credhub_backup.json credhub-cli-<id>:/go/credhub_backup.json
7888
```
7989
Then import all data:
8090
```bash
8191
credhub import -j -f credhub_backup.json
8292
```
8393
1. Restart the Cloud SQL Auth Proxy with the new "Connection name".
94+
1. Stop the "web" pod:
95+
```bash
96+
kubectl -n concourse scale deployment concourse-web --replicas=0
97+
```
98+
1. Retrieve the new database password:
99+
```bash
100+
kubectl -n concourse get secret concourse-postgresql-password -o yaml | yq -r .data.password | base64 -d
101+
```
102+
1. Drop the existing "concourse" database:
103+
```bash
104+
psql -h 127.0.0.1 -p 5432 -U concourse -d postgres
105+
DROP DATABASE concourse;
106+
CREATE DATABASE concourse;
107+
```
84108
1. Restore the Concourse database from the backup:
85109
```bash
86110
psql -h 127.0.0.1 -p 5432 -U concourse -d concourse -f concourse_backup.sql
87-
```
111+
```
112+
There should be no errors like "relation already exists" or constraint violations.
113+
1. Restart the "web" pod:
114+
```bash
115+
kubectl -n concourse scale deployment concourse-web --replicas=1
116+
```

terragrunt/concourse-wg-ci/automatic_certificate_regeneration/.terraform.lock.hcl

Lines changed: 25 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

terragrunt/concourse-wg-ci/config.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
project: app-runtime-interfaces-wg
2-
region: europe-west3
3-
zone: europe-west3-a
4-
secondary_zone: europe-west3-b
2+
region: us-east1
3+
zone: us-east1-b
4+
secondary_zone: us-east1-c
55

66
# gcs_prefix builds root folder for tf state for the entire stack
77
gcs_bucket: terraform-wg-ci
@@ -46,12 +46,13 @@ tf_modules:
4646
# In most cases settings below are safe to keep as defaults
4747
# ---------------------------------------------------------
4848
# SQL
49+
database_version: "POSTGRES_16"
4950
sql_instance_tier: db-custom-1-4096
5051
sql_instance_backup_location: eu
5152
sql_instance_disk_size: 38
5253

5354
# Other GKE vars
54-
gke_controlplane_version: 1.27.8-gke.1067004
55+
gke_controlplane_version: "1.31"
5556
gke_cluster_ipv4_cidr: 10.104.0.0/14
5657
gke_services_ipv4_cidr_block: 10.108.0.0/20
5758
gke_master_ipv4_cidr_block: 172.16.0.32/28

terragrunt/concourse-wg-ci/infra/terragrunt.hcl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ inputs = {
5050

5151
gke_http_load_balancing_disabled = local.config.gke_http_load_balancing_disabled
5252

53+
database_version = local.config.database_version
5354
sql_instance_name = "${local.config.gke_name}-concourse"
5455
sql_instance_tier = local.config.sql_instance_tier
5556
sql_instance_disk_size = local.config.sql_instance_disk_size

0 commit comments

Comments
 (0)