package node import ( "fmt" corev1 "k8s.io/api/core/v1" v1ien "edge-infra.dev/pkg/sds/ien/k8s/apis/v1" ) const ( // Hostname of the Edge node HostnameLabel string = "node.ncr.com/hostname" // Kubernetes node role (worker or controlplane) RoleLabel string = "node.ncr.com/role" // Lane number for the Edge node (touchpoints). LaneLabel string = "node.ncr.com/lane" // Depicts if an Edge node is front-of-house touchpoint (POS) // or a back-of-house server (touchpoint or server). ClassLabel string = "node.ncr.com/class" // The worker class label is attached to k8s worker nodes // and defines the nodes class (touchpoint or server). WorkerClassLabel string = "node.ncr.com/worker-class" // Label applied to kubernetes control plane nodes. ControlPlaneLabel string = "node-role.kubernetes.io/control-plane" // Terminal ID annotation TerminalIDLabel string = "node.ncr.com/terminal-id" ) func IsTouchPointNode(node *corev1.Node) (bool, string) { class := node.ObjectMeta.Labels[ClassLabel] lane := node.ObjectMeta.Labels[LaneLabel] if class == string(v1ien.Touchpoint) && lane != "" { return true, lane } return false, "" } func IsControlPlaneNode(node *corev1.Node) (bool, error) { nodeRole, ok := node.ObjectMeta.Labels[RoleLabel] if !ok { return false, fmt.Errorf("could not find %s annotation for node %s", RoleLabel, node.ObjectMeta.Name) } return v1ien.Role(nodeRole) == v1ien.ControlPlane, nil }