Skip to content

Commit f9bacb2

Browse files
Han KangTim Bannister
andauthored
add deprecation policy for k8s metrics (#27202)
* add deprecation policy for metrics * Update content/en/docs/reference/using-api/deprecation-policy.md Co-authored-by: Tim Bannister <[email protected]> * amend stability language given review comments Co-authored-by: Tim Bannister <[email protected]>
1 parent de3843c commit f9bacb2

File tree

1 file changed

+41
-2
lines changed

1 file changed

+41
-2
lines changed

content/en/docs/reference/using-api/deprecation-policy.md

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ Starting in Kubernetes v1.19, making an API request to a deprecated REST API end
301301

302302
1. Returns a `Warning` header (as defined in [RFC7234, Section 5.5](https://tools.ietf.org/html/rfc7234#section-5.5)) in the API response.
303303
2. Adds a `"k8s.io/deprecated":"true"` annotation to the [audit event](/docs/tasks/debug-application-cluster/audit/) recorded for the request.
304-
3. Sets an `apiserver_requested_deprecated_apis` gauge metric to `1` in the `kube-apiserver`
304+
3. Sets an `apiserver_requested_deprecated_apis` gauge metric to `1` in the `kube-apiserver`
305305
process. The metric has labels for `group`, `version`, `resource`, `subresource` that can be joined
306306
to the `apiserver_request_total` metric, and a `removed_release` label that indicates the
307307
Kubernetes release in which the API will no longer be served. The following Prometheus query
@@ -428,6 +428,46 @@ transitions a lifecycle stage as follows. Feature gates must function for no les
428428
is deprecated it must be documented in both in the release notes and the corresponding CLI help.
429429
Both warnings and documentation must indicate whether a feature gate is non-operational.**
430430

431+
## Deprecating a metric
432+
433+
Each component of the Kubernetes control-plane exposes metrics (usually the
434+
`/metrics` endpoint), which are typically ingested by cluster administrators.
435+
Not all metrics are the same: some metrics are commonly used as SLIs or used
436+
to determine SLOs, these tend to have greater import. Other metrics are more
437+
experimental in nature or are used primarily in the Kubernetes development
438+
process.
439+
440+
Accordingly, metrics fall under two stability classes (`ALPHA` and `STABLE`);
441+
this impacts removal of a metric during a Kubernetes release. These classes
442+
are determined by the perceived importance of the metric. The rules for
443+
deprecating and removing a metric are as follows:
444+
445+
**Rule #9a: Metrics, for the corresponding stability class, must function for no less than:**
446+
447+
* **STABLE: 4 releases or 12 months (whichever is longer)**
448+
* **ALPHA: 0 releases**
449+
450+
**Rule #9b: Metrics, after their _announced deprecation_, must function for no less than:**
451+
452+
* **STABLE: 3 releases or 9 months (whichever is longer)**
453+
* **ALPHA: 0 releases**
454+
455+
Deprecated metrics will have their description text prefixed with a deprecation notice
456+
string '(Deprecated from x.y)' and a warning log will be emitted during metric
457+
registration. Like their stable undeprecated counterparts, deprecated metrics will
458+
be automatically registered to the metrics endpoint and therefore visible.
459+
460+
On a subsequent release (when the metric's deprecatedVersion is equal to
461+
_current_kubernetes_version - 3_)), a deprecated metric will become a _hidden_ metric.
462+
**_Unlike_** their deprecated counterparts, hidden metrics will _no longer_ be
463+
automatically registered to the metrics endpoint (hence hidden). However, they
464+
can be explicitly enabled through a command line flag on the binary
465+
(i.e. `--show-hidden-metrics-for-version=`). This provides cluster admins an
466+
escape hatch to properly migrate off of a deprecated metric, if they were not
467+
able to react to the earlier deprecation warnings. Hidden metrics should be
468+
deleted after one release.
469+
470+
431471
## Exceptions
432472

433473
No policy can cover every possible situation. This policy is a living
@@ -438,4 +478,3 @@ leaders to find the best solutions for those specific cases, always bearing in
438478
mind that Kubernetes is committed to being a stable system that, as much as
439479
possible, never breaks users. Exceptions will always be announced in all
440480
relevant release notes.
441-

0 commit comments

Comments
 (0)