Skip to content

Commit e568e71

Browse files
committed
Document feature gates more
Discuss gates for fields with default values Also emphasize safety as the main motivation for feature gates.
1 parent 2f84157 commit e568e71

File tree

2 files changed

+318
-71
lines changed

2 files changed

+318
-71
lines changed

contributors/devel/sig-architecture/api_changes.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,7 +1096,7 @@ Previously, annotations were used for experimental alpha features, but are no lo
10961096

10971097
The preferred approach adds an alpha field to the existing object, and ensures it is disabled by default:
10981098

1099-
1. Add a feature gate to the API server to control enablement of the new field (and associated function):
1099+
1. Add a [feature gate](feature-gates.md) to the API server to control enablement of the new field:
11001100

11011101
In [staging/src/k8s.io/apiserver/pkg/features/kube_features.go](https://git.k8s.io/kubernetes/staging/src/k8s.io/apiserver/pkg/features/kube_features.go):
11021102

@@ -1118,7 +1118,8 @@ The preferred approach adds an alpha field to the existing object, and ensures i
11181118
* ensure the field is [optional](api-conventions.md#optional-vs-required)
11191119
* add the `omitempty` struct tag
11201120
* add the `// +optional` comment tag
1121-
* ensure the field is entirely absent from API responses when empty (optional fields should be pointers, anyway)
1121+
* add the `// +featureGate=<gate-name>` comment tag
1122+
* ensure the field is entirely absent from API responses when empty (optional fields must be pointers)
11221123
* include details about the alpha-level in the field description
11231124

11241125
```go
@@ -1131,6 +1132,7 @@ The preferred approach adds an alpha field to the existing object, and ensures i
11311132
// width indicates how wide the object is.
11321133
// This field is alpha-level and is only honored by servers that enable the Frobber2D feature.
11331134
// +optional
1135+
// +featureGate=Frobber2D
11341136
Width *int32 `json:"width,omitempty"`
11351137
}
11361138
```
@@ -1243,7 +1245,7 @@ Older versions of expected API clients must be able handle the new value in a sa
12431245
* If the enum field drives behavior of a single component, ensure all versions of that component
12441246
that will encounter API objects containing the new value handle it properly or fail safe.
12451247
For example, a new allowed value in a `Pod` enum field consumed by the kubelet must be handled
1246-
safely by kubelets up to two versions older than the first API server release that allowed the new value.
1248+
safely by kubelets up to three versions older than the first API server release that allowed the new value.
12471249
* If an API drives behavior that is implemented by external clients (like `Ingress` or `NetworkPolicy`),
12481250
the enum field must explicitly indicate that additional values may be allowed in the future,
12491251
and define how unrecognized values must be handled by clients. If this was not done in the first release
@@ -1268,7 +1270,7 @@ Release 2:
12681270
This ensures a cluster with multiple servers at skewed releases (which happens during a rolling upgrade),
12691271
will not allow data to be persisted which the previous release of the API server would choke on.
12701272

1271-
Typically, a feature gate is used to do this rollout, starting in alpha and disabled by default in release 1,
1273+
Typically, a [feature gate](feature-gates.md) is used to do this rollout, starting in alpha and disabled by default in release 1,
12721274
and graduating to beta and enabled by default in release 2.
12731275

12741276
1. Add a feature gate to the API server to control enablement of the new enum value (and associated function):

0 commit comments

Comments
 (0)