From 5c88880584e41ddbdd757edb93e8eb58eb07875d Mon Sep 17 00:00:00 2001 From: Jordan Liggitt Date: Mon, 23 Nov 2020 11:22:44 -0500 Subject: [PATCH] Restore beta os/arch labels on initial node registration --- pkg/kubelet/BUILD | 2 ++ pkg/kubelet/kubelet_node_status.go | 11 ++++++++--- pkg/kubelet/kubelet_node_status_test.go | 17 +++++++++++------ 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/pkg/kubelet/BUILD b/pkg/kubelet/BUILD index 54f6f0cbd8dcf..3e45c6af8b5dd 100644 --- a/pkg/kubelet/BUILD +++ b/pkg/kubelet/BUILD @@ -44,6 +44,7 @@ go_library( "//pkg/apis/core/v1/helper/qos:go_default_library", "//pkg/features:go_default_library", "//pkg/fieldpath:go_default_library", + "//pkg/kubelet/apis:go_default_library", "//pkg/kubelet/apis/config:go_default_library", "//pkg/kubelet/apis/podresources:go_default_library", "//pkg/kubelet/cadvisor:go_default_library", @@ -195,6 +196,7 @@ go_test( deps = [ "//pkg/apis/core/install:go_default_library", "//pkg/features:go_default_library", + "//pkg/kubelet/apis:go_default_library", "//pkg/kubelet/cadvisor/testing:go_default_library", "//pkg/kubelet/cm:go_default_library", "//pkg/kubelet/config:go_default_library", diff --git a/pkg/kubelet/kubelet_node_status.go b/pkg/kubelet/kubelet_node_status.go index cfc78297b0eba..83d306ee37b47 100644 --- a/pkg/kubelet/kubelet_node_status.go +++ b/pkg/kubelet/kubelet_node_status.go @@ -37,6 +37,7 @@ import ( "k8s.io/klog/v2" k8s_api_v1 "k8s.io/kubernetes/pkg/apis/core/v1" v1helper "k8s.io/kubernetes/pkg/apis/core/v1/helper" + kubeletapis "k8s.io/kubernetes/pkg/kubelet/apis" "k8s.io/kubernetes/pkg/kubelet/events" "k8s.io/kubernetes/pkg/kubelet/nodestatus" "k8s.io/kubernetes/pkg/kubelet/util" @@ -201,6 +202,8 @@ func (kl *Kubelet) updateDefaultLabels(initialNode, existingNode *v1.Node) bool v1.LabelOSStable, v1.LabelArchStable, v1.LabelWindowsBuild, + kubeletapis.LabelOS, + kubeletapis.LabelArch, } needsUpdate := false @@ -263,9 +266,11 @@ func (kl *Kubelet) initialNode(ctx context.Context) (*v1.Node, error) { ObjectMeta: metav1.ObjectMeta{ Name: string(kl.nodeName), Labels: map[string]string{ - v1.LabelHostname: kl.hostname, - v1.LabelOSStable: goruntime.GOOS, - v1.LabelArchStable: goruntime.GOARCH, + v1.LabelHostname: kl.hostname, + v1.LabelOSStable: goruntime.GOOS, + v1.LabelArchStable: goruntime.GOARCH, + kubeletapis.LabelOS: goruntime.GOOS, + kubeletapis.LabelArch: goruntime.GOARCH, }, }, Spec: v1.NodeSpec{ diff --git a/pkg/kubelet/kubelet_node_status_test.go b/pkg/kubelet/kubelet_node_status_test.go index fa70d0a14e038..654e7cbda6d86 100644 --- a/pkg/kubelet/kubelet_node_status_test.go +++ b/pkg/kubelet/kubelet_node_status_test.go @@ -49,6 +49,7 @@ import ( "k8s.io/client-go/rest" core "k8s.io/client-go/testing" "k8s.io/component-base/version" + kubeletapis "k8s.io/kubernetes/pkg/kubelet/apis" cadvisortest "k8s.io/kubernetes/pkg/kubelet/cadvisor/testing" "k8s.io/kubernetes/pkg/kubelet/cm" kubecontainer "k8s.io/kubernetes/pkg/kubelet/container" @@ -1136,9 +1137,11 @@ func TestRegisterWithApiServer(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ Name: testKubeletHostname, Labels: map[string]string{ - v1.LabelHostname: testKubeletHostname, - v1.LabelOSStable: goruntime.GOOS, - v1.LabelArchStable: goruntime.GOARCH, + v1.LabelHostname: testKubeletHostname, + v1.LabelOSStable: goruntime.GOOS, + v1.LabelArchStable: goruntime.GOARCH, + kubeletapis.LabelOS: goruntime.GOOS, + kubeletapis.LabelArch: goruntime.GOARCH, }, }, }, nil @@ -1181,9 +1184,11 @@ func TestTryRegisterWithApiServer(t *testing.T) { node := &v1.Node{ ObjectMeta: metav1.ObjectMeta{ Labels: map[string]string{ - v1.LabelHostname: testKubeletHostname, - v1.LabelOSStable: goruntime.GOOS, - v1.LabelArchStable: goruntime.GOARCH, + v1.LabelHostname: testKubeletHostname, + v1.LabelOSStable: goruntime.GOOS, + v1.LabelArchStable: goruntime.GOARCH, + kubeletapis.LabelOS: goruntime.GOOS, + kubeletapis.LabelArch: goruntime.GOARCH, }, }, }