mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 19:31:44 +00:00
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:
parent
e852cd40f0
commit
f8e90eb5b0
@ -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 {
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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/*)
|
||||
|
Loading…
Reference in New Issue
Block a user