CH-256 feat: add PostgreSQL operator support#841
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds CloudNative-PG (CNPG) operator support as an alternative way to deploy Postgres databases via CloudHarness configuration, and wires the new options through the models, OpenAPI schema, Helm templates, and documentation.
Changes:
- Extend
DatabaseConfig/ OpenAPI schema withoperator,instances, andinitialdbfields for Postgres. - Add Helm templating for CNPG-backed Postgres deployment (
Cluster, credentialsSecret, andService) and conditional switching from the legacyDeploymentpath. - Update docs and example values to describe/use the new operator options.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| libraries/models/docs/DatabaseConfig.md | Documents new Postgres operator-related fields in model docs. |
| libraries/models/cloudharness_model/models/user.py | Regenerated model file (import/docstring formatting changes). |
| libraries/models/cloudharness_model/models/database_config.py | Adds operator, instances, initialdb fields to the Pydantic model. |
| libraries/models/api/openapi.yaml | Adds the new fields to the DatabaseConfig schema. |
| docs/model/DatabaseConfig.md | Mirrors model doc updates for the generated docs site. |
| docs/applications/databases.md | Documents the new operator/instances Postgres options and CNPG installation snippet. |
| deployment/codefresh-test.yaml | Adjusts Codefresh build/test steps (e.g., samples build Dockerfile and API test ordering). |
| deployment-configuration/value-template.yaml | Adds default operator/instances values to the Postgres values template. |
| deployment-configuration/helm/templates/auto-network-policies.yaml | Adds a conditional egress exception when CNPG operator mode is enabled. |
| deployment-configuration/helm/templates/auto-database.yaml | Switches Postgres auto-db rendering between legacy Deployment vs CNPG operator template. |
| deployment-configuration/helm/templates/auto-database-postgres-operator.yaml | New CNPG operator template (Secret + CNPG Cluster + Service). |
You can also share your feedback on Copilot code review. Take the survey.
| {{- end }} | ||
| {{- define "deploy_utils.database" }} | ||
| {{- if and (eq .app.harness.database.type "postgres") .app.harness.database.postgres.operator }} | ||
| {{- include "deploy_utils.database.postgres.operator" . }} |
Collaborator
Author
There was a problem hiding this comment.
another PR will address backups
Comment on lines
+123
to
+127
| - ipBlock: | ||
| cidr: 0.0.0.0/0 | ||
| ports: | ||
| - port: 443 | ||
| protocol: TCP |
deployment-configuration/helm/templates/auto-network-policies.yaml
Outdated
Show resolved
Hide resolved
deployment-configuration/helm/templates/auto-database-postgres-operator.yaml
Show resolved
Hide resolved
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
"deploy_utils.database_network_policy" (dict "root" .root "app" .app)>: error calling include: template: mnp/templates/auto-network-policies.yaml:125:46: executing "deploy_utils.database_network_policy" at <$kubeSvc.spec.clusterIP>: nil pointer evaluating interface {}.clusterIP
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes CH-256
Implemented solution
Added a new option
postgres.operatorthat activates the operator https://github.com/cloudnative-pg/cloudnative-pg in place of the usual basic deployment. Can set the number of instances, everything else stays the same.All other parameters such as username, password and initialdb are preserved, so the db with postgres operator can be activated on existing applications seamlessly.
How to test this PR
Deploy application with configuration as:
Sanity checks:
Breaking changes (select one):
breaking-changeand the migration procedure is well described abovePossible deployment updates issues (select one):
alert:deploymentTest coverage (select one):
Documentation (select one):
Nice to have (if relevant):