memory-bank/components/node-labeler.md
The Node-Labeler component in Gitpod is a Kubernetes controller responsible for managing node labels and annotations that are required for workspaces to run properly. It monitors the status of critical services like registry-facade and ws-daemon on each node, and adds or removes labels accordingly. Additionally, it manages cluster-autoscaler annotations to prevent nodes with active workspaces from being scaled down.
The primary purposes of the Node-Labeler component are:
The Node-Labeler component consists of several key parts:
The component operates as a Kubernetes controller with leader election, ensuring only one instance is active at a time. It uses the controller-runtime library to watch for changes to pods and workspaces, and reconciles the state of node labels and annotations accordingly.
cluster-autoscaler.kubernetes.io/scale-down-disabled annotationThe Node-Labeler component can be configured through command-line flags:
--json-log, -j: Produce JSON log output (default: true)--verbose, -v: Enable verbose logging--namespace: Namespace where Gitpod components are running (default: default)--registry-facade-port: Port for registry-facade node port (default: 31750)--ws-daemon-port: Port for ws-daemon service (default: 8080)The Node-Labeler component integrates with:
The component adds the following labels to nodes:
gitpod.io/registry-facade_ready_ns_<namespace>: Indicates registry-facade is readygitpod.io/ws-daemon_ready_ns_<namespace>: Indicates ws-daemon is readyThese labels are used by the workspace scheduler to ensure workspaces are only scheduled on nodes with the required services.
The component adds or removes the following annotation:
cluster-autoscaler.kubernetes.io/scale-down-disabled: Prevents cluster-autoscaler from removing nodes with active workspacescomponents/common-go: Common Go utilitiescomponents/ws-manager-api/go: Workspace manager APIcomponents/ws-manager-mk2: Workspace manager CRDsThe component implements several security measures:
The Pod Reconciler watches for changes to pods with the component label matching "ws-daemon" or "registry-facade". When a pod becomes ready, it:
The Node Scaledown Annotation Controller watches for changes to workspaces. When a workspace is created, deleted, or moved to a different node, it:
cluster-autoscaler.kubernetes.io/scale-down-disabled annotation if there are workspaces on the node