mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 19:01:49 +00:00
Do not remove kubelet labels during startup
This commit is contained in:
parent
d24d368845
commit
9df1f7ef11
@ -169,6 +169,10 @@ func (kl *Kubelet) updateDefaultLabels(initialNode, existingNode *v1.Node) bool
|
||||
var needsUpdate bool = false
|
||||
//Set default labels but make sure to not set labels with empty values
|
||||
for _, label := range defaultLabels {
|
||||
if _, hasInitialValue := initialNode.Labels[label]; !hasInitialValue {
|
||||
continue
|
||||
}
|
||||
|
||||
if existingNode.Labels[label] != initialNode.Labels[label] {
|
||||
existingNode.Labels[label] = initialNode.Labels[label]
|
||||
needsUpdate = true
|
||||
|
@ -1233,6 +1233,37 @@ func TestUpdateDefaultLabels(t *testing.T) {
|
||||
"please-persist": "foo",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "make sure existing labels do not get deleted when initial node has no opinion",
|
||||
initialNode: &v1.Node{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Labels: map[string]string{},
|
||||
},
|
||||
},
|
||||
existingNode: &v1.Node{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
kubeletapis.LabelHostname: "new-hostname",
|
||||
kubeletapis.LabelZoneFailureDomain: "new-zone-failure-domain",
|
||||
kubeletapis.LabelZoneRegion: "new-zone-region",
|
||||
kubeletapis.LabelInstanceType: "new-instance-type",
|
||||
kubeletapis.LabelOS: "new-os",
|
||||
kubeletapis.LabelArch: "new-arch",
|
||||
"please-persist": "foo",
|
||||
},
|
||||
},
|
||||
},
|
||||
needsUpdate: false,
|
||||
finalLabels: map[string]string{
|
||||
kubeletapis.LabelHostname: "new-hostname",
|
||||
kubeletapis.LabelZoneFailureDomain: "new-zone-failure-domain",
|
||||
kubeletapis.LabelZoneRegion: "new-zone-region",
|
||||
kubeletapis.LabelInstanceType: "new-instance-type",
|
||||
kubeletapis.LabelOS: "new-os",
|
||||
kubeletapis.LabelArch: "new-arch",
|
||||
"please-persist": "foo",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "no update needed",
|
||||
initialNode: &v1.Node{
|
||||
|
Loading…
Reference in New Issue
Block a user