#!/sbin/openrc-run # K3s agent (worker node). Env vars K3S_URL + K3S_TOKEN come from cloud-init # user-data — the orchestrator embeds them at RunInstances time per the # Nodegroup bootstrap flow (eks-v1.md Q14). # # K3S_URL points at the cluster's NLB endpoint (https://{cluster}.{account} # .eks.{region}.{suffix}:443) so the agent join path stays stable across the # v2 HA migration (single-VM v1 → 3-node etcd quorum v2). No AMI rebuild # needed when the control plane expands. description="K3s Kubernetes agent (Mulga EKS worker)" command="/usr/local/bin/k3s" command_args="agent" command_background="yes" pidfile="/run/k3s-agent.pid" output_log="/var/log/k3s-agent.log" error_log="/var/log/k3s-agent.log" start_stop_daemon_args="--wait 5000" depend() { need net cgroups after firewall } start_pre() { # Cloud-init drops these into /etc/spinifex-eks/agent.env. We source them # here so OpenRC injects them into k3s' environment. if [ -f /etc/spinifex-eks/agent.env ]; then # shellcheck disable=SC1091 . /etc/spinifex-eks/agent.env export K3S_URL K3S_TOKEN K3S_NODE_NAME K3S_NODE_LABEL fi if [ -z "${K3S_URL:-}" ] || [ -z "${K3S_TOKEN:-}" ]; then eerror "K3S_URL and K3S_TOKEN must be set in /etc/spinifex-eks/agent.env" return 1 fi }