Skip to content

k3s-agent

Version 2026.144.1443
Repo superproject

k3s worker (agent) node — joins an existing k3s-server via pre-shared token The k3s-agent candy renders /etc/rancher/k3s/config.yaml (mode 0600) with the cluster server URL and the shared pre-shared token, then installs and enables a k3s-agent.service systemd unit that runs k3s agent. On a deployed node the agent registers with the control plane and the node reaches the Ready state — no join-token handoff, only the server URL plus the credential-store token.

This candy’s plan: — the runnable spec charly check executes against a live deployment. check: steps are idempotent probes; run: steps change state.

Intent Step
run command=set -euo pipefail if [ -z “${K3S_SERVER_URL}” ]; then echo “K3S_SERVER_URL is required — set it in deploy.yml env for this agent.” >&2 exit 1 fi mkdir -p /etc/rancher/k3s cat >/etc/rancher/k3s/config.yaml <<YAML server: “${K3S_SERVER_URL}” token: “${K3S_CLUSTER_TOKEN}” YAML chmod 0600 /etc/rancher/k3s/config.yaml
run command=set -euo pipefail cat >/etc/systemd/system/k3s-agent.service <<‘UNIT’ [Unit] Description=Lightweight Kubernetes (agent) Documentation=https://k3s.io Wants=network-online.target After=network-online.target [Service] Type=notify ExecStart=/usr/local/bin/k3s agent KillMode=process Delegate=yes LimitNOFILE=1048576 LimitNPROC=infinity LimitCORE=infinity TasksMax=infinity TimeoutStartSec=0 Restart=always RestartSec=5s [Install] WantedBy=multi-user.target UNIT systemctl daemon-reload systemctl enable –now k3s-agent.service
check the rendered agent config exists with owner-only permissions
check the config points the agent at the cluster server URL
check the k3s-agent systemd unit is installed
check the unit starts the node in agent (worker) mode
check the worker node registers with the server and reaches Ready
agent-check the joined worker becomes schedulable so cluster workloads can land on it
check file=/etc/rancher/k3s/config.yaml
check file=/etc/systemd/system/k3s-agent.service