From 8f34e2659fbd122dc583f50dd887ec2314d3623f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Grzegorz=20Burzy=C5=84ski?= Date: Wed, 31 May 2023 19:39:14 +0200 Subject: [PATCH] feat: all-in-one manifests migrations job improvement (#4116) kong migrations bootstrap alone works fine when installing a fresh instance of KIC with DB-backed Kong. It doesn't work though when we'd like to upgrade and keep the DB state between the upgrades, because it only bootstraps a fresh database - when there is one already in existence, it just returns. This PR aims to solve this issue by adding additional commands to the migrations job: kong migrations up && kong migrations finish which will make the job detect new migrations that need to be run after the upgrade and finish them. --- CHANGELOG.md | 5 +++++ config/variants/postgres/migration.yaml | 2 +- deploy/single/all-in-one-postgres-enterprise.yaml | 2 +- deploy/single/all-in-one-postgres.yaml | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5746204565..d151f93eb9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -160,6 +160,11 @@ Adding a new version? You'll need three changes: - Gateway's `AttachedRoutes` fields get updated with the number of routes referencing and using each listener. [#4052](https://github.com/Kong/kubernetes-ingress-controller/pull/4052) +- `all-in-one-postgres.yaml` and `all-in-one-postgres-enterprise.yaml` manifests' + migrations job now works properly when running against an already bootstrapped + database, allowing upgrades from one version of Kong Gateway to another without + tearing down the database. + [#4116](https://github.com/Kong/kubernetes-ingress-controller/pull/4116) ### Changed diff --git a/config/variants/postgres/migration.yaml b/config/variants/postgres/migration.yaml index 5d1731099d..e7cbc0d467 100644 --- a/config/variants/postgres/migration.yaml +++ b/config/variants/postgres/migration.yaml @@ -28,5 +28,5 @@ spec: value: postgres - name: KONG_PG_PORT value: "5432" - command: [ "/bin/bash", "-c", "kong migrations bootstrap" ] + command: [ "/bin/bash", "-c", "kong migrations bootstrap && kong migrations up && kong migrations finish" ] restartPolicy: OnFailure diff --git a/deploy/single/all-in-one-postgres-enterprise.yaml b/deploy/single/all-in-one-postgres-enterprise.yaml index ec4815de1f..6988cdfef1 100644 --- a/deploy/single/all-in-one-postgres-enterprise.yaml +++ b/deploy/single/all-in-one-postgres-enterprise.yaml @@ -1923,7 +1923,7 @@ spec: - command: - /bin/bash - -c - - kong migrations bootstrap + - kong migrations bootstrap && kong migrations up && kong migrations finish env: - name: KONG_LICENSE_DATA valueFrom: diff --git a/deploy/single/all-in-one-postgres.yaml b/deploy/single/all-in-one-postgres.yaml index ac40449c38..56fd423258 100644 --- a/deploy/single/all-in-one-postgres.yaml +++ b/deploy/single/all-in-one-postgres.yaml @@ -1860,7 +1860,7 @@ spec: - command: - /bin/bash - -c - - kong migrations bootstrap + - kong migrations bootstrap && kong migrations up && kong migrations finish env: - name: KONG_PG_PASSWORD value: kong