This is a customized version of the COS Toolbox image, modified to include a suite of production-grade profiling tools for multiple languages and system-level diagnostics.
- Java: Zero-copy JDK Flight Recorder (JFR) profiling via
jattach(Production-safe, works on read-only containers, no files written/copied to container filesystem). - Python:
py-spy(Optimized with--nonblockingand--idlefor production safety). - Golang: eBPF-based on-CPU profiling via
bpftrace(sampling user stacks at 99Hz). - Node.js: Fallback to eBPF-based off-CPU profiling.
- eBPF Diagnostics: CO-RE (Compile Once - Run Everywhere) versions of
biolatency,tcpretrans, andoffcputimeviabpftrace(No kernel headers needed!). - Auto-Packaging: Results are saved in a unique directory, compressed into a
.tar.xzfile, and checksummed with SHA-256.
To run eBPF tools successfully inside this container on a Container-Optimized OS (COS) node, you must override the default toolbox binds and permissions.
Add the following lines to your ${HOME}/.toolboxrc file on the COS host:
TOOLBOX_DOCKER_IMAGE="<your-artifact-registry-path>/app-toolbox"
TOOLBOX_DOCKER_TAG="0.2"
TOOLBOX_BIND="--bind=/:/media/root --bind=/usr:/media/root/usr --bind=/run:/media/root/run --bind=/sys:/sys --bind=/proc:/proc"
TOOLBOX_ENV="--system-call-filter=bpf --system-call-filter=perf_event_open"
Note: The TOOLBOX_BIND adds /sys and /proc mounts, and TOOLBOX_ENV unlocks the necessary system calls for eBPF.
To build the image using Google Cloud Build:
gcloud builds submit --config cloudbuild.yaml .
This will push the image to your configured Artifact Registry location.
-
SSH into your GKE node.
-
Ensure your
~/.toolboxrcis configured as shown in the Prerequisites. -
Launch the toolbox:
toolbox -
Run the interactive collector script:
app-collector -
Follow the prompts to select the Pod, Container, Language, and Duration.
At the end of the run, the script will output the path to the generated .tar.xz report file in /var.
- The host root filesystem is accessible inside the toolbox container at
/media/root. - The toolbox filesystem is accessible from the host at
/var/lib/toolbox/<USER>-gcr.io_cos-cloud_toolbox-<VERSION>/root/(where<USER>is your username and<VERSION>is the toolbox image version).
-
Access the host filesystem inside the toolbox:
USER@cos-dev ~ $ toolbox root@cos-dev:~# ls /media/root bin boot dev etc home lib lib64 ... root@cos-dev:~# cp /media/root/home/USER/some-file . -
Access the toolbox directory from the host:
USER@cos-dev ~ $ sudo cp some-file /var/lib/toolbox/USER-gcr.io_cos-cloud_toolbox-v20220722/root -
Run a command inside the toolbox and save its output to the host user's home directory:
USER@cos-dev ~ $ toolbox strace -o /media/root/$HOME/ls.strace ls USER@cos-dev ~ $ more $HOME/ls.strace
This is not an officially supported Google product. This project is not eligible for the Google Open Source Software Vulnerability Rewards Program.