mirror of
https://github.com/mulgadc/spinifex.git
synced 2026-10-15 17:11:30 +00:00
f14fb64562
* feat(eks): unify eks-server + eks-agent into one eks-node AMI Collapse the two K3s AMIs into a single spinifex-eks-node image whose role (server vs agent) is chosen per-instance at first boot, halving build time, storage, and CVE-rotation surface. - scripts/images/eks-node/: superset manifest + merged setup.sh; all role services baked but only crond + the new eks-node-role selector enabled. - eks-node-role first-boot selector reads SPINIFEX_K3S_ROLE, rc-update adds + starts the matching services (server: k3s + eks-token-webhook + k3s-first-boot publisher; agent: k3s-agent), records /etc/spinifex-eks/role, self-disables. Paths are env-overridable; eks-node-role_test.sh covers all five cases. - mulga-eks-etcd-snapshot.sh early-exits on agent nodes. - k3s_server_vm.go seeds SPINIFEX_K3S_ROLE=server into first-boot.env. - Makefile/dev-install: build-eks-node-image / import-eks-node-image replace the server+agent targets. - Delete scripts/images/eks-server + eks-agent. The launcher resolves the AMI by the spinifex:managed-by=eks tag, so running clusters (which hold the resolved AMI ID) are unaffected. AMI bake + cluster boot are operational integration steps, not yet run. * fix(eks): order eks-node-role after cloud-config/cloud-final The first-boot role selector reads /etc/spinifex-eks/first-boot.env, which cloud-init delivers via write_files in the cloud-config/cloud-final stages. The selector only depended on net+cgroups, so on a fast boot it could start before write_files landed and read a missing role env. Add an after-ordering on cloud-config + cloud-final so the env file is always present first.
39 lines
1.3 KiB
Plaintext
Executable File
39 lines
1.3 KiB
Plaintext
Executable File
#!/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
|
|
}
|