Skip to content

Commit 6ec3ea8

Browse files
authored
Merge pull request kubernetes#85282 from serathius/flag-kubelet
Add show-hidden-metrics-for-version to kubelet
2 parents 322b2fe + d44d5b3 commit 6ec3ea8

File tree

8 files changed

+26
-0
lines changed

8 files changed

+26
-0
lines changed

cmd/kubelet/app/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ go_library(
139139
"//staging/src/k8s.io/cloud-provider:go_default_library",
140140
"//staging/src/k8s.io/component-base/cli/flag:go_default_library",
141141
"//staging/src/k8s.io/component-base/featuregate:go_default_library",
142+
"//staging/src/k8s.io/component-base/metrics:go_default_library",
142143
"//staging/src/k8s.io/component-base/version:go_default_library",
143144
"//staging/src/k8s.io/component-base/version/verflag:go_default_library",
144145
"//staging/src/k8s.io/csi-translation-lib/plugins:go_default_library",

cmd/kubelet/app/server.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ import (
6262
cloudprovider "k8s.io/cloud-provider"
6363
cliflag "k8s.io/component-base/cli/flag"
6464
"k8s.io/component-base/featuregate"
65+
"k8s.io/component-base/metrics"
6566
"k8s.io/component-base/version"
6667
"k8s.io/component-base/version/verflag"
6768
kubeletconfigv1beta1 "k8s.io/kubelet/config/v1beta1"
@@ -509,6 +510,10 @@ func run(s *options.KubeletServer, kubeDeps *kubelet.Dependencies, featureGate f
509510
klog.Errorf("unable to register KubeletConfiguration with configz, error: %v", err)
510511
}
511512

513+
if len(s.ShowHiddenMetricsForVersion) > 0 {
514+
metrics.SetShowHidden()
515+
}
516+
512517
// About to get clients and such, detect standaloneMode
513518
standaloneMode := true
514519
if len(s.KubeConfig) > 0 {

pkg/kubelet/apis/config/helpers_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ var (
215215
"ReservedSystemCPUs",
216216
"RuntimeRequestTimeout.Duration",
217217
"SerializeImagePulls",
218+
"ShowHiddenMetricsForVersion",
218219
"StreamingConnectionIdleTimeout.Duration",
219220
"SyncFrequency.Duration",
220221
"SystemCgroups",

pkg/kubelet/apis/config/types.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,12 @@ type KubeletConfiguration struct {
335335
// This provide a "static" CPU list rather than the "dynamic" list by system-reserved and kube-reserved.
336336
// This option overwrites CPUs provided by system-reserved and kube-reserved.
337337
ReservedSystemCPUs string
338+
// The previous version for which you want to show hidden metrics.
339+
// Only the previous minor version is meaningful, other values will not be allowed.
340+
// The format is <major>.<minor>, e.g.: '1.16'.
341+
// The purpose of this format is make sure you have the opportunity to notice if the next release hides additional metrics,
342+
// rather than being surprised when they are permanently removed in the release after that.
343+
ShowHiddenMetricsForVersion string
338344
}
339345

340346
// KubeletAuthorizationMode denotes the authorization mode for the kubelet

pkg/kubelet/apis/config/v1beta1/zz_generated.conversion.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/kubelet/apis/config/validation/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ go_library(
2222
"//staging/src/k8s.io/apimachinery/pkg/util/errors:go_default_library",
2323
"//staging/src/k8s.io/apimachinery/pkg/util/validation:go_default_library",
2424
"//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library",
25+
"//staging/src/k8s.io/component-base/metrics:go_default_library",
2526
],
2627
)
2728

pkg/kubelet/apis/config/validation/validation.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
utilerrors "k8s.io/apimachinery/pkg/util/errors"
2424
utilvalidation "k8s.io/apimachinery/pkg/util/validation"
2525
utilfeature "k8s.io/apiserver/pkg/util/feature"
26+
"k8s.io/component-base/metrics"
2627
"k8s.io/kubernetes/pkg/features"
2728
kubeletconfig "k8s.io/kubernetes/pkg/kubelet/apis/config"
2829
"k8s.io/kubernetes/pkg/kubelet/cm/cpuset"
@@ -156,5 +157,6 @@ func ValidateKubeletConfiguration(kc *kubeletconfig.KubeletConfiguration) error
156157
if err := validateKubeletOSConfiguration(kc); err != nil {
157158
allErrors = append(allErrors, err)
158159
}
160+
allErrors = append(allErrors, metrics.ValidateShowHiddenMetricsVersion(kc.ShowHiddenMetricsForVersion)...)
159161
return utilerrors.NewAggregate(allErrors)
160162
}

staging/src/k8s.io/kubelet/config/v1beta1/types.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,14 @@ type KubeletConfiguration struct {
714714
// This provide a "static" CPU list rather than the "dynamic" list by system-reserved and kube-reserved.
715715
// This option overwrites CPUs provided by system-reserved and kube-reserved.
716716
ReservedSystemCPUs string `json:"reservedSystemCPUs,omitempty"`
717+
// The previous version for which you want to show hidden metrics.
718+
// Only the previous minor version is meaningful, other values will not be allowed.
719+
// The format is <major>.<minor>, e.g.: '1.16'.
720+
// The purpose of this format is make sure you have the opportunity to notice if the next release hides additional metrics,
721+
// rather than being surprised when they are permanently removed in the release after that.
722+
// Default: ""
723+
// +optional
724+
ShowHiddenMetricsForVersion string `json:"showHiddenMetricsForVersion,omitempty"`
717725
// This flag helps kubelet identify absolute name of top level cgroup used to enforce `SystemReserved` compute resource reservation for OS system daemons.
718726
// Refer to [Node Allocatable](https://git.k8s.io/community/contributors/design-proposals/node/node-allocatable.md) doc for more information.
719727
// Dynamic Kubelet Config (beta): This field should not be updated without a full node

0 commit comments

Comments
 (0)