Skip to content

App Deployments (1/N): DB foundation — catalog, clusters, deployments#214

Merged
v0l merged 1 commit into
masterfrom
feat/app-deployments-db
Jul 24, 2026
Merged

App Deployments (1/N): DB foundation — catalog, clusters, deployments#214
v0l merged 1 commit into
masterfrom
feat/app-deployments-db

Conversation

@v0l

@v0l v0l commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

First increment of the managed App Deployments epic (see work/app-deployments.md): predefined apps (Nostr relay, Blossom, …) run on shared Kubernetes infra — no per-user VMs, no IP-space usage. This PR is the DB layer only (no API/operator yet).

Design (agreed)

  • Billing: reuse the subscription engine — SubscriptionType::App = 4; deployments link via subscription_line_item_id like VMs.
  • Catalog: each app is a docker-compose-style YAML blob (image/ports/env/volumes). The UI builds forms → YAML; the operator will map YAML → k8s.
  • Placement: deployments target an app_cluster, which references a neutral region (location + billing company) — decoupled from VM infra (see the vm_host_region → region rename in refactor(db): rename vm_host_region → region (internal, API stable) #213). The in-cluster operator is keyed by cluster_id; no kube credentials in the DB.
  • Isolation: namespace per deployment (enforced later by the operator).

This PR

  • Migration adds app, app_cluster, app_deployment (cluster FK → region).
  • SubscriptionType::App + ApiSubscriptionLineItemResource::App.
  • Model structs + status/desired-state enums; config stored as an encrypted JSON blob (EncryptedString).
  • DB trait methods + mysql + MockDb impls.
  • Unit tests: catalog / cluster / deployment CRUD (per-user vs operator listing, line-item resolution, status write-back, soft delete).

Next increments

  1. admin catalog API · 3) customer API (order → subscription/invoice) · 4) operator reconcile (Deployment/Service/Ingress/PVC/Secret, namespace + securityContext) · 5) seed relay + Blossom.

Increment 1 of the managed App Deployments epic (predefined apps on shared
k8s infra). Pure DB layer, no API/operator yet.

- Migrations add three tables:
  - app: catalog of predefined apps, each defined by a docker-compose-style
    YAML blob (image/ports/env/volumes) + inline subscription pricing.
  - app_cluster: a k8s cluster, linked to a region (location + billing
    company); carries the ingress base domain. No kube credentials stored.
  - app_deployment: a user's instance, billed via the subscription engine
    (subscription_line_item_id) and reconciled into its own namespace.
- SubscriptionType::App = 4 and ApiSubscriptionLineItemResource::App so app
  deployments flow through the existing subscription/billing engine like VMs.
- Model structs + status/desired-state enums; config stored as an encrypted
  JSON blob (EncryptedString) so secret env values are protected at rest.
- DB trait methods + mysql + MockDb impls; unit tests for catalog, cluster
  and deployment CRUD (incl. per-user vs operator listing, line-item
  resolution, status write-back, soft delete).

Part of work/app-deployments.md.
@v0l
v0l force-pushed the feat/app-deployments-db branch from 406be06 to 4132ca4 Compare July 24, 2026 12:17
@v0l
v0l merged commit 64e2bc7 into master Jul 24, 2026
8 checks passed
@v0l
v0l deleted the feat/app-deployments-db branch July 24, 2026 14:00
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.

1 participant