Skip to content

Commit 270d561

Browse files
committed
Enhance docs book integration with feature gates documentation
1 parent f6b0247 commit 270d561

File tree

3 files changed

+58
-8
lines changed

3 files changed

+58
-8
lines changed

docs/book/src/reference/markers/feature-gates.md

Lines changed: 55 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,34 @@
22

33
Feature gates allow you to enable or disable experimental features in your Kubebuilder controllers. This is similar to how Kubernetes core uses feature gates to manage experimental functionality.
44

5+
## Quick Start
6+
7+
### Marking Fields
8+
9+
```go
10+
type MyResourceSpec struct {
11+
// Standard field
12+
Name string `json:"name"`
13+
14+
// Experimental field
15+
// +feature-gate experimental-bar
16+
Bar *string `json:"bar,omitempty"`
17+
}
18+
```
19+
20+
### Running with Feature Gates
21+
22+
```bash
23+
# Enable feature gates
24+
./manager --feature-gates=experimental-bar
25+
26+
# Multiple gates
27+
./manager --feature-gates=experimental-bar,advanced-features
28+
29+
# Mixed states
30+
./manager --feature-gates=experimental-bar=true,advanced-features=false
31+
```
32+
533
## Overview
634

735
Feature gates provide a mechanism to:
@@ -55,10 +83,10 @@ The `--feature-gates` flag accepts:
5583
### Naming Conventions
5684

5785
Use descriptive, lowercase names with hyphens:
58-
- `experimental-bar`
59-
- `advanced-features`
60-
- `ExperimentalBar`
61-
- `advanced_features`
86+
- `experimental-bar`
87+
- `advanced-features`
88+
- `ExperimentalBar`
89+
- `advanced_features`
6290

6391
### Documentation
6492

@@ -133,4 +161,26 @@ Enable debug logging to see feature gate discovery:
133161

134162
```bash
135163
./manager --feature-gates=experimental-bar --zap-log-level=debug
136-
```
164+
```
165+
166+
## Implementation Status
167+
168+
### Production Ready
169+
170+
- Feature gate discovery and validation
171+
- Controller integration with `--feature-gates` flag
172+
- Scaffolding integration for new projects
173+
174+
### Future Enhancement
175+
176+
- CRD schema modification (requires [controller-tools support](https://github.com/kubernetes-sigs/controller-tools/issues/1238))
177+
178+
When [controller-tools supports feature gates](https://github.com/kubernetes-sigs/controller-tools/issues/1238), you'll be able to use:
179+
180+
```go
181+
// +kubebuilder:feature-gate=experimental-bar
182+
// +optional
183+
Bar *string `json:"bar,omitempty"`
184+
```
185+
186+
This will automatically exclude the field from CRD schemas when the feature gate is disabled.

pkg/machinery/featuregate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
66
You may obtain a copy of the License at
77
8-
http://www/apache.org/licenses/LICENSE-2.0
8+
http://www.apache.org/licenses/LICENSE-2.0
99
1010
Unless required by applicable law or agreed to in writing, software
1111
distributed under the License is distributed on an "AS IS" BASIS,

pkg/plugins/golang/v4/scaffolds/internal/templates/cmd/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ func main() {
269269
var metricsAddr string
270270
var metricsCertPath, metricsCertName, metricsCertKey string
271271
var webhookCertPath, webhookCertName, webhookCertKey string
272-
var enableLeaderElection bool
272+
var enableLeaderElection bool
273273
var probeAddr string
274274
var secureMetrics bool
275275
var enableHTTP2 bool
@@ -280,7 +280,7 @@ func main() {
280280
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
281281
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
282282
"Enable leader election for controller manager. " +
283-
"Enabling this will ensure there is only one active controller manager.")
283+
"Enabling this will ensure there is only one active controller manager.")
284284
flag.BoolVar(&secureMetrics, "metrics-secure", true,
285285
"If set, the metrics endpoint is served securely via HTTPS. Use --metrics-secure=false to use HTTP instead.")
286286
flag.StringVar(&webhookCertPath, "webhook-cert-path", "", "The directory that contains the webhook certificate.")

0 commit comments

Comments
 (0)