Remove the 'beta' version of the node label (os and arch types)

This commit is contained in:
wawa0210 2020-05-13 08:22:43 +08:00
parent 6acceaeb2d
commit 54c0f8b677
No known key found for this signature in database
GPG Key ID: 900C83A2C098B3B1
6 changed files with 57 additions and 83 deletions

View File

@ -145,21 +145,17 @@ var labelReconcileInfo = []struct {
ensureSecondaryExists bool
}{
{
// Reconcile the beta and the stable OS label using the beta label as
// the source of truth.
// TODO(#73084): switch to using the stable label as the source of
// truth in v1.18.
primaryKey: kubeletapis.LabelOS,
secondaryKey: v1.LabelOSStable,
// Reconcile the beta and the stable OS label using the stable label as the source of truth.
// TODO(#89477): no earlier than 1.22: drop the beta labels if they differ from the GA labels
primaryKey: v1.LabelOSStable,
secondaryKey: kubeletapis.LabelOS,
ensureSecondaryExists: true,
},
{
// Reconcile the beta and the stable arch label using the beta label as
// the source of truth.
// TODO(#73084): switch to using the stable label as the source of
// truth in v1.18.
primaryKey: kubeletapis.LabelArch,
secondaryKey: v1.LabelArchStable,
// Reconcile the beta and the stable arch label using the stable label as the source of truth.
// TODO(#89477): no earlier than 1.22: drop the beta labels if they differ from the GA labels
primaryKey: v1.LabelArchStable,
secondaryKey: kubeletapis.LabelArch,
ensureSecondaryExists: true,
},
}

View File

