feat: introduce Feature Gates#1142
Conversation
Signed-off-by: Jacek Luczak <difrost.kernel@gmail.com>
|
@difrost it's not clear to me what the advantage of the feature gates over just the normal configuration (which enables/disabled features already) is? |
agreed, this seems to provide abstractions over something that's already covered.
|
|
IMHO Feature Gates are far more clear abstraction for feature availability widely adapted by K8s ecosystem. I agree that one can build config based solution to that and I'm ok with dropping this out - I'll let @manusa decide. |
|
I'd prefer to close this for now because there's still nothing to take advantage of this and we already have the functionality covered (YAGNI). |
What
This PR introduces a generic feature gate framework (
pkg/features/) based onk8s.io/component-base/featuregate.Feature gates allow controlling feature availability based on maturity level (Alpha, Beta, GA, Deprecated) and can be configured via:
--feature-gates Feature1=true,Feature2=false[feature_gates]section (supports SIGHUP reload)Why
I'm working on enabling Kubernetes MCP in a large environment with many, big clusters. The scale of operations (and the nature of my environment) requires variety of features that we want to introduce gradually. Feature gating will help in managing a lifecycle of features. Some strong candidates from existing codebase:
Maturity: Alpha (default: off)
Description: The
StructuredContentfield onToolCallResultprovides richer MCP UI rendering by including a JSON-serializable structured payload alongside the text Content. This is a newer MCP spec addition and not all clients support it yet.Current state: Unconditionally included in tool call results when set by a tool handler. Defined in
pkg/api/toolsets.go(ToolCallResult.StructuredContent) and serialized inpkg/mcp/tools_gosdk.go.Risk: Low. Tools already produce a text Content fallback per MCP spec, so disabling structured content is a graceful degradation.
Maturity: Alpha (default: off)
Description: Elicitation enables interactive user confirmation prompts via the MCP protocol. The server can ask the user to confirm or deny an action before proceeding. This depends on MCP client support and already has fallback logic for clients that don't implement it (
ErrElicitationNotSupported).Current state: Wired in
pkg/mcp/elicit.go(sessionElicitor), used bypkg/kubernetes/confirmation_validator.gofor kube-level confirmation rules, and bypkg/confirmation/for tool-level rules. Clients that don't support elicitation get an error that is handled gracefully.Risk: Low. The fallback path already exists for clients without elicitation support.
Among the new features that could be gated behind feature gates is #711 that I would like to work on.
How
pkg/features/package — mirrors the Kubernetes convention (k8s.io/apiserver/pkg/util/feature,k8s.io/kubernetes/pkg/features). Keeps the gate instance and feature definitions together, avoids import cycles.[feature_gates]table — usesmap[string]boolwhich naturally maps to a TOML table. Follows the existingStaticConfigpattern. Applied viaSetFromMapwhich is the canonical featuregate API.SetFromMapreplaces the full state atomically, features removed from config revert to their defaults.--feature-gatesflag is applied inloadFlagsafter config file loading, matching the existing pattern where CLI flags take precedence.