Promote v0.2.0 to production

This commit is contained in:
GPU Kitchen delivery
2026-10-09 23:33:58 +00:00
parent cc670cd6e7
commit e20e5148e8
4 changed files with 384 additions and 92 deletions
+263 -36
View File
@@ -69,6 +69,26 @@ need_root() {
# ── JSON helpers (controlled inputs: paths + identifiers) ──────────────────────
json_str() { printf '%s' "$1" | sed 's/\\/\\\\/g; s/"/\\"/g'; }
# The host's IANA time zone (PLN-51): the planning's weekly template is written in the
# controller's time, and a container left in UTC would shift it silently. Empty when
# the host does not say; the controller then reports UTC and shows it.
host_timezone() {
_tz=""
if command -v timedatectl >/dev/null 2>&1; then
_tz=$(timedatectl show -p Timezone --value 2>/dev/null || true)
fi
if [ -z "$_tz" ] && [ -L /etc/localtime ]; then
_tz=$(readlink /etc/localtime | sed -n 's#.*/zoneinfo/##p')
fi
if [ -z "$_tz" ] && [ -r /etc/timezone ]; then
_tz=$(head -n 1 /etc/timezone)
fi
case "$_tz" in
*[!A-Za-z0-9_+/-]*) _tz="" ;;
esac
printf '%s' "$_tz"
}
json_array() { # args → ["a","b",...]
_out=""
for _p in "$@"; do
@@ -236,19 +256,19 @@ seed_secrets() { # DATA_ROOT
[ ! -f "$_sd/bootstrap_admin_password" ] || chmod 0600 "$_sd/bootstrap_admin_password"
}
prepare_claim_code() {
prepare_claim_key() {
# The file is the operator's recoverable proof of machine possession. Create
# it once, preserve it across reinstalls, and let the backend unlink it after
# the atomic first-account claim. A missing file beside an existing manifest
# therefore means "consumed", never "rotate the credential". homelab and studio
# therefore means "consumed", never "rotate the credential". homelab and small-team
# have no claim window at all (PRF-12, SEC-53): no code is made for them.
case "$PROFILE" in homelab|studio) return 0 ;; esac
if [ -f "$CLAIM_CODE_FILE" ]; then
chmod 0600 "$CLAIM_CODE_FILE"
case "$PROFILE" in homelab|small-team) return 0 ;; esac
if [ -f "$CLAIM_KEY_FILE" ]; then
chmod 0600 "$CLAIM_KEY_FILE"
elif [ ! -f "$MANIFEST" ]; then
umask 077
gen_secret > "$CLAIM_CODE_FILE"
chmod 0600 "$CLAIM_CODE_FILE"
gen_secret > "$CLAIM_KEY_FILE"
chmod 0600 "$CLAIM_KEY_FILE"
fi
}
@@ -297,7 +317,7 @@ UNIT
# TLS reverse-proxy example, FILLED with the operator's domain (INS-47) — written
# under `--domain <d>`, whatever the profile. Kept aligned with
# deployments/controller/Caddyfile.example (the compose variant); this copy
# deployments/controller/Caddyfile.example (the dev/CI compose variant); this copy
# targets the all-in-one image, where nginx on the UI port is the single front
# door (INS-09) so one upstream carries pages, /api and the /ws upgrade alike.
# We write a file and NOTHING more: no package install, no service start, no
@@ -307,7 +327,7 @@ write_caddyfile() {
mkdir -p "$DATA_ROOT/caddy"
cat > "$DATA_ROOT/caddy/Caddyfile" <<CADDY
# TLS in front of GPU Kitchen — generated by the installer for --domain $DOMAIN
# (specs/plateforme/installation.md INS-47). Caddy provisions and renews the
# (specs/plateforme/installation/preflight-et-image.md INS-47). Caddy provisions and renews the
# certificate itself once DNS for $DOMAIN points at this machine.
#
# sudo cp $DATA_ROOT/caddy/Caddyfile /etc/caddy/Caddyfile
@@ -444,8 +464,8 @@ cmd_install() {
_seen="$_seen $_pv"
done
case "$PROFILE" in
""|homelab|studio|enterprise|public) ;;
*) die "--profile must be homelab, studio, enterprise or public (got '$PROFILE')" ;;
""|homelab|small-team|managed-network|public) ;;
*) die "--profile must be homelab, small-team, managed-network or public (got '$PROFILE')" ;;
esac
if [ -n "$DOMAIN" ]; then
@@ -475,13 +495,13 @@ cmd_install() {
CACHE_JSON="[{\"hostPath\":\"$(json_str "$CACHE_DIR")\",\"shared\":false}]"
SELF_ENROLL_FILE="$DATA_ROOT/self-enroll-token"
BOOTSTRAP_PASSWORD_FILE="$DATA_ROOT/secrets/bootstrap_admin_password"
CLAIM_CODE_FILE="$DATA_ROOT/secrets/claim_code"
CLAIM_CODE_AVAILABLE=0
CLAIM_KEY_FILE="$DATA_ROOT/secrets/claim_key"
CLAIM_KEY_AVAILABLE=0
if [ "$DRY_RUN" -eq 1 ]; then
case "$MODE:$PROFILE" in
controller:homelab|controller:studio) ;;
controller:*) CLAIM_CODE_AVAILABLE=1 ;;
controller:homelab|controller:small-team) ;;
controller:*) CLAIM_KEY_AVAILABLE=1 ;;
esac
echo "==> dry run: no file, service or container was changed"
[ ! -f "$MANIFEST" ] \
@@ -557,8 +577,8 @@ cmd_install() {
mkdir -p "$ETC_DIR" "$DATA_ROOT" "$CACHE_DIR"
seed_secrets "$DATA_ROOT"
if [ "$MODE" = "controller" ]; then
prepare_claim_code
[ ! -s "$CLAIM_CODE_FILE" ] || CLAIM_CODE_AVAILABLE=1
prepare_claim_key
[ ! -s "$CLAIM_KEY_FILE" ] || CLAIM_KEY_AVAILABLE=1
fi
umask 077
@@ -698,7 +718,7 @@ JSON
# fresh render no longer carries it (a profile change drops GPUK_HSTS); any other
# key was pushed by the controller and is kept. Keep this list in step with
# render_controller_manifest.
INSTALL_ENV_KEYS="NODE_ENV,GPUK_MODE,GPUK_CLUSTER,GPUK_SELF_ENROLL_FILE,NODE_DISPLAY_NAME,HF_HOME,GPUK_DATA_ROOT,GPUK_INSTALL_PROFILE,GPUK_HSTS,GPUK_SESSION_COOKIE_SECURE,GPUK_BOOTSTRAP_MUST_CHANGE,BACKEND_DOCKER_NETWORK,GPUK_PORT,GPUK_PUBLIC_PORT,GPUK_MTLS_PORT,GPUK_PUBLIC_MTLS_PORT,GPUK_PROXY_PUBLIC_PORT"
INSTALL_ENV_KEYS="NODE_ENV,TZ,GPUK_CLUSTER,GPUK_SELF_ENROLL_FILE,NODE_DISPLAY_NAME,HF_HOME,GPUK_DATA_ROOT,GPUK_INSTALL_PROFILE,GPUK_HSTS,GPUK_SESSION_COOKIE_SECURE,GPUK_BOOTSTRAP_MUST_CHANGE,BACKEND_DOCKER_NETWORK,GPUK_PORT,GPUK_PUBLIC_PORT,GPUK_MTLS_PORT,GPUK_PUBLIC_MTLS_PORT,GPUK_PROXY_PUBLIC_PORT"
# Write the manifest — or, when one exists, MERGE into it (INS-03). Re-running the
# installer is the update path, and the manifest is not ours alone: since the first
@@ -751,6 +771,8 @@ render_controller_manifest() {
# own GPUK_PORT when nothing republishes it.
EXTRA_ENV=""
EXTRA_ENV="$EXTRA_ENV,\"GPUK_DATA_ROOT\":\"$(json_str "$DATA_ROOT")\""
HOST_TZ=$(host_timezone)
[ -z "$HOST_TZ" ] || EXTRA_ENV="$EXTRA_ENV,\"TZ\":\"$(json_str "$HOST_TZ")\""
[ -z "$PROFILE" ] || EXTRA_ENV="$EXTRA_ENV,\"GPUK_INSTALL_PROFILE\":\"$(json_str "$PROFILE")\""
if [ "$PROFILE" = "public" ]; then
EXTRA_ENV="$EXTRA_ENV,\"GPUK_HSTS\":\"true\""
@@ -770,8 +792,8 @@ render_controller_manifest() {
BOOTSTRAP_SECRET_JSON=",\"GPUK_BOOTSTRAP_ADMIN_PASSWORD\":\"$(json_str "$BOOTSTRAP_PASSWORD_FILE")\""
fi
CLAIM_SECRET_JSON=""
if [ "$CLAIM_CODE_AVAILABLE" -eq 1 ]; then
CLAIM_SECRET_JSON=",\"GPUK_CLAIM_CODE\":\"$(json_str "$CLAIM_CODE_FILE")\""
if [ "$CLAIM_KEY_AVAILABLE" -eq 1 ]; then
CLAIM_SECRET_JSON=",\"GPUK_CLAIM_KEY\":\"$(json_str "$CLAIM_KEY_FILE")\""
fi
[ "$NETWORK" = "host" ] || EXTRA_ENV="$EXTRA_ENV,\"BACKEND_DOCKER_NETWORK\":\"$(json_str "$NETWORK")\""
@@ -812,7 +834,6 @@ render_controller_manifest() {
"ports": $PORTS_JSON,
"env": {
"NODE_ENV": "production",
"GPUK_MODE": "controller",
"GPUK_CLUSTER": "$(json_str "$CLUSTER")",
"GPUK_SELF_ENROLL_FILE": "$(json_str "$SELF_ENROLL_FILE")",
"NODE_DISPLAY_NAME": "$(json_str "$(hostname)")",
@@ -852,6 +873,21 @@ manifest_image() {
sed -n 's/.*"image"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' "$MANIFEST" 2>/dev/null | head -1
}
manifest_env() { # $1 = env key of the app container
sed -n "s/.*\"$1\"[[:space:]]*:[[:space:]]*\"\([^\"]*\)\".*/\1/p" "$MANIFEST" 2>/dev/null | head -1
}
# [SEC-72] The one-time setup link, rebuilt from the key file the controller unlinks once
# the first account exists. Empty when the key is gone (consumed) or was never made
# (homelab, small-team, worker). The UI port is the published one when the app is bridged.
setup_url() {
_kf="$(manifest_data_root)/secrets/claim_key"
[ -s "$_kf" ] || return 0
_up=$(manifest_env GPUK_PUBLIC_PORT); [ -n "$_up" ] || _up=$(manifest_env GPUK_PORT)
_host=$(hostname -f 2>/dev/null || hostname 2>/dev/null || echo localhost)
printf 'http://%s:%s/start?key=%s' "$_host" "${_up:-8080}" "$(cat "$_kf")"
}
health_port() {
sed -n 's/.*GPUK_WORKER_HEALTH_PORT=\([0-9]*\).*/\1/p' "$WORKER_ENV" 2>/dev/null | head -1
}
@@ -890,7 +926,7 @@ image_tag() {
# The release channel: one flat JSON document served next to the installer. The
# UI's update check reads the same one (apps/controller/api/src/core/release-channel.ts) — one
# source of truth. Interim default: the public Gitea channel repo — flips to
# https://gpu.kitchen/latest.json once the hub exists (specs/developpement/ci-cd.md).
# https://gpu.kitchen/latest.json once the hub exists (specs/developpement/ci-cd/README.md).
CHANNEL_URL="${GPUK_CHANNEL_URL:-https://repo.byterain.io/gpukitchen/channel/raw/branch/main/latest.json}"
# The release public key pinned in THIS copy of gpuk (OPS-20). The channel copy
@@ -959,17 +995,18 @@ ensure_minisign() { # $1 = 1 when nothing may be installed (dry run)
# minisign CLI or no pinned key are all fatal — GPUK_CHANNEL_INSECURE=1 is the
# explicit, logged opt-out (a private mirror that does not sign).
CHANNEL_DOC=""
CHANNEL_MAX_TIME=20
channel_fetch() {
command -v curl >/dev/null 2>&1 || return 1
CHANNEL_DOC=$(mktemp) || return 1
curl -fsSL --max-time 20 "$CHANNEL_URL" -o "$CHANNEL_DOC" 2>/dev/null || return 1
curl -fsSL --max-time "$CHANNEL_MAX_TIME" "$CHANNEL_URL" -o "$CHANNEL_DOC" 2>/dev/null || return 1
if [ "${GPUK_CHANNEL_INSECURE:-}" = "1" ]; then
echo "WARNING: GPUK_CHANNEL_INSECURE=1 — release channel signature NOT verified" >&2
return 0
fi
require_release_key
_sig=$(mktemp)
if ! curl -fsSL --max-time 20 "${CHANNEL_URL}.minisig" -o "$_sig" 2>/dev/null; then
if ! curl -fsSL --max-time "$CHANNEL_MAX_TIME" "${CHANNEL_URL}.minisig" -o "$_sig" 2>/dev/null; then
rm -f "$_sig"
die "no signature at ${CHANNEL_URL}.minisig — refusing an unsigned channel document (OPS-20)"
fi
@@ -1003,7 +1040,7 @@ cmd_backup() {
_img=$(manifest_image)
[ -n "$_img" ] || die "this is a worker node — no controller data to back up here"
if grep -q '"DATABASE_URL"' "$MANIFEST" 2>/dev/null; then
die "this install uses an external DATABASE_URL — back THAT database up (pg_dump, or the compose procedures in specs/plateforme/operations.md); gpuk backup only snapshots the embedded pgdata"
die "this install uses an external DATABASE_URL — back THAT database up (pg_dump); gpuk backup only snapshots the embedded pgdata"
fi
_root=$(manifest_data_root)
[ -n "$_root" ] || die "no dataRoot in $MANIFEST"
@@ -1077,27 +1114,165 @@ cmd_channel() {
# ── status ─────────────────────────────────────────────────────────────────────
# No control socket any more. Status = the systemd unit state + the daemon's own
# /health endpoint + whether a worker has enrolled (identity present).
# [INS-74] Why the daemon is or is not serving, in plain sentences, and how far it is
# from the release channel. Never a "no" it could not read: without root the identity,
# the manifest and worker.env are unreadable (0600/0700), which once printed
# "enrolled: no" for an enrolled worker the controller had refused for its version.
STATUS_NEEDS_ROOT=0
readable_or_flag() { # $1 = path; 0 when it can be judged, 1 (and flags) when only root could
[ -e "$1" ] && [ ! -r "$1" ] && { STATUS_NEEDS_ROOT=1; return 1; }
[ -x "$(dirname "$1")" ] || { STATUS_NEEDS_ROOT=1; return 1; }
return 0
}
json_string_field() { # $1 = json text, $2 = key
printf '%s' "$1" | sed -n 's/.*"'"$2"'"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' | head -1
}
# [INS-74] The sentence for each `connection` code of the daemon's /health answer. The codes
# are the contract packages/contracts/data/worker-connection-states.json, which a gate holds
# this function to (every code mapped, no other one).
connection_sentence() { # $1 = connection code
case "$1" in
starting) echo "Starting: not connected to a controller yet." ;;
connected) echo "Connected to its controller." ;;
disconnected) echo "Not connected: the controller closed the connection. It reconnects by itself." ;;
unreachable) echo "Not connected: the controller cannot be reached. It tries again by itself." ;;
registration_rejected) echo "Not connected: the controller rejected this node. It tries again by itself." ;;
refused_identity) echo "Refused: the controller removed this node. Enroll it again with a new token." ;;
refused_trust_anchor) echo "Refused: the controller changed its identity. Enroll this node again with a new token." ;;
refused_version) echo "Refused by the controller: this node runs a different version. Update it: sudo gpuk update" ;;
self_updating) echo "Updating itself to the version of its controller." ;;
*) return 1 ;;
esac
}
# One sentence from the daemon's own state: systemd's active state, then its /health
# answer (mode, then connection code). An answer without a connection code is a daemon
# older than this gpuk; a code this gpuk does not know is a daemon NEWER than it — the
# daemon updates itself (self-heal, the UI's Update), while gpuk is replaced by
# `gpuk update` (update_cli).
daemon_state_sentence() { # $1 = active state, $2 = /health body
case "$1" in
active|reloading) ;;
failed) echo "The service stopped after an error. See why: sudo gpuk logs"; return ;;
activating) echo "The service is starting."; return ;;
*) echo "The service is not running. Start it: sudo systemctl start $SERVICE_NAME"; return ;;
esac
if [ -z "$2" ]; then echo "The service runs but does not answer yet."; return; fi
_mode=$(json_string_field "$2" mode)
_detail=$(json_string_field "$2" detail)
_connection=$(json_string_field "$2" connection)
if [ "$_mode" = awaiting_enrollment ]; then
case "$_detail" in
explicit_token_required)
echo "Not enrolled. It needs an enrollment token: on the controller, open Nodes & GPU, then Add nodes." ;;
ambiguous_controllers)
echo "Not enrolled. Several controllers answer on this network: enroll it with a token from the right one." ;;
*)
echo "Not enrolled yet. It waits for a controller on this network to admit it." ;;
esac
return
fi
connection_sentence "$_connection" && return
if [ "$_mode" = protocol_mismatch ]; then
connection_sentence refused_version
elif [ -n "$_connection" ]; then
echo "This daemon is newer than this gpuk, which cannot read its state. Get the current gpuk: sudo gpuk update"
else
echo "This daemon is older than this gpuk and does not say its state. Update it: sudo gpuk update"
fi
}
NVIDIA_SMI="${GPUK_NVIDIA_SMI:-nvidia-smi}"
gpu_sentence() {
if ! command -v "$NVIDIA_SMI" >/dev/null 2>&1; then
echo "none found (the NVIDIA driver tool nvidia-smi is not installed)"; return
fi
_n=$(timeout 10 "$NVIDIA_SMI" -L 2>/dev/null | grep -c '^GPU ' || true)
if [ "${_n:-0}" -eq 0 ]; then echo "none found (nvidia-smi lists no GPU: check the NVIDIA driver)"
else echo "$_n found"; fi
}
# "<version> <worker build for this arch>" from the verified channel, in a subshell with a
# short timeout: a mute or unverifiable channel must not stop the status (channel_fetch dies).
status_channel_offer() {
(
CHANNEL_MAX_TIME="${GPUK_STATUS_CHANNEL_TIMEOUT:-5}"
channel_fetch >/dev/null 2>&1 || exit 1
case "$(uname -m)" in
aarch64|arm64) _bkey=workerBuildIdAarch64 ;;
*) _bkey=workerBuildIdX86_64 ;;
esac
_v=$(channel_field "$CHANNEL_DOC" version)
_b=$(channel_field "$CHANNEL_DOC" "$_bkey")
rm -f "$CHANNEL_DOC"
[ -n "$_v" ] || exit 1
printf '%s %s\n' "$_v" "$_b"
) 2>/dev/null
}
cmd_status() {
_active=$(systemctl is-active "$SERVICE_NAME" 2>/dev/null || true)
echo "service : $_active"
echo "service : ${_active:-unknown}"
if [ -f "$IDENTITY_DIR/identity.json" ]; then
echo "enrolled : yes ($IDENTITY_DIR)"
echo "enrolled : yes"
elif { [ -d "$IDENTITY_DIR" ] && [ ! -x "$IDENTITY_DIR" ]; } || ! readable_or_flag "$IDENTITY_DIR"; then
STATUS_NEEDS_ROOT=1
echo "enrolled : unknown (run 'sudo gpuk status' to see it)"
else
echo "enrolled : no (daemon waits for LAN admission; token enrollment is also available)"
echo "enrolled : no"
fi
_hp=$(health_port); [ -n "$_hp" ] || _hp=8001
_hp=""
readable_or_flag "$WORKER_ENV" && _hp=$(health_port)
[ -n "$_hp" ] || _hp=8001
_h=""
if command -v curl >/dev/null 2>&1; then
_h=$(curl -fsS --max-time 3 "http://127.0.0.1:$_hp/health" 2>/dev/null || true)
[ -n "$_h" ] && echo "health : $_h" || echo "health : (no answer on :$_hp)"
fi
_img=$(manifest_image)
if [ -n "$_img" ]; then
echo "state : $(daemon_state_sentence "$_active" "$_h")"
echo "GPUs : $(gpu_sentence)"
_installed=$("$BIN_DEST" --version 2>/dev/null | sed -n 's/^gpu-kitchen-worker //p' | head -1)
echo "daemon : ${_installed:-unknown}"
_img=""; _role_known=1
if readable_or_flag "$MANIFEST"; then _img=$(manifest_image); else _role_known=0; fi
_offer=$(status_channel_offer || true)
_offer_version=${_offer%% *}
_offer_build=""; [ "$_offer" = "${_offer#* }" ] || _offer_build=${_offer#* }
if [ -z "$_offer" ]; then
echo "channel : unknown (the update channel cannot be read now)"
else
echo "channel : $_offer_version (daemon build ${_offer_build:-not listed})"
_behind=0
[ -z "$_offer_build" ] || [ "$_installed" = "$_offer_build" ] || _behind=1
if [ -n "$_img" ]; then
[ "$(image_tag "$_img")" = "$_offer_version" ] || _behind=1
fi
if [ "$_role_known" -eq 0 ]; then
echo "update : unknown (run 'sudo gpuk status' to see it)"
elif [ "$_behind" -eq 1 ]; then
echo "update : $_offer_version is available. Update: sudo gpuk update"
else
echo "update : up to date"
fi
fi
if [ "$_role_known" -eq 0 ]; then
echo "role : unknown (run 'sudo gpuk status' to see it)"
elif [ -n "$_img" ]; then
echo "app image : $_img"
echo "app cont. : $(docker inspect -f '{{.State.Status}}' "$(container_name)" 2>/dev/null || echo 'not running')"
echo "proxy : $(docker inspect -f '{{.State.Status}} {{.State.Health.Status}}' "$(proxy_container_name)" 2>/dev/null || echo 'not running')"
_setup=$(setup_url)
[ -z "$_setup" ] || echo "setup link: $_setup (works once; shown until the first account exists)"
else
echo "role : worker (no app container)"
fi
[ "$STATUS_NEEDS_ROOT" -eq 0 ] || echo "Some details need root. Run: sudo gpuk status"
}
# ── enroll ─────────────────────────────────────────────────────────────────────
@@ -1185,6 +1360,55 @@ update_daemon() {
DAEMON_UPDATED=1
}
# [INS-74] gpuk replaces itself with the gpuk the verified channel names, before anything
# else: a gpuk older than its daemon cannot read the daemon's state. Only an installed gpuk
# is replaced, and only by bytes whose sha256 the signed document gives AND which pin the
# same release key: a key change stays a reinstall, never something a channel can push. The
# new copy is written beside the old one, then renamed over it (a new inode: sh is still
# reading the old file), and an update run from the installed gpuk continues in the new one.
# $1 = the update's --version, or empty.
update_cli() {
[ "${GPUK_CLI_UPDATED:-}" != "1" ] || return 0
[ -f "$CLI_DEST" ] || return 0
if [ "${GPUK_CHANNEL_INSECURE:-}" = "1" ]; then
echo "WARNING: GPUK_CHANNEL_INSECURE=1 — gpuk itself is not updated" >&2
return 0
fi
_url=$(channel_field "$CHANNEL_DOC" gpukScript)
_sum=$(channel_field "$CHANNEL_DOC" gpukScriptSha256)
if [ -z "$_url" ] || [ -z "$_sum" ]; then
echo "==> the release channel names no gpuk; keeping this one"
return 0
fi
[ "$(sha256sum "$CLI_DEST" | cut -d' ' -f1)" != "$_sum" ] || return 0
curl -fsSL --max-time 60 "$_url" -o "$CLI_DEST.new" 2>/dev/null \
|| { rm -f "$CLI_DEST.new"; die "cannot download gpuk from $_url"; }
if [ "$(sha256sum "$CLI_DEST.new" | cut -d' ' -f1)" != "$_sum" ]; then
rm -f "$CLI_DEST.new"
die "the gpuk at $_url does not match the signed channel — refusing it (OPS-20)"
fi
# shellcheck disable=SC2016 # the literal ${GPUK_UPDATE_PUBKEY:-…} line of the new gpuk
_key=$(sed -n 's/^CHANNEL_PUBKEY="\${GPUK_UPDATE_PUBKEY:-\(.*\)}"$/\1/p' "$CLI_DEST.new" | head -1)
if [ "$_key" != "$CHANNEL_PUBKEY" ]; then
rm -f "$CLI_DEST.new"
echo "WARNING: the channel's gpuk pins another release key; keeping this one. A new key needs a reinstall." >&2
return 0
fi
sh -n "$CLI_DEST.new" 2>/dev/null \
|| { rm -f "$CLI_DEST.new"; die "the gpuk at $_url is not a valid script — refusing it"; }
_self=0
[ "$(readlink -f "$0" 2>/dev/null)" != "$(readlink -f "$CLI_DEST")" ] || _self=1
chmod 0755 "$CLI_DEST.new"
mv "$CLI_DEST.new" "$CLI_DEST"
echo "==> gpuk updated from the release channel"
[ "$_self" -eq 1 ] || return 0
rm -f "$CHANNEL_DOC"
if [ -n "$1" ]; then
GPUK_CLI_UPDATED=1 exec "$CLI_DEST" update --version "$1"
fi
GPUK_CLI_UPDATED=1 exec "$CLI_DEST" update
}
# The running daemon still executes the replaced binary until it restarts.
restart_updated_daemon() {
[ "$DAEMON_UPDATED" -eq 1 ] || return 0
@@ -1210,6 +1434,7 @@ cmd_update() {
# button drives the same swap, but only for a worker it still accepts.
[ "$_check" -eq 0 ] || { echo "This is a worker node: 'gpuk update' moves its daemon to the channel's build."; return 0; }
channel_fetch || die "cannot read the release channel at $CHANNEL_URL"
update_cli ""
update_daemon
restart_updated_daemon
return 0
@@ -1240,6 +1465,7 @@ cmd_update() {
_latest=""
if channel_fetch; then
_latest=$(channel_field "$CHANNEL_DOC" version)
[ -z "$_latest" ] || update_cli "$_want"
fi
if [ -z "$_latest" ]; then
[ -z "$_want" ] \
@@ -1345,7 +1571,7 @@ usage() {
cat <<EOF
gpuk — GPU Kitchen host daemon (gpu-kitchen-worker)
gpuk install --mode controller --image <ref> [--profile homelab|studio|enterprise|public]
gpuk install --mode controller --image <ref> [--profile homelab|small-team|managed-network|public]
[--domain D] [--cluster N] [--cache-dir P] [--data-root P]
[--http-port P] [--mtls-port P] [--inference-port P]
[--network bridge|host|<net>] [--binary <path>] [--reset-manifest]
@@ -1362,7 +1588,8 @@ gpuk — GPU Kitchen host daemon (gpu-kitchen-worker)
gpuk enroll --controller wss://<host>:<port> --token gk_enroll_...
gpuk apply (controller) Reconcile the app container, then the proxy container
by handover, from the manifest
gpuk update (controller) Move to the current release (pull + recreate, rollback)
gpuk update Move gpuk, the daemon and (controller) the app to the current release
(pull + recreate, rollback)
gpuk update --check (controller) Compare the installed version with the release
gpuk update --version <tag> (controller) Move to a specific release
gpuk channel Fetch + VERIFY the release channel and print what it offers
@@ -1374,8 +1601,8 @@ gpuk — GPU Kitchen host daemon (gpu-kitchen-worker)
gpuk uninstall --purge Also remove the app container, /etc/gpu-kitchen, the binary and gpuk
(never the data root: database, models, secrets)
Most people never run this directly: the channel's install.sh installs it
(https://repo.byterain.io/gpukitchen/channel/raw/branch/main/install.sh).
The GPU Kitchen installer installs this tool:
curl -fsSL https://gpu.kitchen/install.sh | sudo sh
EOF
}