Skip to content

eBPF-based security platform

testing: share local OCI and telemetry services with VM tests

John Fastabend2917fc4e7e52
diff --git a/Documentation/contribute/testing/test-coverage.rst b/Documentation/contribute/testing/test-coverage.rst
index 27fd3bb8..2f7eae83 100644
--- a/Documentation/contribute/testing/test-coverage.rst
+++ b/Documentation/contribute/testing/test-coverage.rst
@@ -103,6 +103,9 @@ signed config image.
- Script regex matching through ``-t`` and ``TEST_FILTER``, command-line
precedence, empty and invalid patterns, ordering and failure status
+ * - ``t1010-local-stack``
+ - VM-first service configuration and stable public trust across starts
+
``signing`` (2)
~~~~~~~~~~~~~~~
diff --git a/Documentation/contribute/testing/testing.rst b/Documentation/contribute/testing/testing.rst
index 1da86dd7..791e4482 100644
--- a/Documentation/contribute/testing/testing.rst
+++ b/Documentation/contribute/testing/testing.rst
@@ -554,6 +554,50 @@ failed keeps its disks too, copies its logs to
overlay holds an ephemeral signing key, so do not share the state
directory.
+Run a local development stack
+-----------------------------
+
+From the checkout root, run the following commands in any order:
+
+.. code-block:: console
+
+ $ make oci
+ $ make telemetry
+ # make vm
+
+``make oci`` starts a persistent TLS OCI registry on
+``127.0.0.1:15444``. ``make telemetry`` starts the OTLP collector on
+``https://127.0.0.1:14319`` and ClickHouse on
+``http://127.0.0.1:18124``. Both targets are idempotent. They use the same
+container helpers as the end-to-end tests, which use separate ports and
+storage.
+
+``make stack-up`` is shorthand for ``make oci telemetry``. Start the VM
+with ``make vm``.
+
+``make vm`` prepares a stable CA even when neither service is running.
+After initialization, it activates the signed ``config-local-stack``
+image. That image points telemetry at ``https://10.0.2.2:14319`` and the
+BPM tree at ``oci://10.0.2.2:15444/shirudo/local-tree``, reference
+``stable``. The existing timers retry exports and tree sync when services
+are unavailable; starting the containers later needs no VM reboot.
+The registry starts empty. Publish a signed tree at that reference using
+the VM bundle's operator key under ``TEST_VM_HOST_PRIVATE_DIR`` to load
+upatches. Keepalives can reach the collector before any upatch is loaded.
+The VM's node labels include ``role=local``.
+
+The public CA and service data live under ``build/test-vm/stack/``;
+collector JSON is ``out/otlp.json`` there. Server private keys live outside
+the checkout in a directory under ``/tmp`` named for the checkout's hash.
+Normal and sudo invocations use the same trust material. The guest
+receives only the public CA. ``make stack-down`` removes the service
+containers and network while retaining the data and CA for the next start.
+It does not stop the VM; use ``make vm-stop`` for that.
+
+``make -C testing vm`` uses the same defaults. Set ``LOCAL_STACK=0`` to
+boot a VM without the local-stack configuration and use the explicit
+endpoint settings described above instead.
+
Run the end-to-end tests
------------------------
diff --git a/Makefile b/Makefile
index 16aa68a7..089c51cf 100644
--- a/Makefile
+++ b/Makefile
@@ -87,6 +87,7 @@ help:
@printf '%s\n' \
'shirudo make targets:' \
' Build: make, make target, make target-deps, make bpf-deps, make install' \
+ ' Local stack: make stack-up, make oci, make telemetry, make vm, make stack-down' \
' Checks: make sparse' \
' Install roles: make install-target, make install-operator' \
' Package: make -C packaging help' \
@@ -146,3 +147,7 @@ distclean: clean
$(Q)rm -f config.mk
+$(Q)$(MAKE) -f Makefile.target-deps TARGET_DEPS_DIR="$(TARGET_DEPS_DIR)" clean
$(Q)$(MAKE) -f Makefile.shirudo distclean
+
+.PHONY: vm vm-console vm-ssh vm-stop vm-clean oci telemetry stack-up stack-down
+vm vm-console vm-ssh vm-stop vm-clean oci telemetry stack-up stack-down:
+ +$(Q)$(MAKE) -C testing $@
diff --git a/testing/Makefile b/testing/Makefile
index 234b0b40..cf204bb5 100644
--- a/testing/Makefile
+++ b/testing/Makefile
@@ -210,6 +210,8 @@ $(VM_KERNEL_STAMP):
endif
endif
+LOCAL_STACK ?= 1
+
vm: $(VM_KERNEL_DEP) test-vm-bundle
$(Q)VM_MODE=interactive VM_NAME="$(VM_NAME)" VM_TENANT="$(VM_TENANT)" \
TEST_VM_KERNEL="$(abspath $(VM_KERNEL_IMAGE))" \
@@ -232,7 +234,7 @@ vm: $(VM_KERNEL_DEP) test-vm-bundle
TEST_VM_BPM_OCI_INDEX_CERT="$(TEST_VM_BPM_OCI_INDEX_CERT)" \
TEST_VM_MODE="$(TEST_VM_MODE)" TEST_VM_INITRD="$(TEST_VM_INITRD)" \
TEST_VM_HOST_BUNDLE="$(abspath $(TEST_VM_BUNDLE_DIR))" \
- $(ROOT)/testing/vm/run.sh
+ $(if $(filter 0,$(LOCAL_STACK)),,$(ROOT)/testing/vm/stack.sh vm) $(ROOT)/testing/vm/run.sh
vm-console:
$(Q)VM_NAME="$(VM_NAME)" \
TEST_VM_WORK_DIR="$(TEST_VM_WORK_DIR)" $(ROOT)/testing/vm/run.sh --console
@@ -370,6 +372,7 @@ help:
' make -C testing vm KERNEL=7.4' \
' make -C testing kernel KERNEL_TAG=v7.4' \
' make -C testing bpf-next, bundle or test-helpers' \
+ ' make -C testing stack-up, oci, telemetry or stack-down' \
' make -C testing clean'
clean:
@@ -381,3 +384,11 @@ clean:
rm -rf "$$bundle_dir" "$$bundle_dir.operator" \
"$(abspath $(TEST_VM_HOST_PRIVATE_DIR))/operator-keys" \
$(ROOT)/build/test-vm/end2end
+
+.PHONY: oci telemetry stack-up stack-down
+stack-up: oci telemetry
+
+oci telemetry:
+ $(Q)TEST_VM_HOST_PRIVATE_DIR="$(TEST_VM_HOST_PRIVATE_DIR)" $(ROOT)/testing/vm/stack.sh $@
+stack-down:
+ $(Q)TEST_VM_HOST_PRIVATE_DIR="$(TEST_VM_HOST_PRIVATE_DIR)" $(ROOT)/testing/vm/stack.sh down
diff --git a/testing/end2end/host.sh b/testing/end2end/host.sh
index 7404a307..5ee3cfba 100755
--- a/testing/end2end/host.sh
+++ b/testing/end2end/host.sh
@@ -15,11 +15,9 @@ TLS_DIR=$HOST_PRIVATE_DIR/end2end-tls
REGISTRY=127.0.0.1:15443
COLLECTOR=127.0.0.1:14318
CLICKHOUSE=127.0.0.1:18123
-# registry 3.1.2 and opentelemetry-collector-contrib 0.164.0, both built
-# with a Go that offers the hybrid ML-KEM group shirudo requires.
-REGISTRY_IMAGE=docker.io/library/registry@sha256:d4032d4cc323c1731c707931ecada07a53076eac38e3b61ae57533f170f2c6c3
-COLLECTOR_IMAGE=docker.io/otel/opentelemetry-collector-contrib@sha256:340c9ca6a36617084c6661bdc4f0fe92b7cda5a805d61673ec8db375fddc522b
-CLICKHOUSE_IMAGE=docker.io/clickhouse/clickhouse-server@sha256:d426d2f612e1e189c90f9a3f8dcd85a03c6851273833817a296bb327e63aa7a7
+. "$REPO/testing/vm/stack-lib.sh"
+STACK_NAME=shirudo-end2end
+STACK_PERSIST=0
S=$REPO/shirudo
export SHIRUDO_BUILD="$REPO/tools/shirudo-build/shirudo-build"
export BPM_OCI_CA_FILE="$W/ca.pem"
@@ -32,25 +30,10 @@ say() { printf 'end2end: %s\n' "$*"; }
die() { printf 'end2end: %s\n' "$*" >&2; exit 1; }
down() {
- docker logs shirudo-end2end-collector >"$W/collector.log" 2>&1 || true
- docker logs shirudo-end2end-clickhouse >"$W/clickhouse.log" 2>&1 || true
- docker rm -f shirudo-end2end-registry shirudo-end2end-collector \
- shirudo-end2end-clickhouse \
- >/dev/null 2>&1 || true
- docker network rm shirudo-end2end >/dev/null 2>&1 || true
+ stack_down
rm -rf -- "$TLS_DIR"
}
-# Up to ten seconds for a TLS service to answer an HTTP request.
-wait_https() {
- i=0
- until curl -fsS --cacert "$W/ca.pem" "$@" >/dev/null 2>&1; do
- i=$((i + 1))
- [ "$i" -lt 50 ] || return 1
- sleep 0.2
- done
-}
-
command -v docker >/dev/null 2>&1 || die "docker is required"
private_dir="$(realpath -m "$HOST_PRIVATE_DIR")"
repo_dir="$(realpath -m "$REPO")"
@@ -68,47 +51,11 @@ down
install -d -m 0755 "$TLS_DIR"
trap down EXIT
-say "a CA, and a server certificate for the registry and the collector"
-openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:P-256 -nodes \
- -keyout "$TLS_DIR/ca.key" -out "$W/ca.pem" -days 1 \
- -subj /CN=shirudo-end2end-ca \
- -addext 'basicConstraints=critical,CA:TRUE' \
- -addext 'keyUsage=critical,keyCertSign,cRLSign' 2>/dev/null
-openssl req -newkey ec -pkeyopt ec_paramgen_curve:P-256 -nodes \
- -keyout "$TLS_DIR/server.key" -out "$TLS_DIR/server.csr" \
- -subj /CN=shirudo-end2end 2>/dev/null
-printf 'subjectAltName=IP:127.0.0.1,IP:10.0.2.2\n' >"$TLS_DIR/server.ext"
-openssl x509 -req -in "$TLS_DIR/server.csr" -CA "$W/ca.pem" \
- -CAkey "$TLS_DIR/ca.key" -CAcreateserial -out "$TLS_DIR/server.pem" \
- -days 1 -extfile "$TLS_DIR/server.ext" 2>/dev/null
-rm -f -- "$TLS_DIR/ca.key" "$TLS_DIR/server.csr" \
- "$TLS_DIR/server.ext" "$TLS_DIR/ca.srl"
-chmod 0644 "$TLS_DIR/server.key"
+stack_prepare
openssl rand -hex 16 >"$W/nonce"
-
say "the registry, collector and ClickHouse"
-docker network create shirudo-end2end >/dev/null
-docker run -d --name shirudo-end2end-clickhouse \
- --network shirudo-end2end --network-alias clickhouse \
- -p "$CLICKHOUSE:8123" -e CLICKHOUSE_SKIP_USER_SETUP=1 \
- "$CLICKHOUSE_IMAGE" >/dev/null
-i=0
-until curl -fsS --data-binary 'SELECT 1' "http://$CLICKHOUSE/" >/dev/null 2>&1; do
- i=$((i + 1))
- [ "$i" -lt 150 ] || die "ClickHouse did not come up"
- sleep 0.2
-done
-docker run -d --name shirudo-end2end-registry -p "$REGISTRY:5000" \
- -v "$TLS_DIR:/certs:ro" -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/server.pem \
- -e REGISTRY_HTTP_TLS_KEY=/certs/server.key "$REGISTRY_IMAGE" >/dev/null
-docker run -d --name shirudo-end2end-collector -p "$COLLECTOR:4318" \
- --network shirudo-end2end \
- -v "$TLS_DIR:/certs:ro" -v "$W/out:/out" \
- -v "$REPO/testing/end2end/otelcol.yaml:/etc/otelcol-contrib/config.yaml:ro" \
- "$COLLECTOR_IMAGE" >/dev/null
-wait_https "https://$REGISTRY/v2/" || die "the registry did not come up"
-wait_https -X POST -H 'Content-Type: application/json' -d '{}' \
- "https://$COLLECTOR/v1/logs" || die "the collector did not come up"
+stack_oci || die "the registry did not come up"
+stack_telemetry || die "the telemetry stack did not come up"
say "the operator builds, pushes and publishes kernel-obs"
cp -R upatches/kernel-obs "$W/pkg/kernel-obs"
diff --git a/testing/functional/build/t1010-local-stack.sh b/testing/functional/build/t1010-local-stack.sh
new file mode 100644
index 00000000..76b1fd6c
--- /dev/null
+++ b/testing/functional/build/t1010-local-stack.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+# SPDX-License-Identifier: BSD-2-Clause
+# Copyright (c) 2026 Authors of shirudo
+
+cd "$(dirname "$0")/../.."
+. ./test-lib.sh
+command -v openssl >/dev/null 2>&1 || test_skip_all 'no openssl'
+WORK=$(mktemp -d)
+trap 'rm -rf "$WORK"' EXIT
+export TEST_VM_STACK_DIR="$WORK/public" TEST_VM_STACK_PRIVATE_DIR="$WORK/private"
+
+cat >"$WORK/inspect.sh" <<'EOF'
+set -eu
+[ "$TEST_VM_LOCAL_STACK" = 1 ]
+[ "$TEST_VM_MAP_EXPORT_ENDPOINT" = https://10.0.2.2:14319 ]
+[ "$TEST_VM_MAP_EXPORT_INSECURE" = false ]
+[ "$TEST_VM_OCI_CA" = "$TEST_VM_MAP_EXPORT_CA" ]
+[ -s "$TEST_VM_OCI_CA" ]
+EOF
+
+test_expect_success 'a VM can prepare trust and endpoints before services exist' '
+ vm/stack.sh vm sh "$WORK/inspect.sh" &&
+ test ! -e "$TEST_VM_STACK_DIR/server.key" &&
+ test ! -e "$TEST_VM_STACK_DIR/ca.key"
+'
+
+test_expect_success 'preparing services later preserves the VM trust anchor' '
+ cp "$TEST_VM_STACK_DIR/ca.pem" "$WORK/original.pem" &&
+ vm/stack.sh prepare &&
+ cmp "$TEST_VM_STACK_DIR/ca.pem" "$WORK/original.pem"
+'
+
+test_done
diff --git a/testing/vm/files/local-stack-tree.conf b/testing/vm/files/local-stack-tree.conf
new file mode 100644
index 00000000..96fcb3c7
--- /dev/null
+++ b/testing/vm/files/local-stack-tree.conf
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: BSD-2-Clause
+# Copyright (c) 2026 Authors of shirudo
+endpoint = oci://10.0.2.2:15444/shirudo/local-tree
+reference = stable
diff --git a/testing/vm/files/local-stack.conf b/testing/vm/files/local-stack.conf
new file mode 100644
index 00000000..1cca76bc
--- /dev/null
+++ b/testing/vm/files/local-stack.conf
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: BSD-2-Clause
+# Copyright (c) 2026 Authors of shirudo
+map_export.tenant_id = local
+map_export.otel_endpoint = https://10.0.2.2:14319
+map_export.otel_retries = 2
diff --git a/testing/vm/guest.sh b/testing/vm/guest.sh
index 9d7a3a39..b2ff30a9 100755
--- a/testing/vm/guest.sh
+++ b/testing/vm/guest.sh
@@ -414,6 +414,13 @@ if tpm.get("chain_matches_eventlog") is not True:
raise SystemExit("register does not match the shirudo eventlog")
PY
+if [[ "${TEST_VM_LOCAL_STACK:-0}" == 1 ]]; then
+ "$SHIRUDO_BIN" image update /var/lib/shirudo/images/config-local-stack
+ install -d /etc/shirudo/bpm
+ printf '%s\n' 'BPM_OCI_CA_FILE=/usr/local/share/ca-certificates/shirudo-oci-ca.crt' \
+ >/etc/shirudo/bpm/environment
+fi
+
if [[ -n "${TEST_VM_BPM_TREE_INPUT:-}" ]]; then
log "performing initial BPM tree sync"
tree_sync_ok=0
diff --git a/testing/vm/image-fixtures.sh b/testing/vm/image-fixtures.sh
index 84c181b2..688444ac 100755
--- a/testing/vm/image-fixtures.sh
+++ b/testing/vm/image-fixtures.sh
@@ -74,7 +74,7 @@ for name in config-boot-keys config-live-new-key config-live-revoke-a config-a c
config-tree-stable config-tree-updated config-tree-deleted config-tree-restored \
config-tree-kconfig config-tree-reloaded \
config-otel config-jsonl config-jsonl-bad config-interrupted config-end2end \
- config-builtin config-untrusted; do
+ config-local-stack config-builtin config-untrusted; do
[ "$name" != config-builtin ] || [ -n "$builtin_key" ] || continue
root="$output/source/$name"
mkdir -p "$root/etc/shirudo" "$root/keys/trusted" "$root/keys/revoked"
@@ -94,6 +94,12 @@ for name in config-boot-keys config-live-new-key config-live-revoke-a config-a c
config-jsonl|config-jsonl-bad)
cp "$templates/${name#config-}.conf" "$root/etc/shirudo/shirudo.conf"
;;
+ config-local-stack)
+ mkdir -p "$root/etc/shirudo/bpm"
+ cp "$templates/local-stack.conf" "$root/etc/shirudo/shirudo.conf"
+ cp "$templates/local-stack-tree.conf" "$root/etc/shirudo/bpm/upatch-tree.conf"
+ printf 'role=local\n' >"$root/etc/shirudo/node.labels"
+ ;;
config-end2end)
mkdir -p "$root/etc/shirudo/bpm"
printf 'role=end2end\n' >"$root/etc/shirudo/node.labels"
diff --git a/testing/vm/run.sh b/testing/vm/run.sh
index f6056157..43d17bf5 100755
--- a/testing/vm/run.sh
+++ b/testing/vm/run.sh
@@ -1469,6 +1469,7 @@ if [[ -n "$KERNEL_ARTIFACT_DIR" ]]; then
export TEST_VM_KERNEL_MODULES=/mnt/shirudo-kernel/lib/modules
EOF
fi
+printf ' export TEST_VM_LOCAL_STACK=%q\n' "${TEST_VM_LOCAL_STACK:-0}" >>"$USER_DATA"
printf ' export VM_MODE=%q\n' "$VM_MODE" >>"$USER_DATA"
printf ' export TEST_VM_MODE=%q\n' "$TEST_MODE" >>"$USER_DATA"
printf ' export TEST_VM_SUITE=%q\n' "$VM_SUITE" >>"$USER_DATA"
diff --git a/testing/vm/stack-lib.sh b/testing/vm/stack-lib.sh
new file mode 100644
index 00000000..4ff69e7b
--- /dev/null
+++ b/testing/vm/stack-lib.sh
@@ -0,0 +1,102 @@
+#!/bin/sh
+# SPDX-License-Identifier: BSD-2-Clause
+# Copyright (c) 2026 Authors of shirudo
+
+# registry 3.1.2 and opentelemetry-collector-contrib 0.164.0, both built
+# with a Go that offers the hybrid ML-KEM group shirudo requires.
+REGISTRY_IMAGE=docker.io/library/registry@sha256:d4032d4cc323c1731c707931ecada07a53076eac38e3b61ae57533f170f2c6c3
+COLLECTOR_IMAGE=docker.io/otel/opentelemetry-collector-contrib@sha256:340c9ca6a36617084c6661bdc4f0fe92b7cda5a805d61673ec8db375fddc522b
+CLICKHOUSE_IMAGE=docker.io/clickhouse/clickhouse-server@sha256:d426d2f612e1e189c90f9a3f8dcd85a03c6851273833817a296bb327e63aa7a7
+
+stack_prepare()
+{
+ mkdir -p "$W/out"
+ chmod 0777 "$W/out"
+ install -d -m 0700 "$(dirname "$TLS_DIR")"
+ install -d -m 0755 "$TLS_DIR"
+ if [ -s "$W/ca.pem" ] && [ -s "$TLS_DIR/server.pem" ] &&
+ [ -s "$TLS_DIR/server.key" ]; then
+ return 0
+ fi
+ openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:P-256 -nodes \
+ -keyout "$TLS_DIR/ca.key" -out "$W/ca.pem" -days 3650 \
+ -subj /CN=shirudo-end2end-ca \
+ -addext 'basicConstraints=critical,CA:TRUE' \
+ -addext 'keyUsage=critical,keyCertSign,cRLSign' 2>/dev/null
+ openssl req -newkey ec -pkeyopt ec_paramgen_curve:P-256 -nodes \
+ -keyout "$TLS_DIR/server.key" -out "$TLS_DIR/server.csr" \
+ -subj /CN=shirudo-end2end 2>/dev/null
+ printf 'subjectAltName=IP:127.0.0.1,IP:10.0.2.2\n' >"$TLS_DIR/server.ext"
+ openssl x509 -req -in "$TLS_DIR/server.csr" -CA "$W/ca.pem" \
+ -CAkey "$TLS_DIR/ca.key" -CAcreateserial -out "$TLS_DIR/server.pem" \
+ -days 3650 -extfile "$TLS_DIR/server.ext" 2>/dev/null
+ rm -f -- "$TLS_DIR/ca.key" "$TLS_DIR/server.csr" \
+ "$TLS_DIR/server.ext" "$W/ca.srl"
+ chmod 0644 "$TLS_DIR/server.key"
+}
+
+stack_wait_https()
+{
+ attempt=0
+ until curl -fsS --max-time 2 --cacert "$W/ca.pem" "$@" >/dev/null 2>&1; do
+ attempt=$((attempt + 1))
+ [ "$attempt" -lt 50 ] || return 1
+ sleep 0.2
+ done
+}
+
+stack_run()
+{
+ container=$1
+ shift
+ if docker container inspect "$container" >/dev/null 2>&1; then
+ docker start "$container" >/dev/null
+ else
+ docker run -d --name "$container" "$@" >/dev/null
+ fi
+}
+
+stack_oci()
+{
+ set --
+ [ "${STACK_PERSIST:-1}" = 0 ] || set -- -v "$W/registry:/var/lib/registry"
+ stack_run "$STACK_NAME-registry" "$@" -p "$REGISTRY:5000" \
+ -v "$TLS_DIR:/certs:ro" \
+ -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/server.pem \
+ -e REGISTRY_HTTP_TLS_KEY=/certs/server.key "$REGISTRY_IMAGE"
+ stack_wait_https "https://$REGISTRY/v2/"
+}
+
+stack_telemetry()
+{
+ docker network inspect "$STACK_NAME" >/dev/null 2>&1 ||
+ docker network create "$STACK_NAME" >/dev/null
+ set --
+ [ "${STACK_PERSIST:-1}" = 0 ] || set -- -v "$W/clickhouse:/var/lib/clickhouse"
+ stack_run "$STACK_NAME-clickhouse" "$@" --network "$STACK_NAME" \
+ --network-alias clickhouse -p "$CLICKHOUSE:8123" \
+ -e CLICKHOUSE_SKIP_USER_SETUP=1 "$CLICKHOUSE_IMAGE"
+ attempt=0
+ until curl -fsS --max-time 2 --data-binary 'SELECT 1' \
+ "http://$CLICKHOUSE/" >/dev/null 2>&1; do
+ attempt=$((attempt + 1))
+ [ "$attempt" -lt 150 ] || return 1
+ sleep 0.2
+ done
+ stack_run "$STACK_NAME-collector" --network "$STACK_NAME" \
+ -p "$COLLECTOR:4318" -v "$TLS_DIR:/certs:ro" \
+ -v "$W/out:/out" \
+ -v "$REPO/testing/end2end/otelcol.yaml:/etc/otelcol-contrib/config.yaml:ro" \
+ "$COLLECTOR_IMAGE"
+ stack_wait_https -X POST -H 'Content-Type: application/json' -d '{}' \
+ "https://$COLLECTOR/v1/logs"
+}
+
+stack_down()
+{
+ docker logs "$STACK_NAME-collector" >"$W/collector.log" 2>&1 || true
+ docker logs "$STACK_NAME-clickhouse" >"$W/clickhouse.log" 2>&1 || true
+ docker rm -fv "$STACK_NAME-registry" "$STACK_NAME-collector" \
+ "$STACK_NAME-clickhouse" >/dev/null 2>&1 || true
+ docker network rm "$STACK_NAME" >/dev/null 2>&1 || true
+}
diff --git a/testing/vm/stack.sh b/testing/vm/stack.sh
new file mode 100755
index 00000000..ff56deb1
--- /dev/null
+++ b/testing/vm/stack.sh
@@ -0,0 +1,58 @@
+#!/bin/sh
+# SPDX-License-Identifier: BSD-2-Clause
+# Copyright (c) 2026 Authors of shirudo
+
+set -eu
+REPO=$(cd "$(dirname "$0")/../.." && pwd)
+W=${TEST_VM_STACK_DIR:-$REPO/build/test-vm/stack}
+owner=$(stat -c '%u:%g' "$REPO")
+checkout=$(printf '%s' "$REPO" | sha256sum | cut -c1-16)
+TLS_DIR=${TEST_VM_STACK_PRIVATE_DIR:-/tmp/shirudo-stack-$checkout}/tls
+TLS_DIR=$(realpath -m "$TLS_DIR")
+STACK_NAME=shirudo-dev
+REGISTRY=127.0.0.1:15444
+COLLECTOR=127.0.0.1:14319
+CLICKHOUSE=127.0.0.1:18124
+. "$REPO/testing/vm/stack-lib.sh"
+mkdir -p "$W"
+if [ "$(id -u)" = 0 ]; then
+ touch "$W/.lock"
+ chown "$owner" "$W" "$W/.lock"
+fi
+exec 9>"$W/.lock"
+flock 9
+case "$TLS_DIR/" in "$REPO/"*) echo 'stack private keys must be outside the checkout' >&2; exit 1 ;; esac
+command=${1:?usage: stack.sh prepare|oci|telemetry|down|vm}
+shift
+prepare()
+{
+ stack_prepare
+ if [ "$(id -u)" = 0 ]; then
+ chown "$owner" "$(dirname "$TLS_DIR")" "$TLS_DIR" \
+ "$TLS_DIR/server.pem" "$TLS_DIR/server.key" "$W/ca.pem" "$W/out"
+ fi
+}
+
+case "$command" in
+prepare) prepare ;;
+oci) prepare; stack_oci; printf 'OCI: oci://%s (CA: %s/ca.pem)\n' "$REGISTRY" "$W" ;;
+telemetry)
+ prepare
+ stack_telemetry
+ printf 'OTLP: https://%s; ClickHouse: http://%s\n' "$COLLECTOR" "$CLICKHOUSE"
+ ;;
+down) stack_down ;;
+vm)
+ prepare
+ export TEST_VM_LOCAL_STACK=1
+ export TEST_VM_MAP_EXPORT_CA="$W/ca.pem" TEST_VM_OCI_CA="$W/ca.pem"
+ export TEST_VM_MAP_EXPORT_ENDPOINT=https://10.0.2.2:14319
+ export TEST_VM_MAP_EXPORT_INSECURE=false
+ VM_TENANT=${VM_TENANT:-local}
+ export VM_TENANT
+ flock -u 9
+ exec 9>&-
+ exec "$@"
+ ;;
+*) echo "unknown stack command: $command" >&2; exit 2 ;;
+esac