Skip to content

Commit 8a9206c

Browse files
authored
Merge pull request kubernetes#91046 from wawa0210/remove-beta-os-label
kubelet no longer registers "beta.kubernetes.io/os" and "beta.kubernetes.io/arch" node labels to apiserver
2 parents 678415a + 54c0f8b commit 8a9206c

File tree

6 files changed

+57
-83
lines changed

6 files changed

+57
-83
lines changed

pkg/controller/nodelifecycle/node_lifecycle_controller.go

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -145,21 +145,17 @@ var labelReconcileInfo = []struct {
145145
ensureSecondaryExists bool
146146
}{
147147
{
148-
// Reconcile the beta and the stable OS label using the beta label as
149-
// the source of truth.
150-
// TODO(#73084): switch to using the stable label as the source of
151-
// truth in v1.18.
152-
primaryKey: kubeletapis.LabelOS,
153-
secondaryKey: v1.LabelOSStable,
148+
// Reconcile the beta and the stable OS label using the stable label as the source of truth.
149+
// TODO(#89477): no earlier than 1.22: drop the beta labels if they differ from the GA labels
150+
primaryKey: v1.LabelOSStable,
151+
secondaryKey: kubeletapis.LabelOS,
154152
ensureSecondaryExists: true,
155153
},
156154
{
157-
// Reconcile the beta and the stable arch label using the beta label as
158-
// the source of truth.
159-
// TODO(#73084): switch to using the stable label as the source of
160-
// truth in v1.18.
161-
primaryKey: kubeletapis.LabelArch,
162-
secondaryKey: v1.LabelArchStable,
155+
// Reconcile the beta and the stable arch label using the stable label as the source of truth.
156+
// TODO(#89477): no earlier than 1.22: drop the beta labels if they differ from the GA labels
157+
primaryKey: v1.LabelArchStable,
158+
secondaryKey: kubeletapis.LabelArch,
163159
ensureSecondaryExists: true,
164160
},
165161
}

