mirror of
https://github.com/mulgadc/spinifex.git
synced 2026-10-22 12:16:52 +00:00
6879a3425a
* feat(gpu): Ubuntu NVIDIA GPU node image + GPU AMI selection Epic A of GPU passthrough to EKS pods / ECS task containers. - Add gpu-vendor AMI tag constants + GPUVendorForType/IsGPUTypeName helpers (instance-family prefix -> vendor from knownGPUModels). - EKS + ECS worker AMI resolution branches to a GPU-tagged node image for GPU instance types; no fallback to the driverless image (hard error instead). - Exclude gpu-vendor-tagged AMIs from the plain (non-GPU) lookup so a newer GPU AMI cannot hijack ordinary nodes (managed-by tag is shared; filters have no negation, so exclude client-side). - NodegroupRecord caches GPUEnabled/GPUVendor from InstanceTypes. - Catalog entries spinifex-eks-node-gpu / spinifex-ecs-node-gpu (dual-tagged). - New Ubuntu 26.04 GPU node images (eks-node-gpu, ecs-agent-gpu): reuse the proven DKMS -server driver recipe (drop Docker CE + dev payload), add nvidia-container-toolkit, OpenRC->systemd port of the worker/agent service subset, udev EBS by-id bridge, nvidia modules-load, first-boot CDI generation. - build-system-image.sh: SYSTEM_TAG supports multiple space-separated tags. * build: allow SYSTEM_IMAGE_BUILD_DIR override for image build dir Ubuntu GPU images are 16G; a RAM-backed /tmp tmpfs is too small to hold the qcow2 + expanded raw. Default stays /tmp; SYSTEM_IMAGE_BUILD_DIR redirects the build onto a real disk.
49 lines
1.9 KiB
Bash
49 lines
1.9 KiB
Bash
#!/bin/sh
|
|
set -eu
|
|
|
|
# k3s-agent-prestart — reproduces the start_pre logic from
|
|
# scripts/images/eks-node/k3s-agent.initd for the systemd unit: requires
|
|
# K3S_URL + K3S_TOKEN from /etc/spinifex-eks/agent.env (sourced by the unit's
|
|
# own EnvironmentFile=), then resolves the kubelet provider-id from IMDSv2
|
|
# (aws:///<az>/<instance-id>, EKS parity so the AWS Load Balancer Controller
|
|
# can resolve nodes for ip-mode target registration) and writes it as an
|
|
# extra k3s agent argument for the unit's ExecStart to source.
|
|
#
|
|
# Run as ExecStartPre=; a nonzero exit here fails k3s-agent.service before k3s
|
|
# is ever invoked, same as the OpenRC start_pre returning 1.
|
|
|
|
ENV_FILE=/etc/spinifex-eks/agent.env
|
|
DROPIN=/run/k3s-agent-extra-args.env
|
|
LOGTAG="k3s-agent-prestart"
|
|
|
|
# EnvironmentFile= already injects agent.env into this process' environment,
|
|
# but source it directly too so this script also works if invoked standalone.
|
|
if [ -f "${ENV_FILE}" ]; then
|
|
# shellcheck disable=SC1090
|
|
. "${ENV_FILE}"
|
|
fi
|
|
|
|
if [ -z "${K3S_URL:-}" ] || [ -z "${K3S_TOKEN:-}" ]; then
|
|
echo "[${LOGTAG}] K3S_URL and K3S_TOKEN must be set in ${ENV_FILE}" >&2
|
|
exit 1
|
|
fi
|
|
|
|
IMDS=http://169.254.169.254/latest
|
|
CURL="curl -fsS --connect-timeout 3 --max-time 5"
|
|
|
|
EXTRA_ARGS=""
|
|
TOK=$(${CURL} -X PUT -H 'X-aws-ec2-metadata-token-ttl-seconds: 120' "${IMDS}/api/token" 2>/dev/null || true)
|
|
if [ -n "${TOK}" ]; then
|
|
IID=$(${CURL} -H "X-aws-ec2-metadata-token: ${TOK}" "${IMDS}/meta-data/instance-id" 2>/dev/null || true)
|
|
AZ=$(${CURL} -H "X-aws-ec2-metadata-token: ${TOK}" "${IMDS}/meta-data/placement/availability-zone" 2>/dev/null || true)
|
|
if [ -n "${IID}" ] && [ -n "${AZ}" ]; then
|
|
EXTRA_ARGS="--kubelet-arg=provider-id=aws:///${AZ}/${IID}"
|
|
else
|
|
echo "[${LOGTAG}] IMDS instance-id/az empty; keeping default providerID" >&2
|
|
fi
|
|
else
|
|
echo "[${LOGTAG}] IMDS token request failed; keeping default providerID" >&2
|
|
fi
|
|
|
|
echo "K3S_AGENT_EXTRA_ARGS=${EXTRA_ARGS}" > "${DROPIN}"
|