Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
088ff8d
Feat: Add Self hosted and managed options
miladhzzzz Jul 24, 2026
4d1730e
Chore: Clean up dependencies
miladhzzzz Jul 24, 2026
759508d
Feat: Remove Mongodb / Add postgres + no db in self hosted mode
miladhzzzz Jul 24, 2026
6c7de15
Chore: Update Gateway README
miladhzzzz Jul 24, 2026
928ca78
Feat: Add Deployment mode to config
miladhzzzz Jul 24, 2026
b22f562
Refactor: Auth Controller to remove race conditions
miladhzzzz Jul 24, 2026
ca8f485
Chore: fmt automation controller
miladhzzzz Jul 24, 2026
9a3e42a
Chore: Remove Mongo Collection
miladhzzzz Jul 24, 2026
1463983
Feat: Add Proto helper for serilization / deserlialization
miladhzzzz Jul 24, 2026
fbe9e81
Refactor: ClusterMetaController holds the handlers that were never RP…
miladhzzzz Jul 24, 2026
f948bdc
Feat: Add middleware
miladhzzzz Jul 24, 2026
8e496f5
Feat: Package catalog implements a config-driven service registry for…
miladhzzzz Jul 24, 2026
f09f958
Remove: Old internal vault.go we use pkg/certmanager
miladhzzzz Jul 24, 2026
0270846
Feat: Add Package grpcbridge turns any reflection-enabled gRPC servic…
miladhzzzz Jul 24, 2026
04a0c07
Feat: Add bindings.go is the single place the gateway's entire dynami…
miladhzzzz Jul 24, 2026
9a2957d
Feat: Add Package router wires the gateway's HTTP surface from two so…
miladhzzzz Jul 24, 2026
d26a7b8
Feat: Add postgres db schema + store.go
miladhzzzz Jul 24, 2026
ca122e4
Chore: Cleanup + Update Data Models
miladhzzzz Jul 24, 2026
8d28cee
Chore: Remove Ctx
miladhzzzz Jul 24, 2026
75b2b17
Chore: NewGithubRouteController now actually takes the AuthController…
miladhzzzz Jul 24, 2026
d797786
Remove: deprecated Prow routes
miladhzzzz Jul 24, 2026
d79d56c
Security: Fix Hardcoded JWT secret + clean up
miladhzzzz Jul 24, 2026
526211b
Feat: Forgery Service
miladhzzzz Jul 24, 2026
d971270
Chore: Remove mongo from github service
miladhzzzz Jul 24, 2026
2d2ad0c
Refactor: Remove deprecated prow name and service + separation of for…
miladhzzzz Jul 24, 2026
f504e36
Chore: Remove deprecated Prow
miladhzzzz Jul 24, 2026
ce3a3ff
Chore: Remove deprecated mongodb
miladhzzzz Jul 24, 2026
19e14ad
Chore: Update Auth Test
miladhzzzz Jul 24, 2026
9bfb24d
Security: Fix Hardcoded JWT secret
miladhzzzz Jul 24, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 78 additions & 13 deletions persys-gateway/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
## Responsibilities

- Public HTTP ingress.
- OAuth/session handling for GitHub login flow.
- OAuth/session handling for GitHub login flow (managed deployments only — see Deployment Modes).
- GitHub webhook signature + replay validation.
- Multi-cluster scheduler pool routing.
- Proxy HTTP API calls to scheduler gRPC API.
- Forward forgery-related actions to forgery gRPC API.
- Multi-cluster scheduler pool routing, with automatic failover across scheduler replicas.
- Dynamic HTTP-to-gRPC bridging for cluster control (workloads/nodes) and forgery (CI/CD), via gRPC reflection with a compiled-in fallback — see Dynamic API Surface.
- Enforce mTLS for internal calls.

## Non-Responsibilities
Expand All @@ -18,40 +17,103 @@
- Does not push images.
- Does not perform scheduler-side build actions.

## Deployment Modes

Set via `deployment.mode` in `config.yaml` (or left unset):

