File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed
staging/src/k8s.io/cloud-provider/controllers/node Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -550,7 +550,7 @@ func (cnc *CloudNodeController) getNodeModifiersFromCloudProvider(
550
550
n .Labels = map [string ]string {}
551
551
}
552
552
553
- k8sNamespaceRegex := regexp .MustCompile ("( kubernetes|k8s).io/" )
553
+ k8sNamespaceRegex := regexp .MustCompile (`(^|\.)( kubernetes|k8s)\ .io/` )
554
554
for k , v := range instanceMeta .AdditionalLabels {
555
555
// Cloud provider should not be using kubernetes namespaces in labels
556
556
if isK8sNamespace := k8sNamespaceRegex .MatchString (k ); isK8sNamespace {
Original file line number Diff line number Diff line change @@ -1598,9 +1598,14 @@ func Test_syncNode(t *testing.T) {
1598
1598
// and should be discarded
1599
1599
"topology.kubernetes.io/region" : "us-other-west" ,
1600
1600
"topology.k8s.io/region" : "us-other-west" ,
1601
+ "kubernetes.io/region" : "us-other-west" ,
1602
+ "k8s.io/region" : "us-other-west" ,
1601
1603
// Should discard labels that already exist
1602
1604
"my.custom.label/foo" : "bar" ,
1603
1605
"my.custom.label/bar" : "foo" ,
1606
+ // Should add labels that not match regex
1607
+ "app.k8snio/bar" : "foo" ,
1608
+ "k8snio/bar" : "foo" ,
1604
1609
},
1605
1610
},
1606
1611
existingNode : & v1.Node {
@@ -1661,6 +1666,8 @@ func Test_syncNode(t *testing.T) {
1661
1666
"topology.kubernetes.io/zone" : "us-west-1a" ,
1662
1667
"my.custom.label/foo" : "fizz" ,
1663
1668
"my.custom.label/bar" : "foo" ,
1669
+ "app.k8snio/bar" : "foo" ,
1670
+ "k8snio/bar" : "foo" ,
1664
1671
},
1665
1672
},
1666
1673
Spec : v1.NodeSpec {
You can’t perform that action at this time.
0 commit comments