From 9ea63112147c875d5d76c373b891c9d189c0e9df Mon Sep 17 00:00:00 2001 From: Damien Grisonnet Date: Tue, 5 Mar 2024 15:02:16 +0100 Subject: [PATCH] pkg/api: fix singular name With the 1.27 Kubernetes upgrade, a new GetSingularName method needed to be implemented by the metrics rest.Storage. While doing it, we set a value for the singular name of the resources when it used to be empty. Due to that, the kube-apiserver stop guessing the resource name based on its Kind, which broken kubectl get PodMetrics/NodeMetrics. To fix that, we need to blank out the singular name of the resources, otherwise we will be stuck with the following commands: - kubectl get pod.metric - kubectl get node.metric Instead of the more commonly used: - kubectl get PodMetrics - kubectl get NodeMetrics Signed-off-by: Damien Grisonnet --- pkg/api/node.go | 2 +- pkg/api/pod.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/api/node.go b/pkg/api/node.go index bec2d22d2..5c4ed0460 100644 --- a/pkg/api/node.go +++ b/pkg/api/node.go @@ -178,5 +178,5 @@ func (m *nodeMetrics) NamespaceScoped() bool { // GetSingularName implements rest.SingularNameProvider interface func (m *nodeMetrics) GetSingularName() string { - return "node" + return "" } diff --git a/pkg/api/pod.go b/pkg/api/pod.go index 508ab2a8b..2cca539cc 100644 --- a/pkg/api/pod.go +++ b/pkg/api/pod.go @@ -185,5 +185,5 @@ func (m *podMetrics) NamespaceScoped() bool { // GetSingularName implements rest.SingularNameProvider interface func (m *podMetrics) GetSingularName() string { - return "pod" + return "" }