Replaces modifying node object with returning a map of labels

- Adds label to update flow so can be picked up by an existing node
This commit is contained in:
Gab Satch 2019-11-12 16:50:43 -05:00
parent e852cd40f0
commit f8e90eb5b0
4 changed files with 14 additions and 11 deletions

View File

@ -155,6 +155,7 @@ func (kl *Kubelet) updateDefaultLabels(initialNode, existingNode *v1.Node) bool
v1.LabelInstanceType,
v1.LabelOSStable,
v1.LabelArchStable,
v1.LabelWindowsBuild,
kubeletapis.LabelOS,
kubeletapis.LabelArch,
}
@ -230,9 +231,13 @@ func (kl *Kubelet) initialNode(ctx context.Context) (*v1.Node, error) {
Unschedulable: !kl.registerSchedulable,
},
}
if err := addOSSpecificLabels(node); err != nil {
osLabels, err := getOSSpecificLabels()
if err != nil {
return nil, err
}
for label, value := range osLabels {
node.Labels[label] = value
}
nodeTaints := make([]v1.Taint, 0)
if len(kl.registerWithTaints) > 0 {

View File

@ -18,10 +18,6 @@ limitations under the License.
package kubelet
import (
v1 "k8s.io/api/core/v1"
)
func addOSSpecificLabels(n *v1.Node) error {
return nil
func getOSSpecificLabels() (map[string]string, error) {
return nil, nil
}

View File

@ -23,11 +23,11 @@ import (
"k8s.io/kubernetes/pkg/kubelet/winstats"
)
func addOSSpecificLabels(n *v1.Node) error {
func getOSSpecificLabels() (map[string]string, error) {
osInfo, err := winstats.GetOSInfo()
if err != nil {
return err
return nil, err
}
n.Labels[v1.LabelWindowsBuild] = osInfo.GetBuild()
return nil
return map[string]string{v1.LabelWindowsBuild: osInfo.GetBuild()}, nil
}

View File

@ -26,6 +26,8 @@ const (
LabelOSStable = "kubernetes.io/os"
LabelArchStable = "kubernetes.io/arch"
// LabelWindowsBuild is used on Windows nodes to specify the Windows build number starting with v1.17.0.
// It's in the format MajorVersion.MinorVersion.BuildNumber (for ex: 10.0.17763)
LabelWindowsBuild = "node.kubernetes.io/windows-build"
// LabelNamespaceSuffixKubelet is an allowed label namespace suffix kubelets can self-set ([*.]kubelet.kubernetes.io/*)