From 114023382d89a0661a9ce7e4c6531e5c2c629110 Mon Sep 17 00:00:00 2001 From: Moritz Sanft <58110325+msanft@users.noreply.github.com> Date: Wed, 20 Nov 2024 18:10:32 +0100 Subject: [PATCH] packages/kata-debug-shell: init Add a little helper script to get a shell into a Kata pod VM with a single command. --- packages/kata-debug-shell.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 packages/kata-debug-shell.sh diff --git a/packages/kata-debug-shell.sh b/packages/kata-debug-shell.sh new file mode 100644 index 000000000..13bf1bebb --- /dev/null +++ b/packages/kata-debug-shell.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +set -euo pipefail + +if [ "$(id -u)" -ne 0 ]; then + echo "Please run as root" + exit 1 +fi + +if [ -z "${1:-}" ]; then + echo "Usage: $0 " + exit 1 +fi + +container_info=$(k3s ctr c info "$1") + +sbx_id=$(echo "$container_info" | jq -r '.Spec.annotations."io.kubernetes.cri.sandbox-id"') +runtime_class_name=$(echo "$container_info" | jq -r '.Snapshotter' | cut -c7-) + +kata_runtime="/opt/edgeless/${runtime_class_name}/bin/kata-runtime" +config_file=$(ls -1 "/opt/edgeless/${runtime_class_name}/etc") + +${kata_runtime} --config "/opt/edgeless/${runtime_class_name}/etc/${config_file}" exec ${sbx_id}