Skip to content

Commit cc449a7

Browse files
committed
feat(k8s): add inbound TokenReview auth strategy and START/STOP via workload scaling
Add KubeAuthStrategy, an opt-in inbound HTTP auth strategy that validates caller ServiceAccount bearer tokens through the cluster's authentication.k8s.io/v1 TokenReview API, registered in the auth registry when inbound_auth_enabled is set. Implement START_INSTANCES/STOP_INSTANCES for Deployment and StatefulSet workloads by patching spec.replicas (stopping scales to zero and archives the prior count; starting restores it); Pod and Job report the operation as unsupported for their kind.
1 parent a63548d commit cc449a7

9 files changed

Lines changed: 1864 additions & 15 deletions

File tree

src/orb/providers/k8s/auth/__init__.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,32 @@
1-
"""Kubernetes API auth loaders.
1+
"""Kubernetes API auth loaders and inbound HTTP auth strategies.
22
3+
API client bootstrap loaders
4+
-----------------------------
35
These modules are thin wrappers around ``kubernetes.config.load_*`` calls
46
used to bootstrap the Kubernetes API client. They are not ORB
57
:class:`~orb.infrastructure.adapters.ports.auth.AuthPort` strategies (which
68
authenticate inbound HTTP requests to ORB's REST surface) — the
79
ORB-side ``AuthRegistry`` entries for the kubernetes provider are
810
registered in :mod:`orb.providers.k8s.registration`.
11+
12+
Inbound HTTP auth strategy
13+
---------------------------
14+
:class:`KubeAuthStrategy` implements the ``AuthPort`` interface and validates
15+
caller Kubernetes ServiceAccount JWTs via the ``authentication.k8s.io/v1
16+
TokenReview`` API. It is registered in the ``AuthRegistry`` by
17+
:func:`orb.providers.k8s.registration.register_k8s_auth_strategies` when
18+
``inbound_auth_enabled=True`` in :class:`K8sProviderConfig`.
919
"""
1020

1121
from orb.providers.k8s.auth.in_cluster import (
1222
is_in_cluster,
1323
load_in_cluster_config,
1424
)
25+
from orb.providers.k8s.auth.kube_auth_strategy import KubeAuthStrategy
1526
from orb.providers.k8s.auth.kubeconfig import load_kubeconfig
1627

1728
__all__: list[str] = [
29+
"KubeAuthStrategy",
1830
"is_in_cluster",
1931
"load_in_cluster_config",
2032
"load_kubeconfig",

0 commit comments

Comments
 (0)