- **`self-hosted`** (default) — no GitHub OAuth app required. `/auth/*` and
`/github/*` routes aren't mounted at all. mTLS is the only trust
boundary for cluster-control and forgery routes. No database is
required — see Database below.
- **`managed`** — GitHub OAuth mounts, cluster-control/forgery routes
require a verified user JWT (or mTLS), and a database is required at
startup (fails fast if `database.dsn` is empty).

`GET /health` reports the active `deployment_mode` and `database_enabled`
so this is always visible at runtime, not just inferred from config.

## Database

Postgres, via `internal/store` — **optional in self-hosted mode**. Leave
`database.dsn` unset and the gateway runs with no database at all: the
only things that ever touch it (OAuth login/session storage, webhook
delivery audit trail) either aren't mounted in self-hosted mode or
degrade gracefully to in-memory-only behavior. Managed mode requires it.

Schema is three tables (`users`, `oauth_sessions`, `webhook_events`),
applied as idempotent `CREATE TABLE IF NOT EXISTS` on every startup —
no separate migration command. See `internal/store/schema.sql` for what
each table is for and what was deliberately *not* carried over from an
earlier MongoDB-based version.

## Ports

From `config.yaml`:
- mTLS API: `:8551`
- public webhook API: `:8585`
- debug/pprof: `:6060`

## Config

Primary config files:
- `config.yaml`
- `cluster.yaml` (scheduler clusters and routing)
- `catalog.yaml` (optional — see Dynamic API Surface; absence is normal)

Important sections:
- `deployment.mode` — see Deployment Modes
- `app.jwt_secret` — required in managed mode, auto-generated with a
startup warning in self-hosted (won't survive a restart unless set)
- `database.dsn` — required in managed mode, optional in self-hosted
- `tls`, `vault`
- `scheduler` + `core_dns`
- `webhook`
- `forgery.grpc_addr`, `forgery.grpc_server_name`

Key environment variable overrides (see `config/config.go` for the full
list): `PERSYS_GATEWAY_CONFIG`, `PERSYS_GATEWAY_JWT_SECRET`,
`PERSYS_GATEWAY_POSTGRES_DSN`, `PERSYS_GATEWAY_CATALOG`.

## Dynamic API Surface

Cluster-control (workloads/nodes) and forgery (CI/CD) routes are not
hand-written per RPC. `internal/grpcbridge` discovers methods via gRPC
reflection against the live backend, falling back to the compiled-in
proto descriptor if the backend doesn't support reflection yet — so a
new RPC on either backend is reachable with zero gateway code changes,
and works against existing deployments unmodified either way.

The full, current list of stable paths is `internal/router/bindings.go`.
Anything not given a stable alias there is still callable at the generic
`/clusters/:cluster_id/rpc/<Service>/<Method>` path, and every method
(aliased or not) is listed at runtime:

```
GET /clusters/:cluster_id/rpc/_meta
GET /clusters/:cluster_id/forgery/rpc/_meta
```

## Key Routes

Public:
- `POST /webhooks/github`

mTLS API:
- `GET /health`
- `GET /clusters`
- `POST /workloads/schedule`
- `GET /workloads`
- `GET /nodes`
- `GET /cluster/metrics`
- `POST /forgery/projects/upsert`
- `POST /forgery/builds/trigger`
- `POST /forgery/webhooks/test`

Cluster-scoped variants are under `/clusters/:cluster_id/...`.
- `GET /clusters/:cluster_id`
- `POST /clusters/:cluster_id/workloads/schedule`
- `GET /clusters/:cluster_id/workloads`
- `GET /clusters/:cluster_id/nodes`
- `GET /clusters/:cluster_id/cluster/metrics`
- `POST /clusters/:cluster_id/forgery/projects/upsert`
- `POST /clusters/:cluster_id/forgery/builds/trigger`
- `POST /clusters/:cluster_id/forgery/webhooks/test`

Managed mode only:
- `GET /auth/login`
- `GET /auth/` (OAuth callback)
- `GET /github/list/repos`

## Run

Expand All @@ -66,3 +128,6 @@ go run ./cmd
cd persys-gateway
go build ./cmd
```

After pulling dependency changes (e.g. the Postgres migration), run
`go mod tidy` once to settle `go.sum`.
Loading
Loading