|
2 | 2 |
|
3 | 3 | 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.
|
4 | 4 |
|
| 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 | + |
5 | 33 | ## Overview
|
6 | 34 |
|
7 | 35 | Feature gates provide a mechanism to:
|
@@ -133,4 +161,26 @@ Enable debug logging to see feature gate discovery:
|
133 | 161 |
|
134 | 162 | ```bash
|
135 | 163 | ./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. |
0 commit comments