Skip to content

CH-256 feat: add PostgreSQL operator support#841

Open
filippomc wants to merge 8 commits intodevelopfrom
feature/CH-256-postgres-operator
Open

CH-256 feat: add PostgreSQL operator support#841
filippomc wants to merge 8 commits intodevelopfrom
feature/CH-256-postgres-operator

Conversation

@filippomc
Copy link
Collaborator

@filippomc filippomc commented Mar 19, 2026

Closes CH-256

Implemented solution

Added a new option postgres.operator that 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:

harness:
    postgres:
      instances: 2
      operator: true

Sanity checks:

  • The pull request is explicitly linked to the relevant issue(s)
  • The issue is well described: clearly states the problem and the general proposed solution(s)
  • In this PR it is explicitly stated how to test the current change
  • The labels in the issue set the scope and the type of issue (bug, feature, etc.)
  • The relevant components are indicated in the issue (if any)
  • All the automated test checks are passing
  • All the linked issues are included in one Sprint
  • All the linked issues are in the Review state
  • All the linked issues are assigned

Breaking changes (select one):

  • The present changes do not change the preexisting api in any way
  • This PR and the issue are tagged as a breaking-change and the migration procedure is well described above

Possible deployment updates issues (select one):

  • There is no reason why deployments based on CloudHarness may break after the current update
  • This PR and the issue are tagged as alert:deployment

Test coverage (select one):

  • Tests for the relevant cases are included in this pr
  • The changes included in this pr are out of the current test coverage scope

Documentation (select one):

  • The documentation has been updated to match the current changes
  • The changes included in this PR are out of the current documentation scope

Nice to have (if relevant):

  • Screenshots of the changes
  • Explanatory video/animated gif

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 with operator, instances, and initialdb fields for Postgres.
  • Add Helm templating for CNPG-backed Postgres deployment (Cluster, credentials Secret, and Service) and conditional switching from the legacy Deployment path.
  • 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" . }}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

another PR will address backups

Comment on lines +123 to +127
- ipBlock:
cidr: 0.0.0.0/0
ports:
- port: 443
protocol: TCP
filippomc and others added 7 commits March 19, 2026 11:34
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants