Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate from Cassandra to PostgreSQL #5885

Merged
merged 8 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added app/_assets/images/docs/gateway/migration.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
---
title: Migration guidelines: Cassandra to Postgres
Guaris marked this conversation as resolved.
Show resolved Hide resolved
---

The purpose of this document is to provide an approach aimed at migrating Cassandra db backed Kong deployment to Postgresql backed Kong deployment. This document will guide migration from traditional Kong deployment topology to hybrid.
lena-larionova marked this conversation as resolved.
Show resolved Hide resolved
Guaris marked this conversation as resolved.
Show resolved Hide resolved

A Blue/Green migration approach is proposed in this document. To achieve the easiest possible migration, declarative tools Kong [DecK](https://docs.konghq.com/deck/latest/) will be utilized. DNS switching will be used to cut traffic over from a Blue environment to a Green environment. This will provide the ability to rollback faster if an issue is detected.
lena-larionova marked this conversation as resolved.
Show resolved Hide resolved
Guaris marked this conversation as resolved.
Show resolved Hide resolved

The steps to migrate, at a high level are:
Guaris marked this conversation as resolved.
Show resolved Hide resolved

* New target Kong environment will be built as a blank canvas with Postgresql db with hybrid deployment.
lena-larionova marked this conversation as resolved.
Show resolved Hide resolved
Guaris marked this conversation as resolved.
Show resolved Hide resolved
* Kong deck is used to take export (dump) from old traditional cassandra backed Kong deployment.
lena-larionova marked this conversation as resolved.
Show resolved Hide resolved
Guaris marked this conversation as resolved.
Show resolved Hide resolved
* Kong deck is used to import (sync) to new hybrid postgresql backed Kong deployment.
lena-larionova marked this conversation as resolved.
Show resolved Hide resolved
Guaris marked this conversation as resolved.
Show resolved Hide resolved
* Basic auth credentials and local rbac users will need to be created separately either using admin api or manually(Kong Manager).
Guaris marked this conversation as resolved.
Show resolved Hide resolved
* When the Kong configuration has been migrated over to the green environment, traffic can be slowly canaried into the green environment to de-risk the release with a fast rollback mechanism in place.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [vale] reported by reviewdog 🐶
[kong.Spelling] Did you really mean 'canaried'?

Guaris marked this conversation as resolved.
Show resolved Hide resolved


### Considerations
Guaris marked this conversation as resolved.
Show resolved Hide resolved

While the document provides high level guidelines, actual migration steps may differ based on the following factors:
* complexity of the Kong deployment environment
* Kong plugins used
* Usage of custom plugins
* External touchpoints to the Gateway (e.g. OIDC)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [vale] reported by reviewdog 🐶
[kong.Spelling] Did you really mean 'touchpoints'?

Guaris marked this conversation as resolved.
Show resolved Hide resolved
* number of configuration entities - e.g. services and routes
Guaris marked this conversation as resolved.
Show resolved Hide resolved
* If running an older version of Kong it is recommended to do a Kong version upgrade before the database migration (To reduce the moving parts in the upgrade procedure)
Guaris marked this conversation as resolved.
Show resolved Hide resolved
* Using cassandra means may not be using the Kong Hybrid Mode deployment and might be deployed in the traditional mode, we recommend taking this opportunity to review the architecture to leverage the latest features of Kong Enterprise.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [vale] reported by reviewdog 🐶
[kong.Spelling] Did you really mean 'cassandra'?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [vale] reported by reviewdog 🐶
[kong.We] Try to avoid using first-person plural like 'we'.

Guaris marked this conversation as resolved.
Show resolved Hide resolved

While the diagram shows the split between the Kong control and Data planes, the same approach can be followed for Kong instances deployed in Classic Mode.
Guaris marked this conversation as resolved.
Show resolved Hide resolved

![migration image](_assets/images/docs/gateway/migration.png)
Guaris marked this conversation as resolved.
Show resolved Hide resolved


### Assumptions
The Kong blue environment (Using Cassandra) and green environment (using Postgres) are running the same Kong Enterprise version
Blue is deployed in traditional mode and green environment is running with Kong deployed in a hybrid deployment mode.
Guaris marked this conversation as resolved.
Show resolved Hide resolved


## Migration Approach
Guaris marked this conversation as resolved.
Show resolved Hide resolved
The following steps should be tested in a non-production environment. Any gaps in the target state should be identified and remediated before running it in production.

| Step | Name | Description | Completed |
|------|--------------------|-------------------------------------------------------------------------------------------------------|-----------|
| 1 | Platform build | The Green environment is built with Kong Enterprise setup using the same version as the Blue environment | |
Guaris marked this conversation as resolved.
Show resolved Hide resolved
| 2 | Database setup | A new Postgres DB is built and connected to the green environment | |
Guaris marked this conversation as resolved.
Show resolved Hide resolved
| 3 | Regression Testing | A deployment is made into the new system and regression tested. The deployment is cleaned up when testing is completed | |
Guaris marked this conversation as resolved.
Show resolved Hide resolved


## Preperation
Guaris marked this conversation as resolved.
Show resolved Hide resolved
Guaris marked this conversation as resolved.
Show resolved Hide resolved



| Step | Name | Description | Completed |
|------|-------------------------------|-------------------------------------------------------------------------------------------------------------|-----------|
| 1 | Change embargo | A change embargo is placed on the environment preventing new deployments or configuration changes | |
Guaris marked this conversation as resolved.
Show resolved Hide resolved
| 2 | Blue environment backup | A backup is taken on the blue environment's Cassandra database and placed into redundant storage | |
Guaris marked this conversation as resolved.
Show resolved Hide resolved
| 3 | Observability setup | Dashboards are created to track the health of the new environment | |
Guaris marked this conversation as resolved.
Show resolved Hide resolved
| 4 | Go/No go checkpoint | Go/No go decision point for the migration execution | |
Guaris marked this conversation as resolved.
Show resolved Hide resolved



## Execution

The goal of this phase is to reproduce the Kong configuration in the blue environment and perform regression/smoke testing ahead of live traffic cut-over.
Guaris marked this conversation as resolved.
Show resolved Hide resolved


| Step | Name | Description | Completed |
|------|-----------------------|-----------------------------------------------------------------------------------------------------------------------|-----------|
| 1 | Configuration dump | - Execute the "deck dump" command against the blue environment, for each workspace to build a YAML representation of the Kong estate<br>- Execute "deck dump --rbac-resources-only" against the blue environment for each workspace to build a YAML representation of any RBAC resources created<br>- If using the Kong Developer Portal, run the "portal fetch" command to build a representation of the Dev Portal Assets for a workspace | |
Guaris marked this conversation as resolved.
Show resolved Hide resolved
Guaris marked this conversation as resolved.
Show resolved Hide resolved
| 2 | Configuration sync | - Change decK to work with the green environment, and execute "deck sync" to push the configuration to the green environment<br>- Change Portal CLI to work against the green environment, and execute "portal deploy" to push the Dev Portal configuration against the new environment | |
Guaris marked this conversation as resolved.
Show resolved Hide resolved
| 3 | Regression Testing | Execute regression tests against the green environment backed by PostGres | |
Guaris marked this conversation as resolved.
Show resolved Hide resolved
Guaris marked this conversation as resolved.
Show resolved Hide resolved
| 4 | Go/No go checkpoint | If all tests pass proceed with traffic cutover | |
Guaris marked this conversation as resolved.
Show resolved Hide resolved
Guaris marked this conversation as resolved.
Show resolved Hide resolved


## Traffic cutover
Guaris marked this conversation as resolved.
Show resolved Hide resolved

The purpose of this phase is to migrate traffic in a controlled manner, with a rapid fall back mechanism if a problem is detected. The wait times before increasing the canary split can be increased/decreased depending on risk appetite.
Guaris marked this conversation as resolved.
Show resolved Hide resolved


| Step | Name | Description | Completed |
|------|-------------------------|---------------------------------------|-----------|
| 1 | Canary 1% of traffic to the new green environment | Canary 1% of traffic to the new environment and monitor the traffic health. | |
| 2 | Canary 5% of traffic to the new green environment | Increase traffic split to 5% and monitor. | |
| 3 | Canary 10% of traffic to the new green environment | Increase traffic split to 10% and monitor. | |
| 4 | Canary 50% of traffic to the new green environment | Increase traffic split to 50% and monitor. | |
| 5 | Switch 100% of traffic to the new green environment | Perform a full DNS switch over to point to the new green environment. | |
| 6 | Demise old platform | After 24 hours when confidence is high, demise of the old platform. | |
Guaris marked this conversation as resolved.
Show resolved Hide resolved




## Limitations
Guaris marked this conversation as resolved.
Show resolved Hide resolved


* If basic auth plugin is used, the passwords are hashed and encrypted in the database which a decK dump will not export and it is impossible to get the passwords out of the database in the cleartext. Migrating these credentials will have to be performed using admin api or Kong Manager.
Guaris marked this conversation as resolved.
Show resolved Hide resolved

* Admin users on the Kong management plane are not propagated using DecK, and will have to be done using the Kong Admin API
Guaris marked this conversation as resolved.
Show resolved Hide resolved




Going forward, the basic authentication credentials can be managed through the Kong deck. See below document to integrate with GCP secrets and secrets management with deck.
Guaris marked this conversation as resolved.
Show resolved Hide resolved

[Gateway secret management GCP](/gateway/latest/kong-enterprise/secrets-management/backends/gcp-sm/#main)
[Secrets Management with Deck](/deck/latest/guides/vaults/#configure-a-secret-vault)