generated from NCAR/rda-python-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Update readme #43
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
Open
NicholasCote
wants to merge
4
commits into
main
Choose a base branch
from
ncote-readme-details
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Update readme #43
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
ab91d74
Add readme with details on cnpg postgres clusters, rebuilding, and ot…
NicholasCote b9a223b
Fix some things copilot called out
NicholasCote 5c3676b
Add working alert configuration
NicholasCote b9daa5e
Increase email timing to 1 hr and ensure team name is the same across…
NicholasCote File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,70 @@ | ||
| RDA python Package to manage RDA PostgreSQL databases. | ||
| # RDA PostgreSQL Management | ||
|
|
||
| This repository contains: | ||
|
|
||
| - Python package to manage RDA PostgreSQL databases | ||
| - Helm charts for PostgreSQL clusters via CloudNativePG | ||
|
|
||
| ## PostgreSQL Clusters | ||
|
|
||
| ### Architecture | ||
| - **pgdb01** (NWSC cluster): Primary database | ||
| - **pgdb02** (ML cluster): Replication target (streaming replica from pgdb01) | ||
| - **pgdb03** (ML cluster) | ||
|
|
||
| All Postgres clusters are managed via the [CloudNativePG operator](https://cloudnative-pg.io/) using Helm charts from `https://cloudnative-pg.github.io/charts`. | ||
|
|
||
| ### Deployment | ||
| All PostgreSQL resources are automatically deployed and updated via **ArgoCD**. To make changes: | ||
|
|
||
| 1. Update the relevant YAML files in this repository | ||
| 2. Commit and push changes | ||
| 3. ArgoCD will automatically apply the updates to the clusters | ||
|
|
||
| No manual `kubectl apply` or Helm commands are needed for routine updates. | ||
|
|
||
| ### Rebuilding Replication (pgdb02) | ||
|
|
||
| If replication fails or pgdb02 becomes out of sync with pgdb01, you can rebuild it by deleting the cluster resource. The cluster will automatically re-bootstrap from pgdb01 via `pg_basebackup`. | ||
|
|
||
| **Note:** Make sure you are targeting the right database before running any of these commands. | ||
|
|
||
| **Option 1: Via ArgoCD UI** | ||
| 1. Navigate to the pgdb02 application in [ArgoCD](https://mlc1-argo.k8s.ucar.edu/applications/argocd/rda-pgdb02?view=tree&resource=) | ||
| 2. Find the `Cluster` resource named `pgdb02` | ||
| 3. Delete the resource | ||
| 4. Click "Sync" to recreate it | ||
| 5. Monitor the logs in ArgoCD | ||
|
|
||
| **Option 2: Via kubectl** | ||
| ```bash | ||
| # Delete the cluster | ||
| kubectl delete cluster pgdb02 -n rda --context mlc1 | ||
|
|
||
| # ArgoCD will automatically recreate it on the next sync | ||
| # Or manually sync in the ArgoCD UI | ||
| ``` | ||
|
|
||
| **Monitoring rebuild progress:** | ||
| ```bash | ||
| # Watch cluster status | ||
| kubectl get cluster pgdb02 -n rda --context mlc1 -w | ||
|
|
||
| # Get the pg_basebackup pod name (it will have a random suffix) | ||
| kubectl get pods -n rda --context mlc1 | grep pgbasebackup | ||
|
|
||
| # View pg_basebackup logs (replace with actual pod name from above) | ||
| kubectl logs -n rda pgdb02-1-pgbasebackup-xxxxx -f --context mlc1 | ||
|
|
||
| # Check PVC size growth | ||
| kubectl get pvc -n rda --context mlc1 | grep pgdb02 | ||
|
|
||
| # Watch PVC size in real-time | ||
| watch -n 5 'kubectl get pvc -n rda --context mlc1 | grep pgdb02' | ||
| ``` | ||
|
|
||
| The rebuild process typically takes several hours depending on database size. The pg_basebackup job runs in a pod with a name like `pgdb02-1-pgbasebackup-xxxxx` (where `xxxxx` is a random suffix). Once the backup completes, the main `pgdb02-1` pod will start and the cluster status will show as "Cluster in healthy state". | ||
|
|
||
| ### Important Notes | ||
| - **Version Compatibility**: pgdb02 must use the same PostgreSQL major version as pgdb01. Currently both run `ghcr.io/cloudnative-pg/postgresql:17.4` | ||
| - **Data Loss**: Deleting and rebuilding pgdb02 will resync all data from pgdb01. This is safe for the replica but takes time. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| apiVersion: monitoring.coreos.com/v1alpha1 | ||
| kind: AlertmanagerConfig | ||
| metadata: | ||
| name: gdex-app-team | ||
| namespace: rda | ||
| labels: | ||
| alertmanagerConfig: gdex | ||
| namespace: rda | ||
| spec: | ||
| route: | ||
| receiver: gdex-app-team | ||
| groupBy: | ||
| - alertname | ||
| groupWait: 10s | ||
| groupInterval: 1m | ||
| repeatInterval: 60m | ||
| matchers: | ||
| - name: namespace | ||
| value: rda | ||
| matchType: "=" | ||
|
|
||
| receivers: | ||
| - name: gdex-app-team | ||
| emailConfigs: | ||
| - to: decs-info@ucar.edu | ||
| from: alertmanager@k8s.ucar.edu | ||
| smarthost: vdir.ucar.edu:25 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.