#!/usr/bin/env bash
# Real demos for P132 "How to Fix Kubernetes ImagePullBackOff Errors". Runs on the Mac's Docker Desktop.
# One container, ce-p132-laptop (Ana's laptop at her taco truck): a stock Ubuntu 24.04 with systemd as PID 1, Ubuntu's
# own Docker, and kind + kubectl from their official releases (lab/laptop/Dockerfile), run --privileged with its own
# cgroup namespace and fresh volumes, so its Docker starts empty. Off camera, demo_driver.py makes a real three-node
# kind cluster inside it and the truck's private registry (lab/registry/setup.sh: registry:3 with TLS from our own lab
# CA and a password). Every command shown is typed into a real login shell in a pty; Ana's files are copied into
# ~/menu from lab/steps off camera, as if saved from an editor.
set -euo pipefail
cd "$(dirname "$0")"
cleanup() { docker rm -f -v ce-p132-laptop >/dev/null 2>&1 || true; }
cleanup
[ -n "${KEEP:-}" ] || trap cleanup EXIT
docker build -q -t ce-p132-laptop lab/laptop >/dev/null
docker run -d --name ce-p132-laptop --hostname taco-laptop --privileged --cgroupns=private \
  --tmpfs /run --tmpfs /run/lock -v /var/lib/docker -v /var/lib/containerd ce-p132-laptop >/dev/null
for i in $(seq 60); do docker exec ce-p132-laptop docker info >/dev/null 2>&1 && break; sleep 1; done
python3 demo_driver.py ce-p132-laptop
