Skip to content

feat(globalproxysettings): add Tenant subject kind - #1151

Open
NopeCharon wants to merge 1 commit into
projectcapsule:mainfrom
NopeCharon:feat/globalproxysettings-tenant-subject
Open

NopeCharon wants to merge 1 commit into
projectcapsule:mainfrom
NopeCharon:feat/globalproxysettings-tenant-subject

Conversation

@NopeCharon

Copy link
Copy Markdown

Fixes #1131

Adds a Tenant subject kind to GlobalProxySettings:

subjects:
  - kind: Tenant
    name: solar

It matches every caller that currently owns Tenant solar, whether as User, Group or promoted ServiceAccount. Non-owners and owners of other Tenants get nothing from the rule, and removing ownership revokes the grant. This removes the need to maintain one GlobalProxySettings entry per dynamically created promoted ServiceAccount.

  • Only GlobalProxySettings is affected, and only with the ProxyClusterScoped feature gate enabled. Namespaced ProxySetting is unchanged.
  • Resolution reuses the Tenant owner index already queried for the caller plus the existing GlobalProxySettings subject index (Tenant:<name>), so no extra API calls are made. A Tenant is resolved once per request even if the caller owns it through several identities, so rules are not duplicated.
  • GlobalSubject.Kind gets its own GlobalSubjectKind type so the CRD enum can include Tenant without widening the kinds accepted for ProxySetting owners. CRD regenerated with controller-gen v0.22.0.
  • README documents the new subject kind.

Tests

  • Unit: subject matching (internal/tenant), end-to-end lookup for User/Group/ServiceAccount identities with gate on/off, non-owner, other tenant, ownership revocation, and once-only resolution (the latter fails without the dedupe).
  • Benchmark BenchmarkGlobalProxySettingsTenantSubject (up to 1000 unrelated namespaces): about 0.09 ms/op without a grant and 0.12 ms/op with a grant; cost does not grow with unrelated objects.
  • e2e: e2e/global_tenant_subject_test.go with two tenants (owner granted, owner of another tenant denied, grant revoked after ownership change). It compiles with the e2e tag; it was not run locally because no cluster was available, so it relies on CI.
  • go test -race ./... passes.

GlobalProxySettings subjects could only be User, Group or ServiceAccount.
That works poorly for promoted ServiceAccounts: tenant owners create them
dynamically, so cluster administrators cannot know their names in advance
and would have to maintain one GlobalProxySettings entry per account.

Add a Tenant subject kind. A subject {kind: Tenant, name: solar} matches
every caller that currently owns Tenant "solar", whether as User, Group or
promoted ServiceAccount. Non-owners and owners of other Tenants get
nothing from the rule, and removing ownership revokes the grant.

Resolution reuses the existing Tenant owner index already queried for the
caller and the GlobalProxySettings subject index, so no extra API calls
are made. Lookups happen only with the ProxyClusterScoped feature gate
enabled. A Tenant is resolved once per request even when the caller owns
it through several identities (user plus groups), avoiding duplicated
rules.

GlobalSubject.Kind gets its own GlobalSubjectKind type so the CRD enum can
include Tenant without widening the kind accepted for namespaced
ProxySettings owners. CRD regenerated with controller-gen v0.22.0.

Adds unit tests (subject matching, user/group/serviceaccount identities,
gate on/off, ownership revocation, once-only resolution), a benchmark and
an e2e scenario with two tenants, plus README documentation.

Signed-off-by: NopeCharon <115794254+NopeCharon@users.noreply.github.com>
@NopeCharon
NopeCharon force-pushed the feat/globalproxysettings-tenant-subject branch from 217ac47 to f437e6f Compare November 20, 2026 08:52
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.

Adding a Tenant as subject in a GlobalProxySettings

1 participant