# ADR 0013: Service access — one ingress, configured by domain and TLS mode

> Binding. The local root runs the ingress adapter and emits access.ingress with routes for Dagster and Superset per stage, Trino, OpenMetadata when…

Source: https://openlakeforge.dev/docs/adr/0013-service-access-and-ingress/

## Status

Binding. The local root runs the ingress adapter and emits `access.ingress`
with routes for Dagster and Superset per stage, Trino, OpenMetadata when
governance is enabled, the portal landing page at the base domain, and `auth.<base_domain>` for the identity provider; the AWS and Azure roots still emit
`access.kubectl_port_forward`.

## Context

Users reach Dagster, Superset, OpenMetadata, and Trino through
`kubectl port-forward` to fixed localhost ports. That needs a cluster
credential on every workstation, breaks on pod restart, and gives no stable
URL or trusted TLS. v0.4 (#20) replaces it for local and on-premises installs.

## Decision

1. **One ingress everywhere.** A local evaluation install and a real install
   run the same ingress and differ only in configuration. The Deployment
   Profile carries that configuration as `spec.access`:

   | Field | Default | Real install |
   | --- | --- | --- |
   | `base_domain` | `olf.localhost` | e.g. `olf.example.com` |
   | `tls` | `none` (plain HTTP) | `external`: your reverse proxy, tunnel or load balancer terminates HTTPS |
   | `trusted_proxies` | none | with `external`: the CIDR blocks of that proxy, the only peers whose `X-Forwarded-*` headers are believed |

   The defaults need neither a purchased domain nor a public server, nor a
   certificate. `local-ca`, a CA the platform creates, is opt-in HTTPS for an
   evaluation install (every browser must trust it); `external` means the
   customer terminates HTTPS in front of OpenLakeForge, so Traefik serves HTTP
   while every generated URL, callback and cookie is `https://`, and it is
   refused on `*.localhost`, where nothing upstream can terminate TLS; the other providers' default stays `local-ca` because they do
   not read the block yet and `none` is local-only (decision 9).

   **The block is the switch (#399).** A profile with no `spec.access` is a
   quickstart: no Traefik, cert-manager, local CA, CoreDNS rewrite, portal or
   route Ingresses, and `shared.access` is a port-forward contract
   (`access.port_forward`, no routes), which `olf` clients and `olf infra forward`
   serve over `http://localhost:<port>`. Declaring the block, even as
   `access: {}` for the defaults, turns the ingress on. Block presence was
   chosen over an `access.exposure` field because a second field would let the
   block and the field disagree (`access:` present with `exposure: none`), and
   the defaults above already make an empty block meaningful.
   On the local provider `spec.identity` requires `spec.access` (the cloud roots do not read `spec.access`): sign-in redirects need the route
   hostnames, so the profile is rejected at validation otherwise.
2. **Routes sit one level under the base domain:** a stage service is
   `https://<service>-<stage>.<base_domain>` (`dagster-dev.olf.localhost`);
   a shared service (OpenMetadata, Trino) drops the stage suffix. One
   wildcard level is all that most client certificates and edge providers
   cover (#340), so a single `*.<base_domain>` certificate serves every
   route. Stage names are the fixed set `dev`, `uat`, `prod` and the stage
   services are `dagster` and `superset`, so no `<service>-<stage>` host can
   equal a shared or reserved host (`trino`, `openmetadata`, `auth`,
   `oauth2`). The one exception is the portal (decision 7), which is the apex,
   `https://<base_domain>`.
   With one Trino per stage (ADR 0019 section 9), Trino is a stage service,
   `trino-<stage>.<base_domain>`, and `trino` is no longer a shared host. The
   stage services are `dagster`, `superset` and `trino`, and the no-collision
   argument above is unchanged. Built for the local root (#976): the refs are
   `stage/<stage>/query` and `stage/<stage>/query_api` (the `/v1` path).
3. **The provider contract carries the routes.** `shared.access` gains
   `base_domain`, `tls`, `tls_mode`, and `routes` — declared together or
   not at all, so a port-forward contract still parses. `routes` is keyed by
   the service's existing contract ref (`stage/dev/orchestration`,
   `shared/governance_service`, `shared/portal`, ...), so a route for a disabled capability
   or an unknown service does not resolve and is rejected. Consumers read
   URLs from the contract, never from fixed ports.
4. **Internal endpoints cannot be user-facing.** Only orchestration,
   reporting, governance, query, identity, and portal may be routed with
   `exposure: user-facing`. Databases, object-store administration, the
   catalog service, and the registry may only be `internal`; Dagster code
   servers have no ref and cannot be routed at all.
5. **Port-forward is an explicit development fallback**, not an access path.
   `olf`'s own clients (`olf.infra.access.service_url`) use a stage's route when
   its contract has one, and port-forward when it has none (the AWS and
   Azure contracts today), when `OLF_PORT_FORWARD` is set, or when the route
   is in `shared.access.perimeter.protected_routes` of an enabled perimeter
   (ADR 0014 seam 3), because the ingress answers a request with no session
   by redirecting to login. Only a caller that tests the ingress itself passes
   `through_ingress=True`. They resolve
   `*.localhost` to `127.0.0.1` in-process and, for the `local-ca` issuer,
   verify against the CA read from the cluster — no `/etc/hosts` edit and no
   disabled verification. Users trust that CA once with `olf infra access trust`.
6. **Local adapter: Traefik terminates TLS, cert-manager issues.** On kind,
   Traefik binds host ports 80/443 on `127.0.0.1` through the control-plane
   node. cert-manager signs from a `local-ca` ClusterIssuer whose root is
   self-signed once and never rotated by a re-deploy; `olf infra deploy` waits for
   a probe certificate from it. `tls_mode` is therefore `ingress-terminated` for `tls: local-ca`
   (`none` for plain HTTP, `edge-terminated` for `external`: Traefik serves only
   `web`, with no TLS store, no certificate and no host port 443, and trusts
   `X-Forwarded-Proto` and `-Host` only from `forwardedHeaders.trustedIPs`, set
   from the profile's `spec.access.trusted_proxies` (required with `external`,
   refused otherwise, never `0.0.0.0/0`); Traefik discards those headers from any other peer, so
   a forged one is never read as HTTPS; the perimeter's forward-auth middleware
   keeps them (`trustForwardHeader`) only in this mode, since otherwise it
   rebuilds them from its own HTTP connection and oauth2-proxy would send
   the browser back to `http://`). One wildcard
   certificate, `*.<base_domain>` plus the bare `<base_domain>` (a wildcard
   does not match the apex), is issued in the shared namespace by
   cert-manager's ingress-shim and is Traefik's default certificate
   (`tlsStore.default`). Traefik's TLS store is global and keyed by SNI, so
   per-namespace copies of the same wildcard would leave one of them serving
   every route; stage `Ingress` objects carry an empty `tls` block, which
   enables TLS on the router and names no Secret. Routes are standard `Ingress` objects, which need no
   CRD at plan time. Traefik attaches middleware per `Ingress`, so a
   namespace has one `Ingress` per access group (the role floor, ADR 0014
   seam 3); only one in the shared namespace carries the issuer annotation
   and names the TLS Secret. The `Ingress` without a group holds the routes
   behind no middleware: the identity route and the perimeter's login
   callback.
7. **The portal is a page at the base domain.** It lists every route
   of `shared.access.routes` that is enabled and `user-facing`, grouped by
   stage, plus an Admin link to the GitHub organisation's teams when the
   issuer is GitHub. Terraform writes those links as `routes.json` in a
   ConfigMap from the same route data that feeds the contract, so the page
   cannot list a service the contract does not route. The pinned
   [openlakeforge-portal](https://github.com/OpenLakeForge/openlakeforge-portal)
   image renders it, and the page Logout lands on, from the `olf-system`
   namespace in the platform phase: the route set is static infrastructure
   (ADR 0002). Links are not filtered by role;
   the perimeter (#176) denies what a role cannot open and sends an
   unauthenticated request to login, and the portal sits behind it like
   every other route.
   Stage services sit under their stage; shared services (query, governance)
   sit under a final "Shared" heading. The page omits itself and the identity
   route: Dex has no account page and GitHub owns accounts, so when the issuer
   is `github` it links to `https://<host>/orgs/<org>/teams` ("Manage your
   account and teams on GitHub") instead.

8. **Pods reach the issuer at its Service.** The issuer's public URL is the
   token's `iss` and the browser's login page; it is compared as a string. A
   service that validates a token fetches keys and redeems codes at the
   `internal_url` of the `identity.oidc` contract (ADR 0014), Dex's Service
   (`http://dex.olf-system.svc.cluster.local:5556`), over plain HTTP: the
   perimeter proxy, Polaris and the platform API do. An `external` issuer has
   no `internal_url` and is reached at its public, publicly trusted URL.
   With `tls: external` the rewrite is not applied: the public name belongs to
   the customer's edge, and Traefik behind it serves no TLS. The two callers
   below then reach the public name through the customer's DNS and need a
   publicly trusted certificate; the e2e fixture keeps the rewrite, pointed at a
   TLS-terminating proxy that stands in for the edge.
   Two callers do not yet follow the contract and still call the public URL
   from inside the cluster, each for its own reason. OpenMetadata: its code
   exchange follows the discovery document, whose endpoints are public URLs,
   and 1.13.6's `oidcClientConfig` has no token-URL override. Superset: its
   Authlib discovery names public URLs, and moving it to `internal_url` needs
   a change to `images/superset/olf_oidc.py`, which the image source-drift
   guard (#1073) blocks until a release republishes the image (#1092). For them
   the local root keeps a CoreDNS `rewrite` sending `<base_domain>` and every
   name under it to the Traefik Service, and publishes the local CA root as
   ConfigMap `olf-local-ca` (key `ca.crt`) in `olf-system` and every stage
   namespace. Dex itself mounts the ConfigMap only to trust a GitHub
   Enterprise host (ADR 0014), which is not an issuer call. The rewrite
   replaces the cluster's `Corefile` key, so it is removed with the cluster.

The shape is provider-neutral. The AWS mapping (#274) is out of v0.4.

9. **Plain HTTP on `*.localhost` is the local default: `tls: none`.** The
   local provider accepts `spec.access.tls: none` only for a `base_domain`
   ending in `.localhost`, so a first-time user reaches every service, and
   tests sign-in, without trusting a certificate. Browsers resolve
   `*.localhost` to loopback and treat it as a secure context, so the
   perimeter cookie and the OIDC redirects work over HTTP, and Traefik's
   `127.0.0.1:80` mapping is the only exposure. Routes and the contract use
   `http://`, `tls_mode` is `none` (accepted exactly with this mode), Traefik
   serves the `web` entrypoint with no `tls` block and publishes no host port
   443. cert-manager and the local CA stay deployed: the CA ConfigMap the
   pods mount is independent of the routes. Trino has no certificate since
   #983 (ADR 0016), and whether cert-manager is still needed with this mode
   is settled in #391; `tls: external` deploys cert-manager and the CA on the
   same terms (no route certificate). With this mode the CA is disposable: nothing
   outside the cluster trusts it and the pods mount it by path, so it is not
   backed up and a restore or rebuild keeps the platform's own CA. Not for any other provider or a public domain;
   the validator rejects both, and public exposure (#340) must reject it too.
   A profile that wants browser HTTPS says `tls: local-ca`; the conformance
   profile does, so the nightly keeps exercising the TLS routes.

## Consequences

- `olf` rejects a contract whose `base_domain` or `tls` differs from the
  resolved profile, so a contract and profile cannot silently diverge.
- Changing `base_domain` changes every user-facing URL; it is deployment
  configuration, not product intent, and stays out of `governance.yml`.

- The ingress and portal add five pods to the local footprint, all in `olf-system`:

  | Pod | CPU request | Memory request / limit |
  | --- | --- | --- |
  | Traefik | 50m | 64Mi / 256Mi |
  | cert-manager controller | 10m | 64Mi / 256Mi |
  | cert-manager cainjector | 10m | 64Mi / 256Mi |
  | cert-manager webhook | 10m | 32Mi / 128Mi |
  | Portal (openlakeforge-portal) | 5m | 48Mi / 128Mi |
  | Platform API, with `spec.identity` only ([ADR 0021](https://openlakeforge.dev/docs/adr/0021-platform-api/)) | 10m | 64Mi / 192Mi |

  The platform API's request is set from about 41 MiB resident, measured in
  Docker (read-only root filesystem, as `nobody`, after 200 requests), not yet
  on kind. It answers `https://<base_domain>/api/` behind the perimeter's
  lowest role floor.

- Mapping 80/443 changed the kind cluster shape: an existing local cluster
  must be recreated (`olf infra destroy` then `olf infra deploy`), and those host ports
  must be free; `olf infra deploy` checks both ports and the TLS mode before it
  creates the cluster.

## History

#989 renamed `spec.access.issuer` to `spec.access.tls` and added `external`: the customer
terminates HTTPS in front of OpenLakeForge, Traefik serves HTTP, and
`shared.access.tls_mode` is `edge-terminated` while every route URL is
`https://`. `external` is refused on `*.localhost`. v1alpha1 profiles that say
`issuer` are refused in v1beta1 (the profile migrates with `olf project migrate`); contracts already in state keep the old key and are
read the same way.

#990 built the local adapter for `external` (decisions 1, 6, 8): Traefik serves
HTTP behind the customer's HTTPS and trusts forwarded headers only from a
range the profile names (`spec.access.trusted_proxies`), and every URL, callback and cookie is `https://`. The
end-to-end variant runs a TLS-terminating proxy in front of Traefik.

Decision 8 (#991): the perimeter proxy, Polaris and the platform API reach
Dex at its Service (`internal_url`) instead of through Traefik and the local
CA. OpenMetadata (1.13.6 has no token-URL override) and Superset (its image
change waits for #1092) still use the public URL, so the CoreDNS rewrite and
`olf-local-ca` stay until both move.

Decisions 2 and 9 (#960): Trino moved to a per-stage route with one Trino per
stage (#965, built for the local root in #976). Its certificate and its Web
UI's OAuth2 sign-in were removed with its authentication (#983, ADR 0016).

The local CA is backed up only with `tls: local-ca`; with `none` it is disposable (decision 9).

`tls: none` became the local default; the other providers keep `local-ca`.
cert-manager, the CA and `olf-local-ca` are unchanged: they still serve Trino's
certificate (ADR 0016), so only the routes' scheme differs. The conformance
profile pins `local-ca`.

#666 added the platform API's row to the footprint table: a path (`/api`) on
the portal's host, deployed with `spec.identity` (ADR 0021).

The `shared/identity` route serves Dex since Keycloak was removed (#384, ADR 0014);
the entries below that name Keycloak describe the adapter that existed then.

#403 added decision 9 (`tls: none`).

New record (#264). No prior ADR covered service access. #265 added the local
Traefik/cert-manager adapter (decision 6) and fixed `tls_mode`'s values.
#266 added the local routes and wildcard certificates. #267 moved `olf`'s
clients onto the routes, added `olf access trust`, and lists the URLs in
`olf status`. #268 added the deploy preflight, the not-Ready Certificate
section in `olf status`, and the e2e Traefik restart and renewal drills.
#24 added the `shared/identity` route (`auth.<base_domain>`, then Keycloak, now Dex) to the
local routes; it is never behind the perimeter (ADR 0014). Decision 8 (in-cluster
resolution of the routes and the CA ConfigMap) was added with it.
#330 added the portal (decisions 2, 3, 4, 6 and 7): the apex route, its
certificate name, and the landing page; a follow-up split out the Shared
section and dropped the identity link.
The portal then moved from a BusyBox-served Terraform page to the
openlakeforge-portal image, with the GitHub teams page as its Admin link.
#176 put every route except the identity route behind the perimeter (ADR 0014
seam 3): decision 6 now renders one `Ingress` per namespace and access group,
and `olf`'s clients port-forward to a protected route instead of taking its
ingress URL (decision 5). The login callback host `oauth2.<base_domain>` is
answered by the proxy and is not a contract route.
#389 flattened stage hostnames to `<service>-<stage>.<base_domain>` (decisions 2 and
6): every namespace's certificate is now `*.<base_domain>`.
The flat-hostname change also replaced the per-namespace certificates with one shared
wildcard served as Traefik's default certificate (decision 6).

---

<small>Synced from openlakeforge @ `v0.6.0-alpha.3` (`882b426`), [docs/adr/0013-service-access-and-ingress.md](https://github.com/OpenLakeForge/openlakeforge/blob/882b426992381ef277f7c0830f36c0d6fa348644/docs/adr/0013-service-access-and-ingress.md).</small>
