diff --git a/cmd/kube-controller-manager/app/controllermanager.go b/cmd/kube-controller-manager/app/controllermanager.go index d87e31dc2b1..2274a6a68bf 100644 --- a/cmd/kube-controller-manager/app/controllermanager.go +++ b/cmd/kube-controller-manager/app/controllermanager.go @@ -215,9 +215,8 @@ func Run(ctx context.Context, c *config.CompletedConfig) error { var unsecuredMux *mux.PathRecorderMux if c.SecureServing != nil { unsecuredMux = genericcontrollermanager.NewBaseHandler(&c.ComponentConfig.Generic.Debugging, healthzHandler) - if utilfeature.DefaultFeatureGate.Enabled(features.ComponentSLIs) { - slis.SLIMetricsWithReset{}.Install(unsecuredMux) - } + slis.SLIMetricsWithReset{}.Install(unsecuredMux) + handler := genericcontrollermanager.BuildHandlerChain(unsecuredMux, &c.Authorization, &c.Authentication) // TODO: handle stoppedCh and listenerStoppedCh returned by c.SecureServing.Serve if _, _, err := c.SecureServing.Serve(handler, 0, stopCh); err != nil { diff --git a/cmd/kube-proxy/app/server.go b/cmd/kube-proxy/app/server.go index 8726e60c1b2..4561fb88446 100644 --- a/cmd/kube-proxy/app/server.go +++ b/cmd/kube-proxy/app/server.go @@ -806,9 +806,8 @@ func serveMetrics(bindAddress string, proxyMode kubeproxyconfig.ProxyMode, enabl proxyMux := mux.NewPathRecorderMux("kube-proxy") healthz.InstallHandler(proxyMux) - if utilfeature.DefaultFeatureGate.Enabled(metricsfeatures.ComponentSLIs) { - slis.SLIMetricsWithReset{}.Install(proxyMux) - } + slis.SLIMetricsWithReset{}.Install(proxyMux) + proxyMux.HandleFunc("/proxyMode", func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "text/plain; charset=utf-8") w.Header().Set("X-Content-Type-Options", "nosniff") diff --git a/cmd/kube-scheduler/app/server.go b/cmd/kube-scheduler/app/server.go index c48b09a420d..4a7e171ae30 100644 --- a/cmd/kube-scheduler/app/server.go +++ b/cmd/kube-scheduler/app/server.go @@ -294,9 +294,8 @@ func newHealthzAndMetricsHandler(config *kubeschedulerconfig.KubeSchedulerConfig pathRecorderMux := mux.NewPathRecorderMux("kube-scheduler") healthz.InstallHandler(pathRecorderMux, checks...) installMetricHandler(pathRecorderMux, informers, isLeader) - if utilfeature.DefaultFeatureGate.Enabled(features.ComponentSLIs) { - slis.SLIMetricsWithReset{}.Install(pathRecorderMux) - } + slis.SLIMetricsWithReset{}.Install(pathRecorderMux) + if config.EnableProfiling { routes.Profiling{}.Install(pathRecorderMux) if config.EnableContentionProfiling { diff --git a/pkg/kubelet/server/server.go b/pkg/kubelet/server/server.go index 7ee617cc5fe..f66505ff883 100644 --- a/pkg/kubelet/server/server.go +++ b/pkg/kubelet/server/server.go @@ -377,9 +377,8 @@ func (s *Server) InstallDefaultHandlers() { healthz.NamedCheck("syncloop", s.syncLoopHealthCheck), ) - if utilfeature.DefaultFeatureGate.Enabled(metricsfeatures.ComponentSLIs) { - slis.SLIMetricsWithReset{}.Install(s.restfulCont) - } + slis.SLIMetricsWithReset{}.Install(s.restfulCont) + s.addMetricsBucketMatcher("pods") ws := new(restful.WebService) ws. diff --git a/staging/src/k8s.io/apiserver/pkg/server/config.go b/staging/src/k8s.io/apiserver/pkg/server/config.go index d678f52dfb7..ebe788b1c50 100644 --- a/staging/src/k8s.io/apiserver/pkg/server/config.go +++ b/staging/src/k8s.io/apiserver/pkg/server/config.go @@ -994,14 +994,10 @@ func installAPI(s *GenericAPIServer, c *Config) { if c.EnableMetrics { if c.EnableProfiling { routes.MetricsWithReset{}.Install(s.Handler.NonGoRestfulMux) - if utilfeature.DefaultFeatureGate.Enabled(features.ComponentSLIs) { - slis.SLIMetricsWithReset{}.Install(s.Handler.NonGoRestfulMux) - } + slis.SLIMetricsWithReset{}.Install(s.Handler.NonGoRestfulMux) } else { routes.DefaultMetrics{}.Install(s.Handler.NonGoRestfulMux) - if utilfeature.DefaultFeatureGate.Enabled(features.ComponentSLIs) { - slis.SLIMetrics{}.Install(s.Handler.NonGoRestfulMux) - } + slis.SLIMetrics{}.Install(s.Handler.NonGoRestfulMux) } } diff --git a/staging/src/k8s.io/cloud-provider/app/controllermanager.go b/staging/src/k8s.io/cloud-provider/app/controllermanager.go index 528e607634e..d9069dc7d76 100644 --- a/staging/src/k8s.io/cloud-provider/app/controllermanager.go +++ b/staging/src/k8s.io/cloud-provider/app/controllermanager.go @@ -202,9 +202,9 @@ func Run(c *cloudcontrollerconfig.CompletedConfig, cloud cloudprovider.Interface // Start the controller manager HTTP server if c.SecureServing != nil { unsecuredMux := genericcontrollermanager.NewBaseHandler(&c.ComponentConfig.Generic.Debugging, healthzHandler) - if utilfeature.DefaultFeatureGate.Enabled(features.ComponentSLIs) { - slis.SLIMetricsWithReset{}.Install(unsecuredMux) - } + + slis.SLIMetricsWithReset{}.Install(unsecuredMux) + handler := genericcontrollermanager.BuildHandlerChain(unsecuredMux, &c.Authorization, &c.Authentication) // TODO: handle stoppedCh and listenerStoppedCh returned by c.SecureServing.Serve if _, _, err := c.SecureServing.Serve(handler, 0, stopCh); err != nil { diff --git a/staging/src/k8s.io/component-base/metrics/prometheus/slis/metrics.go b/staging/src/k8s.io/component-base/metrics/prometheus/slis/metrics.go index 7907dfad12a..3d464d12d75 100644 --- a/staging/src/k8s.io/component-base/metrics/prometheus/slis/metrics.go +++ b/staging/src/k8s.io/component-base/metrics/prometheus/slis/metrics.go @@ -37,7 +37,7 @@ var ( Namespace: "kubernetes", Name: "healthcheck", Help: "This metric records the result of a single healthcheck.", - StabilityLevel: k8smetrics.BETA, + StabilityLevel: k8smetrics.STABLE, }, []string{"name", "type"}, ) @@ -48,7 +48,7 @@ var ( Namespace: "kubernetes", Name: "healthchecks_total", Help: "This metric records the results of all healthcheck.", - StabilityLevel: k8smetrics.BETA, + StabilityLevel: k8smetrics.STABLE, }, []string{"name", "type", "status"}, ) diff --git a/staging/src/k8s.io/component-base/metrics/prometheus/slis/metrics_test.go b/staging/src/k8s.io/component-base/metrics/prometheus/slis/metrics_test.go index b328c868d8b..621caaab31d 100644 --- a/staging/src/k8s.io/component-base/metrics/prometheus/slis/metrics_test.go +++ b/staging/src/k8s.io/component-base/metrics/prometheus/slis/metrics_test.go @@ -37,10 +37,10 @@ func TestObserveHealthcheck(t *testing.T) { initialState := Error healthcheckName := "healthcheck-a" initialOutput := ` - # HELP kubernetes_healthcheck [BETA] This metric records the result of a single healthcheck. + # HELP kubernetes_healthcheck [STABLE] This metric records the result of a single healthcheck. # TYPE kubernetes_healthcheck gauge kubernetes_healthcheck{name="healthcheck-a",type="healthz"} 0 - # HELP kubernetes_healthchecks_total [BETA] This metric records the results of all healthcheck. + # HELP kubernetes_healthchecks_total [STABLE] This metric records the results of all healthcheck. # TYPE kubernetes_healthchecks_total counter kubernetes_healthchecks_total{name="healthcheck-a",status="error",type="healthz"} 1 ` @@ -57,10 +57,10 @@ func TestObserveHealthcheck(t *testing.T) { hcType: "healthz", hcStatus: Success, want: ` - # HELP kubernetes_healthcheck [BETA] This metric records the result of a single healthcheck. + # HELP kubernetes_healthcheck [STABLE] This metric records the result of a single healthcheck. # TYPE kubernetes_healthcheck gauge kubernetes_healthcheck{name="healthcheck-a",type="healthz"} 1 - # HELP kubernetes_healthchecks_total [BETA] This metric records the results of all healthcheck. + # HELP kubernetes_healthchecks_total [STABLE] This metric records the results of all healthcheck. # TYPE kubernetes_healthchecks_total counter kubernetes_healthchecks_total{name="healthcheck-a",status="error",type="healthz"} 1 kubernetes_healthchecks_total{name="healthcheck-a",status="success",type="healthz"} 1 diff --git a/test/instrumentation/testdata/stable-metrics-list.yaml b/test/instrumentation/testdata/stable-metrics-list.yaml index 0f20ca5e0da..a62c76e42b9 100644 --- a/test/instrumentation/testdata/stable-metrics-list.yaml +++ b/test/instrumentation/testdata/stable-metrics-list.yaml @@ -96,23 +96,6 @@ labels: - name - stage -- name: healthcheck - namespace: kubernetes - help: This metric records the result of a single healthcheck. - type: Gauge - stabilityLevel: BETA - labels: - - name - - type -- name: healthchecks_total - namespace: kubernetes - help: This metric records the results of all healthcheck. - type: Counter - stabilityLevel: BETA - labels: - - name - - status - - type - name: registered_metrics_total help: The count of registered metrics broken by stability level and deprecation version. @@ -446,6 +429,23 @@ - priority - resource - unit +- name: healthcheck + namespace: kubernetes + help: This metric records the result of a single healthcheck. + type: Gauge + stabilityLevel: STABLE + labels: + - name + - type +- name: healthchecks_total + namespace: kubernetes + help: This metric records the results of all healthcheck. + type: Counter + stabilityLevel: STABLE + labels: + - name + - status + - type - name: evictions_total subsystem: node_collector help: Number of Node evictions that happened since current instance of NodeController