# The cluster node `services.hyperhive.deploy.k8s.enable` (default `false`) makes the host run a single-node k3s server for the swarm services that run in the cluster. It's the Kubernetes counterpart of `services.hyperhive.deploy.singleHostSwarm`: set it on the host that runs the swarm's services, and the cluster comes up with the service images loaded and no service's objects applied. ## 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 exists, and the pods name their images with `imagePullPolicy: Never`. - **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. - **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 starts with no hyperhive workload. Each service keeps running as its systemd unit, and nothing applies the services' manifests: two copies of `swarm-notify-router`, `swarm-ci-metrics` or `swarm-controller` would share one queue consumer, one cursor or one swarm. A service's objects go into the cluster when its `runtime` is `"k8s"` ([the runtime switch](runtime.md)). 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.runtime` is `"k8s"`, and `ci-metrics`, when `deploy.ci-metrics.runtime` is `"k8s"`. 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