Skip to content

Commit

Permalink
packages/kata-debug-shell: init
Browse files Browse the repository at this point in the history
Add a little helper script to get a shell into a Kata pod VM with a single command.
  • Loading branch information
msanft committed Nov 20, 2024
1 parent 3cff8bf commit 1140233
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions packages/kata-debug-shell.sh
Original file line number Diff line number Diff line change
@@ -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 <container_id>"
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}

0 comments on commit 1140233

Please sign in to comment.