# The cluster node `services.hyperhive.deploy.k8s.enable` makes the host run the main node of a k3s cluster for the swarm services that run in the cluster. It defaults on where the host enables one of them (`deploy.notify-router`, `stt`, `ci-metrics`, `review-classifier`, `claude-login`, `nats` or `swarm-controller`), which `services.hyperhive.deploy.singleHostSwarm` and `services.hyperhive.deploy.allSwarmServices` do, so the all-local host gets the cluster with its services in it and no option set. Setting it to `false` on such a host fails the evaluation, naming the option and the services. Other machines can [join it](#joining-nodes) and run the services' pods; hyperhive runs no cluster of its own beyond that one main node, and it replicates no service. ## What the host gets - **k3s:** one server, which also runs the workloads. traefik and metrics-server are off, and the cluster encrypts its Secrets at rest (`--secrets-encryption`). CoreDNS and the local-path provisioner stay on, so pods have cluster DNS and PersistentVolumeClaims. - **Images:** the node holds k3s's own images and the image of each service that [renders manifests](manifests.md) on this host, in containerd before k3s starts. No registry service exists. A pod names its image with `imagePullPolicy: IfNotPresent`, and a node that joined and lacks the image gets it from a peer ([Service images](images.md#where-a-node-gets-an-image)). - **Manifests:** `services.hyperhive.k8s.enable` is on, so the host builds `system.build.k8sManifests` and `system.build.k8sImages`. Setting it to `false` explicitly fails the evaluation. - **Addresses:** pods take their addresses from `deploy.k8s.podCidr` (default `10.200.0.0/16`) and services from `deploy.k8s.serviceCidr` (default `10.201.0.0/16`). Neither may overlap the hive bridge's subnet (`network.bridgeIp`, default `10.42.0.0/24`) or the other, and the evaluation fails when one does: the bridge and the cluster would route the same addresses. k3s's own default pod range, `10.42.0.0/16`, contains the bridge's default subnet. - **Firewall:** the pod network's interfaces, `cni0` and `flannel.1`, are trusted, so the node reaches its pods. The node-to-node ports are open to the addresses in `deploy.k8s.nodeAddresses` only, which is empty by default ([Joining nodes](#joining-nodes)). - **NetworkPolicy:** k3s's own controller (kube-router, iptables) enforces NetworkPolicy objects; the node doesn't turn it off. A pod no policy selects reaches whatever it can route to. [The manifests](manifests.md#pods) say which pods have one. - **Secret store:** the store gets a second listener and an auth mount for the pods' ServiceAccount tokens, described under [Logging in to the secret store](#logging-in-to-the-secret-store). ## What it leaves alone The cluster holds the workload of the swarm services the host enables, and no other: [the runtime module](runtime.md) applies their manifests, and each runs there and nowhere else, because two copies of `swarm-notify-router`, `swarm-ci-metrics` or `swarm-controller` would share one queue consumer, one cursor or one swarm. A host that enables none has a cluster with no hyperhive workload. With the option off, the host's configuration is the one it has without the module. ## Node labels A service whose data sits on one node's disk runs on that node, and the node says so with a label. The module sets the labels (`services.hyperhive.deploy.k8s.nodeLabels`, passed to `services.k3s.nodeLabel`): - `hyperhive.darkest.space/state-=true`, one per service whose data the cluster keeps. Today that's `nats`, when `deploy.nats.enable` is on, and `ci-metrics`, when `deploy.ci-metrics.enable` is on. The service's static local volume has a `nodeAffinity` on the label, and its pod a `nodeSelector` on it, so a node without the label can't run the pod and shows as no match instead of a volume that can't bind. One label per service, so moving one service's data moves one label. - `hyperhive.darkest.space/entry=true`, on the node the hosts' DNS points at. Nothing selects on it yet. The pods that hosts dial will, as they move in. - `svccontroller.k3s.cattle.io/enablelb=true`. With this label on any node, k3s's service load balancer binds a published port on the labelled nodes only (k3s documents it under "Controlling servicelb node selection"). Without it, a node that joins would also bind the queue's port 4222. On the single node, every label is on the node and the pods are the ones the node ran without them, plus a `nodeSelector`. **A node that joins carries none of the labels**, so it can't run a pod that keeps data on a disk, and the load balancer doesn't bind the queue's port on it. A stateless pod can run there. k3s applies `--node-label` to the node's object at every start, whether the node registered before or not, so a node that registered before a label existed has the label after the restart a switch causes. A pod that selects on a label the node doesn't have yet waits as Pending and starts when the label arrives. k3s only adds labels. A label the module no longer sets, such as `state-nats` after the queue moves back to `"host"`, stays on the node and does nothing, because no pod selects on it. `kubectl label node