Skip to content

feat(edge): per-EdgeRoute downstream TLS via SDS + HTTP→HTTPS redirect - #244

Merged
bpalermo merged 1 commit into
mainfrom
feat/edge-downstream-tls
Jun 19, 2026
Merged

bpalermo merged 1 commit into
mainfrom
feat/edge-downstream-tls

Conversation

@bpalermo

Copy link
Copy Markdown
Owner

What

Real ingress TLS for the edge, replacing the v1 file-mounted single cert (#239): per-host certs, hot rotation, and an HTTP→HTTPS redirect.

kind: EdgeRoute
spec:
  hosts: [api.example.com]
  service: svc-1
  tls:
    secretName: api-tls            # BYO / cert-manager kubernetes.io/tls Secret
    provider: SECRET_PROVIDER_KUBERNETES   # default

Design

  • Per-EdgeRoute cert, served over ADS SDS. The edge agent watches EdgeRoutes + their Secrets, reads the cert bytes, and serves them to Envoy over the agent's SecretType channel (free — upstream mTLS comes from SPIRE directly). Envoy picks the cert by SNI. Rotation is event-driven (Secret watch) — no pod roll, no static mount.
  • Pluggable SecretProvider. New pkg agent/internal/edge/secret: a Provider interface + Registry (enum dispatch, provider-prefixed SDS names <scheme>/<ref>). kubernetesProvider reads a kubernetes.io/tls Secret. Adding AWS Secrets Manager / Vault = a new enum value + Provider impl, no listener/SDS changes. The selector is a proto enum (SecretProvider) for schema validation.
  • Listeners. TLS-terminating listener on httpsPort (one DownstreamTlsContext, N SDS certs, no client cert, min TLS 1.2, ALPN h2/http1.1) + a :80 listener that 301-redirects to https. Plain HTTP when TLS off.
  • Chart. edge.tls.enabled (+ httpsPort, service.httpsPort): the deployment passes --edge-tls/--edge-https-port, adds the :443 port + HTTPS readiness (NET_BIND_SERVICE covers 443), the Service exposes https, and the edge Role gains secrets get/list/watch. The mounted-Secret path is gone. Chart 0.11.0 → 0.12.0.

Tests

kubernetesProvider + Registry (fake client, enum dispatch, SDS-name prefix, error cases); SDS downstream socket (ADS source, no client cert, TLS params/ALPN); redirect listener (301 https); cache TLS-mode two-listener set + SecretType cert; reconciler resolves provider/ref → SDS name + bytes and tolerates an unresolvable ref. Full build, 28 test targets, lint, format, and chart-version-bump pass; chart renders TLS on/off.

Follow-ups

e2e on talos-main (publish → deploy from the published chart): a kubernetes.io/tls Secret + EdgeRoute.tls, curl -k --resolve … https://… → 200, :80 → 301, and a Secret rotation reflected without a pod roll. Out of scope: client mTLS at the edge, chart-rendered cert-manager Certificate, default/fallback cert for SNI misses.

🤖 Generated with Claude Code

Replace the v1 file-mounted single-cert edge TLS (#239) with real ingress TLS:
per-host certs, hot rotation, and an HTTP->HTTPS redirect.

- EdgeRoute.spec.tls{secret_name, provider} references a cert (BYO / cert-manager).
  provider is a SecretProvider ENUM (kubernetes now; aws-secrets-manager reserved).
- New agent/internal/edge/secret: a pluggable Provider interface + Registry
  (enum dispatch, provider-prefixed SDS names "<scheme>/<ref>"); kubernetesProvider
  reads a kubernetes.io/tls Secret. New backends = new enum value + Provider impl,
  no listener/SDS changes.
- The edge agent watches EdgeRoutes + their Secrets, resolves cert bytes, and
  serves them to Envoy over the agent's ADS SecretType channel (cache.SetSecrets,
  free since upstream certs come from SPIRE directly). Envoy selects the cert by
  SNI. Rotation is event-driven (Secret watch) with no pod roll.
- Listeners: TLS-terminating listener on httpsPort (one DownstreamTlsContext with
  N SDS certs, no client cert, min TLS 1.2, ALPN h2/http1.1) + a :80 listener that
  301-redirects to https. Plain HTTP when TLS off.
- Chart: edge.tls.enabled (+ edge.httpsPort, service.httpsPort); deployment passes
  --edge-tls/--edge-https-port, adds the :443 port + HTTPS readiness, NET_BIND_SERVICE
  covers 443; Service exposes https; edge Role gains secrets get/list/watch. Drops
  the mounted-Secret path. chart 0.11.0 -> 0.12.0.

Removed: the file-based EdgeTLS struct, edge-tls cert/key flags, mounted Secret.

Tests: kubernetesProvider + Registry (fake client); SDS downstream socket (ADS,
no client cert, TLS params); redirect listener (301 https); cache TLS-mode
two-listener set + SecretType cert; reconciler resolves provider/ref -> SDS name +
bytes (and tolerates an unresolvable ref).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Pihqn5RmVPhV9HTdBnqbvY
@bpalermo
bpalermo merged commit 5eea4d8 into main Jun 19, 2026
14 checks passed
@bpalermo
bpalermo deleted the feat/edge-downstream-tls branch June 19, 2026 21:08
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