Skip to content

feat: add DiscoveryContextPolicy CRD and discovery context filtering#607

Merged
scotwells merged 8 commits into
mainfrom
feat/discovery-context-policy
May 6, 2026
Merged

feat: add DiscoveryContextPolicy CRD and discovery context filtering#607
scotwells merged 8 commits into
mainfrom
feat/discovery-context-policy

Conversation

@scotwells
Copy link
Copy Markdown
Contributor

Summary

  • Introduces the DiscoveryContextPolicy CRD (discovery.miloapis.com/v1alpha1) as the highest-precedence source for controlling which API resources appear in discovery responses per parent context (Platform, Organization, Project, User)
  • Adds a discovery context filter middleware that filters /apis and /apis/{group}/{version} responses based on the URL prefix of the request
  • Registers sessions and useridentities (identity.miloapis.com) statically as User-context resources
  • Adds discovery.miloapis.com/parent-contexts=Platform annotation to the namespaced Note type
  • Ships a protected core-kubernetes-resources DiscoveryContextPolicy covering:
    • Core k8s workload resources → Project context
    • RBAC, CRDs, API services, auth/authz, and flow control resources → Platform context

How it works

Resources opt in to parent contexts via a CRD annotation (discovery.miloapis.com/parent-contexts) or a DiscoveryContextPolicy object (highest precedence). The filter is behind the DiscoveryContextFilter alpha feature gate. Missing or empty annotation means visible everywhere (backwards compatible).

Test plan

  • DiscoveryContextFilter feature gate enables filtering
  • CRD annotation changes are reflected in discovery responses
  • DiscoveryContextPolicy overrides CRD annotations
  • Chainsaw e2e test in test/discovery-context-filter/ passes

🤖 Generated with Claude Code

scotwells and others added 2 commits May 6, 2026 17:49
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds Platform context rules for apiextensions.k8s.io, apiregistration.k8s.io,
authentication.k8s.io, authorization.k8s.io, and flowcontrol.apiserver.k8s.io.
Also moves rbac.authorization.k8s.io resources from Project to Platform.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@joggrbot
Copy link
Copy Markdown
Contributor

joggrbot Bot commented May 6, 2026

📝 Documentation Analysis

All docs are up to date! 🎉


✅ Latest commit analyzed: 871e767 | Powered by Joggr

scotwells and others added 5 commits May 6, 2026 18:25
Restricts notes resources across notes.miloapis.com, crm.miloapis.com,
and notification.miloapis.com to the Platform parent context.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…imitives

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…omponent

- Moves discovery-context-policy-core.yaml into config/discovery/core/ as
  a standalone Component, consistent with config/discovery/notes/
- Removes apps, batch, and networking.k8s.io rules (not registered in milo)
- Removes serviceaccounts and resourcequotas from core group (explicitly disabled)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Removes pods, services, persistentvolumeclaims, and limitranges which
are not enabled in milo's API server.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@scotwells scotwells requested a review from kevwilliams May 6, 2026 23:30
kevwilliams
kevwilliams previously approved these changes May 6, 2026
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@scotwells scotwells merged commit 5138c4b into main May 6, 2026
8 of 9 checks passed
@scotwells scotwells deleted the feat/discovery-context-policy branch May 6, 2026 23:58
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.

2 participants