Skip to content

Users/hpn/implement postg rest auto api template#65

Merged
NgocAnhDo26 merged 10 commits into
features/sprint4-backend-templates-db-injectionfrom
users/hpn/implement-PostgREST-auto-api-template
Apr 12, 2026
Merged

Users/hpn/implement postg rest auto api template#65
NgocAnhDo26 merged 10 commits into
features/sprint4-backend-templates-db-injectionfrom
users/hpn/implement-PostgREST-auto-api-template

Conversation

@nghiaz160904
Copy link
Copy Markdown
Collaborator

Overview

Adds a Backstage scaffolding template for PostgREST, enabling developers to quickly provision instant REST APIs connected to PostgreSQL databases without writing backend code.

What's Implemented

Template Features:

  • Scaffolds PostgREST configuration on Backstage
  • Uses official postgrest/postgrest Docker image
  • Generates two Git repositories:
    • Source Repo: PostgREST configuration + Dockerfile + CI/CD setup
    • GitOps Repo: HeliosApp manifest + Tekton pipelines + ArgoCD sync

Key Capabilities:

  • Configurable API schema, JWT authentication, and access roles
  • Automatic PostgreSQL database provisioning via Helios Operator
  • Environment variable injection for database credentials (PGRST_DB_URI)
  • Tekton CI/CD pipeline for automated builds
  • ArgoCD GitOps synchronization
  • Ingress-based REST API exposure

Files Added

  • apps/portal/examples/postgrest-template/template.yaml - Backstage scaffolder template
  • apps/portal/examples/postgrest-template/content/source/ - PostgREST config templates (Dockerfile, postgrestrc.conf, etc.)
  • apps/portal/examples/postgrest-template/content/gitops/ - Kubernetes manifests (HeliosApp, pipeline, triggers, ArgoCD)
  • Documentation: README, QUICKSTART, REGISTRATION, OPERATORS, TESTING, OPERATOR_INTEGRATION, CHECKLIST, REPO_STRUCTURE

How It Works

  1. User scaffolds component on Backstage portal
  2. Provides: service name, port, API schema, JWT config, database settings, Git repo
  3. Template generates two repositories with all configuration
  4. Operator provisions PostgreSQL database and injects credentials as Secret
  5. PostgREST container starts and exposes REST API automatically

User Experience

Users can now:

# Navigate to Backstage Create page
# Select "PostgREST API Template"
# Fill in configuration
# → Instant REST API deployed to cluster

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 9, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 636683e3-a5e0-4ac3-a129-78ec025d38de

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch users/hpn/implement-PostgREST-auto-api-template

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@nghiaz160904 nghiaz160904 linked an issue Apr 9, 2026 that may be closed by this pull request
4 tasks
@PhuocHoan
Copy link
Copy Markdown
Collaborator

Thanks for the solid progress on PostgREST template + DB URI injection. I don’t think this is ready to merge yet due to a few blocking issues.

Required fixes before merge

  1. Fix broken values mapping in template

  2. Fix invalid Backstage catalog schema field

  3. Respect selected namespace for webhook

  4. Align PGRST_DB_URI reference with operator injection contract

  5. Fix validation script reliability

Quality improvements (recommended)

  1. Build DB URI using structured URL handling to avoid edge-case formatting bugs (IPv6/userinfo escaping), and update tests accordingly.
  2. Add a small template render test/smoke check in CI to catch malformed values mappings early.

Once the above is addressed, this should be in much better shape for merge.

@NgocAnhDo26
Copy link
Copy Markdown
Contributor

The yaml files inside gitops folder, except for helios-app.yml are redundant, consider removing them.
They should be defined (or they are already defined) using CUE. They will be auto-generated by the Operator and will be pushed to the GitOps repo.

@NgocAnhDo26
Copy link
Copy Markdown
Contributor

NgocAnhDo26 commented Apr 12, 2026

On second thought, we also need to establish a dedicated pipeline that handles database migrations and subsequently triggers a PostgREST schema reload.
This ensures the API immediately reflects the latest database changes without necessarily rebuilding images.

Here are some of my suggestions to achieve this:

Standardize the Migration Tool:

Implement a Schema Reload Mechanism:

  • Ensure the pipeline includes a dedicated step to reload the PostgREST schema cache immediately after migrations are applied.
  • Use the psql command NOTIFY pgrst, 'reload schema'; as the primary reload method. It is much cleaner and maintains better availability than triggering a full Kubernetes rollout restart.

Update Tekton Pipeline Configurations:

  • Create a new CUE pipeline definition specifically for this database workflow.
  • Structure the pipeline tasks sequentially as: git-clone → migrate → reload-postgrest. Register this new pipeline in the CUE #PipelineRegistry.
  • Configure a trigger mechanism, such as a manual PipelineRun for controlled migrations or a scoped EventListener that only fires on changes to the db/** path.

Address Secrets and Networking:

  • Ensure the new Tekton task pod has the necessary access to the database to run the migrations.
  • Explicitly mount or project the existing database Kubernetes Secret into the migration task pod so it can successfully resolve the DATABASE_URL.

@PhuocHoan PhuocHoan force-pushed the users/hpn/implement-PostgREST-auto-api-template branch from f7aeef5 to 4f2d8d7 Compare April 12, 2026 11:21
@nghiaz160904 nghiaz160904 force-pushed the users/hpn/implement-PostgREST-auto-api-template branch from 4f2d8d7 to b2e45e5 Compare April 12, 2026 16:04
@NgocAnhDo26 NgocAnhDo26 merged commit f67ca74 into features/sprint4-backend-templates-db-injection Apr 12, 2026
5 checks passed
@NgocAnhDo26 NgocAnhDo26 deleted the users/hpn/implement-PostgREST-auto-api-template branch April 12, 2026 17:23
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.

Implement PostgREST Auto-API Template

3 participants