...
1 package node
2
3 import (
4 "fmt"
5
6 corev1 "k8s.io/api/core/v1"
7
8 v1ien "edge-infra.dev/pkg/sds/ien/k8s/apis/v1"
9 )
10
11 const (
12
13 HostnameLabel string = "node.ncr.com/hostname"
14
15 RoleLabel string = "node.ncr.com/role"
16
17 LaneLabel string = "node.ncr.com/lane"
18
19
20 ClassLabel string = "node.ncr.com/class"
21
22
23 WorkerClassLabel string = "node.ncr.com/worker-class"
24
25 ControlPlaneLabel string = "node-role.kubernetes.io/control-plane"
26
27 TerminalIDLabel string = "node.ncr.com/terminal-id"
28 )
29
30 func IsTouchPointNode(node *corev1.Node) (bool, string) {
31 class := node.ObjectMeta.Labels[ClassLabel]
32 lane := node.ObjectMeta.Labels[LaneLabel]
33 if class == string(v1ien.Touchpoint) && lane != "" {
34 return true, lane
35 }
36 return false, ""
37 }
38
39 func IsControlPlaneNode(node *corev1.Node) (bool, error) {
40 nodeRole, ok := node.ObjectMeta.Labels[RoleLabel]
41 if !ok {
42 return false, fmt.Errorf("could not find %s annotation for node %s", RoleLabel, node.ObjectMeta.Name)
43 }
44 return v1ien.Role(nodeRole) == v1ien.ControlPlane, nil
45 }
46
View as plain text