@ -3288,14 +3288,14 @@ func TestReconcileNodeLabels(t *testing.T) {
},
},
{
Name: "Create OS/arch stable labels when they don't exist",
Name: "Create OS/arch beta labels when they don't exist",
Node: &v1.Node{
ObjectMeta: metav1.ObjectMeta{
Name: "node0",
CreationTimestamp: metav1.Date(2012, 1, 1, 0, 0, 0, 0, time.UTC),
Labels: map[string]string{
kubeletapis.LabelOS: "linux",
kubeletapis.LabelArch: "amd64",
v1.LabelOSStable: "linux",
v1.LabelArchStable: "amd64",
},
},
},
@ -3307,16 +3307,16 @@ func TestReconcileNodeLabels(t *testing.T) {
},
},
{
Name: "Reconcile OS/arch stable labels to match beta labels",
Name: "Reconcile OS/arch beta labels to match stable labels",
Node: &v1.Node{
ObjectMeta: metav1.ObjectMeta{
Name: "node0",
CreationTimestamp: metav1.Date(2012, 1, 1, 0, 0, 0, 0, time.UTC),
Labels: map[string]string{
kubeletapis.LabelOS: "linux",
kubeletapis.LabelArch: "amd64",
v1.LabelOSStable: "windows",
v1.LabelArchStable: "arm",
kubeletapis.LabelOS: "windows",
kubeletapis.LabelArch: "arm",
v1.LabelOSStable: "linux",
v1.LabelArchStable: "amd64",
},
},
},

View File

@ -43,7 +43,6 @@ 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",
@ -184,7 +183,6 @@ 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",

View File

@ -25,14 +25,10 @@ import (
const (
// LabelOS is a label to indicate the operating system of the node.
// The OS labels are promoted to GA in 1.14. kubelet applies both beta
// and GA labels to ensure backward compatibility.
// TODO: stop applying the beta OS labels in Kubernetes 1.18.
// The OS labels are promoted to GA in 1.14. kubelet applies GA labels and stop applying the beta OS labels in Kubernetes 1.19.
LabelOS = "beta.kubernetes.io/os"
// LabelArch is a label to indicate the architecture of the node.
// The Arch labels are promoted to GA in 1.14. kubelet applies both beta
// and GA labels to ensure backward compatibility.
// TODO: stop applying the beta Arch labels in Kubernetes 1.18.
// The Arch labels are promoted to GA in 1.14. kubelet applies GA labels and stop applying the beta Arch labels in Kubernetes 1.19.
LabelArch = "beta.kubernetes.io/arch"
)

View File

@ -36,7 +36,6 @@ import (
"k8s.io/klog"
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"
@ -157,8 +156,6 @@ func (kl *Kubelet) updateDefaultLabels(initialNode, existingNode *v1.Node) bool
v1.LabelOSStable,
v1.LabelArchStable,
v1.LabelWindowsBuild,
kubeletapis.LabelOS,
kubeletapis.LabelArch,
}
needsUpdate := false
@ -221,11 +218,9 @@ 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,
kubeletapis.LabelOS: goruntime.GOOS,
kubeletapis.LabelArch: goruntime.GOARCH,
v1.LabelHostname: kl.hostname,
v1.LabelOSStable: goruntime.GOOS,
v1.LabelArchStable: goruntime.GOARCH,
},
},
Spec: v1.NodeSpec{

View File

@ -49,7 +49,6 @@ 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"
@ -1131,11 +1130,9 @@ 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,
kubeletapis.LabelOS: goruntime.GOOS,
kubeletapis.LabelArch: goruntime.GOARCH,
v1.LabelHostname: testKubeletHostname,
v1.LabelOSStable: goruntime.GOOS,
v1.LabelArchStable: goruntime.GOARCH,
},
},
}, nil
@ -1178,11 +1175,9 @@ 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,
kubeletapis.LabelOS: goruntime.GOOS,
kubeletapis.LabelArch: goruntime.GOARCH,
v1.LabelHostname: testKubeletHostname,
v1.LabelOSStable: goruntime.GOOS,
v1.LabelArchStable: goruntime.GOARCH,
},
},
}
@ -1417,8 +1412,8 @@ func TestUpdateDefaultLabels(t *testing.T) {
v1.LabelZoneRegion: "new-zone-region",
v1.LabelInstanceTypeStable: "new-instance-type",
v1.LabelInstanceType: "new-instance-type",
kubeletapis.LabelOS: "new-os",
kubeletapis.LabelArch: "new-arch",
v1.LabelOSStable: "new-os",
v1.LabelArchStable: "new-arch",
},
},
},
@ -1436,8 +1431,8 @@ func TestUpdateDefaultLabels(t *testing.T) {
v1.LabelZoneRegion: "new-zone-region",
v1.LabelInstanceTypeStable: "new-instance-type",
v1.LabelInstanceType: "new-instance-type",
kubeletapis.LabelOS: "new-os",
kubeletapis.LabelArch: "new-arch",
v1.LabelOSStable: "new-os",
v1.LabelArchStable: "new-arch",
},
},
{
@ -1452,8 +1447,8 @@ func TestUpdateDefaultLabels(t *testing.T) {
v1.LabelZoneRegion: "new-zone-region",
v1.LabelInstanceTypeStable: "new-instance-type",
v1.LabelInstanceType: "new-instance-type",
kubeletapis.LabelOS: "new-os",
kubeletapis.LabelArch: "new-arch",
v1.LabelOSStable: "new-os",
v1.LabelArchStable: "new-arch",
},
},
},
@ -1467,8 +1462,8 @@ func TestUpdateDefaultLabels(t *testing.T) {
v1.LabelZoneRegion: "old-zone-region",
v1.LabelInstanceTypeStable: "old-instance-type",
v1.LabelInstanceType: "old-instance-type",
kubeletapis.LabelOS: "old-os",
kubeletapis.LabelArch: "old-arch",
v1.LabelOSStable: "old-os",
v1.LabelArchStable: "old-arch",
},
},
},
@ -1481,8 +1476,8 @@ func TestUpdateDefaultLabels(t *testing.T) {
v1.LabelZoneRegion: "new-zone-region",
v1.LabelInstanceTypeStable: "new-instance-type",
v1.LabelInstanceType: "new-instance-type",
kubeletapis.LabelOS: "new-os",
kubeletapis.LabelArch: "new-arch",
v1.LabelOSStable: "new-os",
v1.LabelArchStable: "new-arch",
},
},
{
@ -1497,8 +1492,8 @@ func TestUpdateDefaultLabels(t *testing.T) {
v1.LabelZoneRegion: "new-zone-region",
v1.LabelInstanceTypeStable: "new-instance-type",
v1.LabelInstanceType: "new-instance-type",
kubeletapis.LabelOS: "new-os",
kubeletapis.LabelArch: "new-arch",
v1.LabelOSStable: "new-os",
v1.LabelArchStable: "new-arch",
},
},
},
@ -1512,8 +1507,8 @@ func TestUpdateDefaultLabels(t *testing.T) {
v1.LabelZoneRegion: "new-zone-region",
v1.LabelInstanceTypeStable: "new-instance-type",
v1.LabelInstanceType: "new-instance-type",
kubeletapis.LabelOS: "new-os",
kubeletapis.LabelArch: "new-arch",
v1.LabelOSStable: "new-os",
v1.LabelArchStable: "new-arch",
"please-persist": "foo",
},
},
@ -1527,8 +1522,8 @@ func TestUpdateDefaultLabels(t *testing.T) {
v1.LabelZoneRegion: "new-zone-region",
v1.LabelInstanceTypeStable: "new-instance-type",
v1.LabelInstanceType: "new-instance-type",
kubeletapis.LabelOS: "new-os",
kubeletapis.LabelArch: "new-arch",
v1.LabelOSStable: "new-os",
v1.LabelArchStable: "new-arch",
"please-persist": "foo",
},
},
@ -1549,8 +1544,8 @@ func TestUpdateDefaultLabels(t *testing.T) {
v1.LabelZoneRegion: "new-zone-region",
v1.LabelInstanceTypeStable: "new-instance-type",
v1.LabelInstanceType: "new-instance-type",
kubeletapis.LabelOS: "new-os",
kubeletapis.LabelArch: "new-arch",
v1.LabelOSStable: "new-os",
v1.LabelArchStable: "new-arch",
"please-persist": "foo",
},
},
@ -1564,8 +1559,8 @@ func TestUpdateDefaultLabels(t *testing.T) {
v1.LabelZoneRegion: "new-zone-region",
v1.LabelInstanceTypeStable: "new-instance-type",
v1.LabelInstanceType: "new-instance-type",
kubeletapis.LabelOS: "new-os",
kubeletapis.LabelArch: "new-arch",
v1.LabelOSStable: "new-os",
v1.LabelArchStable: "new-arch",
"please-persist": "foo",
},
},
@ -1581,8 +1576,8 @@ func TestUpdateDefaultLabels(t *testing.T) {
v1.LabelZoneRegion: "new-zone-region",
v1.LabelInstanceTypeStable: "new-instance-type",
v1.LabelInstanceType: "new-instance-type",
kubeletapis.LabelOS: "new-os",
kubeletapis.LabelArch: "new-arch",
v1.LabelOSStable: "new-os",
v1.LabelArchStable: "new-arch",
},
},
},
@ -1596,8 +1591,8 @@ func TestUpdateDefaultLabels(t *testing.T) {
v1.LabelZoneRegion: "new-zone-region",
v1.LabelInstanceTypeStable: "new-instance-type",
v1.LabelInstanceType: "new-instance-type",
kubeletapis.LabelOS: "new-os",
kubeletapis.LabelArch: "new-arch",
v1.LabelOSStable: "new-os",
v1.LabelArchStable: "new-arch",
},
},
},
@ -1610,8 +1605,8 @@ func TestUpdateDefaultLabels(t *testing.T) {
v1.LabelZoneRegion: "new-zone-region",
v1.LabelInstanceTypeStable: "new-instance-type",
v1.LabelInstanceType: "new-instance-type",
kubeletapis.LabelOS: "new-os",
kubeletapis.LabelArch: "new-arch",
v1.LabelOSStable: "new-os",
v1.LabelArchStable: "new-arch",
},
},
{
@ -1626,8 +1621,8 @@ func TestUpdateDefaultLabels(t *testing.T) {
v1.LabelZoneRegion: "new-zone-region",
v1.LabelInstanceTypeStable: "new-instance-type",
v1.LabelInstanceType: "new-instance-type",
kubeletapis.LabelOS: "new-os",
kubeletapis.LabelArch: "new-arch",
v1.LabelOSStable: "new-os",
v1.LabelArchStable: "new-arch",
},
},
},
@ -1643,8 +1638,8 @@ func TestUpdateDefaultLabels(t *testing.T) {
v1.LabelZoneRegion: "new-zone-region",
v1.LabelInstanceTypeStable: "new-instance-type",
v1.LabelInstanceType: "new-instance-type",
kubeletapis.LabelOS: "new-os",
kubeletapis.LabelArch: "new-arch",
v1.LabelOSStable: "new-os",
v1.LabelArchStable: "new-arch",
},
},
{
@ -1659,8 +1654,6 @@ func TestUpdateDefaultLabels(t *testing.T) {
v1.LabelZoneRegion: "new-zone-region",
v1.LabelInstanceTypeStable: "new-instance-type",
v1.LabelInstanceType: "new-instance-type",
kubeletapis.LabelOS: "new-os",
kubeletapis.LabelArch: "new-arch",
v1.LabelOSStable: "new-os",
v1.LabelArchStable: "new-arch",
},
@ -1673,8 +1666,6 @@ func TestUpdateDefaultLabels(t *testing.T) {
v1.LabelZoneFailureDomain: "new-zone-failure-domain",
v1.LabelZoneRegion: "new-zone-region",
v1.LabelInstanceType: "new-instance-type",
kubeletapis.LabelOS: "new-os",
kubeletapis.LabelArch: "new-arch",
},
},
},
@ -1687,8 +1678,6 @@ func TestUpdateDefaultLabels(t *testing.T) {
v1.LabelZoneRegion: "new-zone-region",
v1.LabelInstanceTypeStable: "new-instance-type",
v1.LabelInstanceType: "new-instance-type",
kubeletapis.LabelOS: "new-os",
kubeletapis.LabelArch: "new-arch",
v1.LabelOSStable: "new-os",
v1.LabelArchStable: "new-arch",
},