PostgreSQL Demo
Deploys PostgreSQL and creates a sample database with seed data
A minimal UIS template that deploys PostgreSQL and creates a sample tasks table with seed data. Shows the full uis template flow from registry to deployed, configured service. Use this to verify your UIS setup or as a starting point for your own stack templates.
terchrisPrerequisites
- DCT devcontainer running
- UIS provision-host container running
- Local Kubernetes cluster running (Rancher Desktop)
Files
Files (4)
├── .gitignore ├── README-postgresql-demo.md ├── template-info.yaml └── config/ └── init-database.sql
Related templates
①What gets set up
When you install this template, the following are configured for you:
- Open-source relational database
- Databasedemo_db
- Userdemo_app
- Port-forwardhost.docker.internal:35432
- Namespacedefault
- Helm chartbitnami/postgresql
config/init-database.sql
-- PostgreSQL Demo — sample schema with seed data
-- Applied by: uis configure postgresql --init-file -
-- Uses psql --set ON_ERROR_STOP=on for fail-fast on syntax errors
-- All statements are idempotent — safe to re-run
CREATE TABLE IF NOT EXISTS tasks (
id SERIAL PRIMARY KEY,
title VARCHAR(255) NOT NULL,
status VARCHAR(20) DEFAULT 'pending',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX IF NOT EXISTS idx_tasks_status ON tasks(status);
INSERT INTO tasks (title, status) VALUES
('Verify uis template install works', 'done'),
('Build your own UIS stack template', 'pending'),
('Deploy it with uis template install', 'pending')
ON CONFLICT DO NOTHING;
②Install
Install this stack into your local UIS environment. Provisions the services defined above and seeds them with any init data.
Then run:
uis template install postgresql-demoExpected output from uis template install postgresql-demo
🔧 UIS Template Install: postgresql-demo
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📄 Reading template-info.yaml...
✓ ID: postgresql-demo
✓ Type: stack
📝 Parameters:
app_name = demo-app
database_name = demo_db
🔧 Provisioning 1 service...
─── postgresql ──────────────────────────────────────────────────
Database: demo_db
Namespace: default
Init file: config/init-database.sql (706 bytes, 19 lines)
📡 Calling UIS:
docker exec -i uis-provision-host uis deploy postgresql \
--database demo_db \
--namespace default \
--init-file - \
< config/init-database.sql
✓ PostgreSQL deployed
✓ Database demo_db created + seeded
✓ Port-forward: host.docker.internal:35432 → postgresql.default.svc:5432
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✅ Stack installed (1 service)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📋 Next steps:
• Verify: uis connect postgresql demo_db
• Check port forwards: uis expose --status
• Consumer templates: see the "Related" links on this page③Verify the database
uis connect postgresql demo_dbInside psql, run: SELECT * FROM tasks; You should see 3 seeded rows. Type \q to exit.
Architecture
These diagrams are auto-generated from the template's metadata. Click any diagram to enlarge.
Overview
Components
Template README
A minimal UIS stack template that deploys PostgreSQL and creates a sample database with seed data. Use it to verify your UIS setup, or as a starting point for your own UIS stack templates.
What it deploys
- PostgreSQL (via UIS) — deployed to the cluster if not already running
What it configures
- A per-app user (derived from
app_nameparam) - A database (from
database_nameparam) - The init SQL — creates a
taskstable with 3 seed rows
Before you start
This template uses UIS. Verify the UIS provision-host container is running:
docker ps --filter name=uis-provision-host --format '{{.Status}}'
You should see Up X minutes. If not, start UIS from the urbalurba-infrastructure repo. Inside DCT (devcontainer-toolbox v1.7.34 or later) you also have the uis shim, which lets you run UIS commands directly.
Install
uis template install postgresql-demo
This works from inside the DCT devcontainer (via the uis shim), from the host (via ./uis from the urbalurba-infrastructure repo), and from inside the UIS provision-host. Same command, three contexts.
With custom params:
uis template install postgresql-demo --param app_name=myapp --param database_name=mydb
What you get
After install, uis template install returns JSON with connection details (passwords are randomly generated — your actual values will be different):
{
"status": "ok",
"service": "postgresql",
"local": {
"host": "host.docker.internal",
"port": 35432,
"database_url": "postgresql://demo_app:Xa7mP9...@host.docker.internal:35432/demo_db"
},
"cluster": {
"host": "postgresql.default.svc.cluster.local",
"port": 5432
},
"database": "demo_db",
"username": "demo_app",
"password": "Xa7mP9...",
"secret_name": "<repo>-db",
"secret_namespace": "<repo>"
}
The local URL works from your DCT devcontainer (Flask, psql, etc.) via the host port-forward.
The cluster connection is what K8s pods use — UIS also creates a Kubernetes Secret in your app's namespace so deployments can read it via secretKeyRef.
Verify it worked
The simplest way to inspect the seeded data:
uis connect postgresql demo_db
Inside psql:
SELECT * FROM tasks;
\q
You should see 3 rows. Re-running uis template install postgresql-demo is safe — it detects the existing database and returns already_configured.
Try this with
Once PostgreSQL is running and you've installed this demo template, scaffold a Flask app on top with the consumer-side template:
dev-template python-basic-webserver-database
That template's dev-template-configure step will create its own per-app database (separate from demo_db) and write DATABASE_URL to .env for local dev. Run the app with uv run python app/app.py and curl /tasks to see the full producer/consumer chain working end-to-end.
Extending this template
This template is the minimum viable example. To build your own:
- Copy this folder as a starting point
- Edit
template-info.yaml— changeid,name, add more services toprovides - Add more init files in
config/(SQL, Authentik blueprints, Grafana dashboards) - Reference UIS stacks (like
observability) inprovides.stacksto include multi-service stacks
See the contributor docs for the full template authoring guide.