...
1
16
17 package patchnode
18
19 import (
20 "k8s.io/api/core/v1"
21 clientset "k8s.io/client-go/kubernetes"
22 "k8s.io/klog/v2"
23
24 "k8s.io/kubernetes/cmd/kubeadm/app/constants"
25 "k8s.io/kubernetes/cmd/kubeadm/app/util/apiclient"
26 )
27
28
29 func AnnotateCRISocket(client clientset.Interface, nodeName string, criSocket string) error {
30
31 klog.V(1).Infof("[patchnode] Uploading the CRI Socket information %q to the Node API object %q as an annotation\n", criSocket, nodeName)
32
33 return apiclient.PatchNode(client, nodeName, func(n *v1.Node) {
34 annotateNodeWithCRISocket(n, criSocket)
35 })
36 }
37
38 func annotateNodeWithCRISocket(n *v1.Node, criSocket string) {
39 if n.ObjectMeta.Annotations == nil {
40 n.ObjectMeta.Annotations = make(map[string]string)
41 }
42 n.ObjectMeta.Annotations[constants.AnnotationKubeadmCRISocket] = criSocket
43 }
44
View as plain text