pkg/controller/nodelifecycle/node_lifecycle_controller_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3288,14 +3288,14 @@ func TestReconcileNodeLabels(t *testing.T) {
32883288
},
32893289
},
32903290
{
3291-
Name: "Create OS/arch stable labels when they don't exist",
3291+
Name: "Create OS/arch beta labels when they don't exist",
32923292
Node: &v1.Node{
32933293
ObjectMeta: metav1.ObjectMeta{
32943294
Name: "node0",
32953295
CreationTimestamp: metav1.Date(2012, 1, 1, 0, 0, 0, 0, time.UTC),
32963296
Labels: map[string]string{
3297-
kubeletapis.LabelOS: "linux",
3298-
kubeletapis.LabelArch: "amd64",
3297+
v1.LabelOSStable: "linux",
3298+
v1.LabelArchStable: "amd64",
32993299
},
33003300
},
33013301
},
@@ -3307,16 +3307,16 @@ func TestReconcileNodeLabels(t *testing.T) {
33073307
},
33083308
},
33093309
{
3310-
Name: "Reconcile OS/arch stable labels to match beta labels",
3310+
Name: "Reconcile OS/arch beta labels to match stable labels",
33113311
Node: &v1.Node{
33123312
ObjectMeta: metav1.ObjectMeta{
33133313
Name: "node0",
33143314
CreationTimestamp: metav1.Date(2012, 1, 1, 0, 0, 0, 0, time.UTC),
33153315
Labels: map[string]string{
3316-
kubeletapis.LabelOS: "linux",
3317-
kubeletapis.LabelArch: "amd64",
3318-
v1.LabelOSStable: "windows",
3319-
v1.LabelArchStable: "arm",
3316+
kubeletapis.LabelOS: "windows",
3317+
kubeletapis.LabelArch: "arm",
3318+
v1.LabelOSStable: "linux",
3319+
v1.LabelArchStable: "amd64",
33203320
},
33213321
},
33223322
},

pkg/kubelet/BUILD

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ go_library(
4343
"//pkg/apis/core/v1/helper/qos:go_default_library",
4444
"//pkg/features:go_default_library",
4545
"//pkg/fieldpath:go_default_library",
46-
"//pkg/kubelet/apis:go_default_library",
4746
"//pkg/kubelet/apis/config:go_default_library",
4847
"//pkg/kubelet/apis/podresources:go_default_library",
4948
"//pkg/kubelet/cadvisor:go_default_library",
@@ -184,7 +183,6 @@ go_test(
184183
deps = [
185184
"//pkg/apis/core/install:go_default_library",
186185
"//pkg/features:go_default_library",
187-
"//pkg/kubelet/apis:go_default_library",
188186
"//pkg/kubelet/cadvisor/testing:go_default_library",
189187
"//pkg/kubelet/cm:go_default_library",
190188
"//pkg/kubelet/config:go_default_library",

pkg/kubelet/apis/well_known_labels.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,10 @@ import (
2525

2626
const (
2727
// LabelOS is a label to indicate the operating system of the node.
28-
// The OS labels are promoted to GA in 1.14. kubelet applies both beta
29-
// and GA labels to ensure backward compatibility.
30-
// TODO: stop applying the beta OS labels in Kubernetes 1.18.
28+
// 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.
3129
LabelOS = "beta.kubernetes.io/os"
3230
// LabelArch is a label to indicate the architecture of the node.
33-
// The Arch labels are promoted to GA in 1.14. kubelet applies both beta
34-
// and GA labels to ensure backward compatibility.
35-
// TODO: stop applying the beta Arch labels in Kubernetes 1.18.
31+
// 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.
3632
LabelArch = "beta.kubernetes.io/arch"
3733
)
3834

pkg/kubelet/kubelet_node_status.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ import (
3636
"k8s.io/klog"
3737
k8s_api_v1 "k8s.io/kubernetes/pkg/apis/core/v1"
3838
v1helper "k8s.io/kubernetes/pkg/apis/core/v1/helper"
39-
kubeletapis "k8s.io/kubernetes/pkg/kubelet/apis"
4039
"k8s.io/kubernetes/pkg/kubelet/events"
4140
"k8s.io/kubernetes/pkg/kubelet/nodestatus"
4241
"k8s.io/kubernetes/pkg/kubelet/util"
@@ -157,8 +156,6 @@ func (kl *Kubelet) updateDefaultLabels(initialNode, existingNode *v1.Node) bool
157156
v1.LabelOSStable,
158157
v1.LabelArchStable,
159158
v1.LabelWindowsBuild,
160-
kubeletapis.LabelOS,
161-
kubeletapis.LabelArch,
162159
}
163160

164161
needsUpdate := false
@@ -221,11 +218,9 @@ func (kl *Kubelet) initialNode(ctx context.Context) (*v1.Node, error) {
221218
ObjectMeta: metav1.ObjectMeta{
222219
Name: string(kl.nodeName),
223220
Labels: map[string]string{
224-
v1.LabelHostname: kl.hostname,
225-
v1.LabelOSStable: goruntime.GOOS,
226-
v1.LabelArchStable: goruntime.GOARCH,
227-
kubeletapis.LabelOS: goruntime.GOOS,
228-
kubeletapis.LabelArch: goruntime.GOARCH,
221+
v1.LabelHostname: kl.hostname,
222+
v1.LabelOSStable: goruntime.GOOS,
223+
v1.LabelArchStable: goruntime.GOARCH,
229224
},
230225
},
231226
Spec: v1.NodeSpec{

pkg/kubelet/kubelet_node_status_test.go

Lines changed: 36 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ import (
4949
"k8s.io/client-go/rest"
5050
core "k8s.io/client-go/testing"
5151
"k8s.io/component-base/version"
52-
kubeletapis "k8s.io/kubernetes/pkg/kubelet/apis"
5352
cadvisortest "k8s.io/kubernetes/pkg/kubelet/cadvisor/testing"
5453
"k8s.io/kubernetes/pkg/kubelet/cm"
5554
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
@@ -1131,11 +1130,9 @@ func TestRegisterWithApiServer(t *testing.T) {
11311130
ObjectMeta: metav1.ObjectMeta{
11321131
Name: testKubeletHostname,
11331132
Labels: map[string]string{
1134-
v1.LabelHostname: testKubeletHostname,
1135-
v1.LabelOSStable: goruntime.GOOS,
1136-
v1.LabelArchStable: goruntime.GOARCH,
1137-
kubeletapis.LabelOS: goruntime.GOOS,
1138-
kubeletapis.LabelArch: goruntime.GOARCH,
1133+
v1.LabelHostname: testKubeletHostname,
1134+
v1.LabelOSStable: goruntime.GOOS,
1135+
v1.LabelArchStable: goruntime.GOARCH,
11391136
},
11401137
},
11411138
}, nil
@@ -1178,11 +1175,9 @@ func TestTryRegisterWithApiServer(t *testing.T) {
11781175
node := &v1.Node{
11791176
ObjectMeta: metav1.ObjectMeta{
11801177
Labels: map[string]string{
1181-
v1.LabelHostname: testKubeletHostname,
1182-
v1.LabelOSStable: goruntime.GOOS,
1183-
v1.LabelArchStable: goruntime.GOARCH,
1184-
kubeletapis.LabelOS: goruntime.GOOS,
1185-
kubeletapis.LabelArch: goruntime.GOARCH,
1178+
v1.LabelHostname: testKubeletHostname,
1179+
v1.LabelOSStable: goruntime.GOOS,
1180+
v1.LabelArchStable: goruntime.GOARCH,
11861181
},
11871182
},
11881183
}
@@ -1417,8 +1412,8 @@ func TestUpdateDefaultLabels(t *testing.T) {
14171412
v1.LabelZoneRegion: "new-zone-region",
14181413
v1.LabelInstanceTypeStable: "new-instance-type",
14191414
v1.LabelInstanceType: "new-instance-type",
1420-
kubeletapis.LabelOS: "new-os",
1421-
kubeletapis.LabelArch: "new-arch",
1415+
v1.LabelOSStable: "new-os",
1416+
v1.LabelArchStable: "new-arch",
14221417
},
14231418
},
14241419
},
@@ -1436,8 +1431,8 @@ func TestUpdateDefaultLabels(t *testing.T) {
14361431
v1.LabelZoneRegion: "new-zone-region",
14371432
v1.LabelInstanceTypeStable: "new-instance-type",
14381433
v1.LabelInstanceType: "new-instance-type",
1439-
kubeletapis.LabelOS: "new-os",
1440-
kubeletapis.LabelArch: "new-arch",
1434+
v1.LabelOSStable: "new-os",
1435+
v1.LabelArchStable: "new-arch",
14411436
},
14421437
},
14431438
{
@@ -1452,8 +1447,8 @@ func TestUpdateDefaultLabels(t *testing.T) {
14521447
v1.LabelZoneRegion: "new-zone-region",
14531448
v1.LabelInstanceTypeStable: "new-instance-type",
14541449
v1.LabelInstanceType: "new-instance-type",
1455-
kubeletapis.LabelOS: "new-os",
1456-
kubeletapis.LabelArch: "new-arch",
1450+
v1.LabelOSStable: "new-os",
1451+
v1.LabelArchStable: "new-arch",
14571452
},
14581453
},
14591454
},
@@ -1467,8 +1462,8 @@ func TestUpdateDefaultLabels(t *testing.T) {
14671462
v1.LabelZoneRegion: "old-zone-region",
14681463
v1.LabelInstanceTypeStable: "old-instance-type",
14691464
v1.LabelInstanceType: "old-instance-type",
1470-
kubeletapis.LabelOS: "old-os",
1471-
kubeletapis.LabelArch: "old-arch",
1465+
v1.LabelOSStable: "old-os",
1466+
v1.LabelArchStable: "old-arch",
14721467
},
14731468
},
14741469
},
@@ -1481,8 +1476,8 @@ func TestUpdateDefaultLabels(t *testing.T) {
14811476
v1.LabelZoneRegion: "new-zone-region",
14821477
v1.LabelInstanceTypeStable: "new-instance-type",
14831478
v1.LabelInstanceType: "new-instance-type",
1484-
kubeletapis.LabelOS: "new-os",
1485-
kubeletapis.LabelArch: "new-arch",
1479+
v1.LabelOSStable: "new-os",
1480+
v1.LabelArchStable: "new-arch",
14861481
},
14871482
},
14881483
{
@@ -1497,8 +1492,8 @@ func TestUpdateDefaultLabels(t *testing.T) {
14971492
v1.LabelZoneRegion: "new-zone-region",
14981493
v1.LabelInstanceTypeStable: "new-instance-type",
14991494
v1.LabelInstanceType: "new-instance-type",
1500-
kubeletapis.LabelOS: "new-os",
1501-
kubeletapis.LabelArch: "new-arch",
1495+
v1.LabelOSStable: "new-os",
1496+
v1.LabelArchStable: "new-arch",
15021497
},
15031498
},
15041499
},
@@ -1512,8 +1507,8 @@ func TestUpdateDefaultLabels(t *testing.T) {
15121507
v1.LabelZoneRegion: "new-zone-region",
15131508
v1.LabelInstanceTypeStable: "new-instance-type",
15141509
v1.LabelInstanceType: "new-instance-type",
1515-
kubeletapis.LabelOS: "new-os",
1516-
kubeletapis.LabelArch: "new-arch",
1510+
v1.LabelOSStable: "new-os",
1511+
v1.LabelArchStable: "new-arch",
15171512
"please-persist": "foo",
15181513
},
15191514
},
@@ -1527,8 +1522,8 @@ func TestUpdateDefaultLabels(t *testing.T) {
15271522
v1.LabelZoneRegion: "new-zone-region",
15281523
v1.LabelInstanceTypeStable: "new-instance-type",
15291524
v1.LabelInstanceType: "new-instance-type",
1530-
kubeletapis.LabelOS: "new-os",
1531-
kubeletapis.LabelArch: "new-arch",
1525+
v1.LabelOSStable: "new-os",
1526+
v1.LabelArchStable: "new-arch",
15321527
"please-persist": "foo",
15331528
},
15341529
},
@@ -1549,8 +1544,8 @@ func TestUpdateDefaultLabels(t *testing.T) {
15491544
v1.LabelZoneRegion: "new-zone-region",
15501545
v1.LabelInstanceTypeStable: "new-instance-type",
15511546
v1.LabelInstanceType: "new-instance-type",
1552-
kubeletapis.LabelOS: "new-os",
1553-
kubeletapis.LabelArch: "new-arch",
1547+
v1.LabelOSStable: "new-os",
1548+
v1.LabelArchStable: "new-arch",
15541549
"please-persist": "foo",
15551550
},
15561551
},
@@ -1564,8 +1559,8 @@ func TestUpdateDefaultLabels(t *testing.T) {
15641559
v1.LabelZoneRegion: "new-zone-region",
15651560
v1.LabelInstanceTypeStable: "new-instance-type",
15661561
v1.LabelInstanceType: "new-instance-type",
1567-
kubeletapis.LabelOS: "new-os",
1568-
kubeletapis.LabelArch: "new-arch",
1562+
v1.LabelOSStable: "new-os",
1563+
v1.LabelArchStable: "new-arch",
15691564
"please-persist": "foo",
15701565
},
15711566
},
@@ -1581,8 +1576,8 @@ func TestUpdateDefaultLabels(t *testing.T) {
15811576
v1.LabelZoneRegion: "new-zone-region",
15821577
v1.LabelInstanceTypeStable: "new-instance-type",
15831578
v1.LabelInstanceType: "new-instance-type",
1584-
kubeletapis.LabelOS: "new-os",
1585-
kubeletapis.LabelArch: "new-arch",
1579+
v1.LabelOSStable: "new-os",
1580+
v1.LabelArchStable: "new-arch",
15861581
},
15871582
},
15881583
},
@@ -1596,8 +1591,8 @@ func TestUpdateDefaultLabels(t *testing.T) {
15961591
v1.LabelZoneRegion: "new-zone-region",
15971592
v1.LabelInstanceTypeStable: "new-instance-type",
15981593
v1.LabelInstanceType: "new-instance-type",
1599-
kubeletapis.LabelOS: "new-os",
1600-
kubeletapis.LabelArch: "new-arch",
1594+
v1.LabelOSStable: "new-os",
1595+
v1.LabelArchStable: "new-arch",
16011596
},
16021597
},
16031598
},
@@ -1610,8 +1605,8 @@ func TestUpdateDefaultLabels(t *testing.T) {
16101605
v1.LabelZoneRegion: "new-zone-region",
16111606
v1.LabelInstanceTypeStable: "new-instance-type",
16121607
v1.LabelInstanceType: "new-instance-type",
1613-
kubeletapis.LabelOS: "new-os",
1614-
kubeletapis.LabelArch: "new-arch",
1608+
v1.LabelOSStable: "new-os",
1609+
v1.LabelArchStable: "new-arch",
16151610
},
16161611
},
16171612
{
@@ -1626,8 +1621,8 @@ func TestUpdateDefaultLabels(t *testing.T) {
16261621
v1.LabelZoneRegion: "new-zone-region",
16271622
v1.LabelInstanceTypeStable: "new-instance-type",
16281623
v1.LabelInstanceType: "new-instance-type",
1629-
kubeletapis.LabelOS: "new-os",
1630-
kubeletapis.LabelArch: "new-arch",
1624+
v1.LabelOSStable: "new-os",
1625+
v1.LabelArchStable: "new-arch",
16311626
},
16321627
},
16331628
},
@@ -1643,8 +1638,8 @@ func TestUpdateDefaultLabels(t *testing.T) {
16431638
v1.LabelZoneRegion: "new-zone-region",
16441639
v1.LabelInstanceTypeStable: "new-instance-type",
16451640
v1.LabelInstanceType: "new-instance-type",
1646-
kubeletapis.LabelOS: "new-os",
1647-
kubeletapis.LabelArch: "new-arch",
1641+
v1.LabelOSStable: "new-os",
1642+
v1.LabelArchStable: "new-arch",
16481643
},
16491644
},
16501645
{
@@ -1659,8 +1654,6 @@ func TestUpdateDefaultLabels(t *testing.T) {
16591654
v1.LabelZoneRegion: "new-zone-region",
16601655
v1.LabelInstanceTypeStable: "new-instance-type",
16611656
v1.LabelInstanceType: "new-instance-type",
1662-
kubeletapis.LabelOS: "new-os",
1663-
kubeletapis.LabelArch: "new-arch",
16641657
v1.LabelOSStable: "new-os",
16651658
v1.LabelArchStable: "new-arch",
16661659
},
@@ -1673,8 +1666,6 @@ func TestUpdateDefaultLabels(t *testing.T) {
16731666
v1.LabelZoneFailureDomain: "new-zone-failure-domain",
16741667
v1.LabelZoneRegion: "new-zone-region",
16751668
v1.LabelInstanceType: "new-instance-type",
1676-
kubeletapis.LabelOS: "new-os",
1677-
kubeletapis.LabelArch: "new-arch",
16781669
},
16791670
},
16801671
},
@@ -1687,8 +1678,6 @@ func TestUpdateDefaultLabels(t *testing.T) {
16871678
v1.LabelZoneRegion: "new-zone-region",
16881679
v1.LabelInstanceTypeStable: "new-instance-type",
16891680
v1.LabelInstanceType: "new-instance-type",
1690-
kubeletapis.LabelOS: "new-os",
1691-
kubeletapis.LabelArch: "new-arch",
16921681
v1.LabelOSStable: "new-os",
16931682
v1.LabelArchStable: "new-arch",
16941683
},

0 commit comments

Comments
 (0)