Skip to main content
Version: main 🚧

Capture pprof for vCluster

This guide shows how to use Performance Profiling in Go (pprof) to capture CPU and memory profiles from vCluster. Capturing pprof is important for identifying performance bottlenecks and optimizing resource usage.

When vCluster experiences high CPU or memory usage, use profiling to identify performance bottlenecks and optimize resource consumption.

Setup and capture pprof on vCluster​

Enable verbose logging and pprof endpoint​

To make the logging more verbose and to enable the endpoint that serves pprof data, add the following environment variable in the Helm chart values:

controlPlane:
statefulSet:
env:
- name: "DEBUG"
value: "true"
note

You must be on the kube-context of the host cluster where the vCluster is running.

Port forwarding​

If you're not using the templates from the UI, you can execute the following commands from your terminal:

kubectl port-forward -n vclusternamespace pod/vclustername-0 10443:8443

This command allows you to access services running inside the virtual cluster from your local machine without exposing them publicly through the host Kubernetes cluster’s services or ingress.

If a template is not used, the values should be added directly to .spec.template.helmRelease.values in the VirtualClusterInstance.

Capture CPU profile​

Run the following command locally:

curl -k "https://localhost:10443/debug/pprof/profile?second=60" > profile60.prof

This command fetches a CPU profile of the vCluster pod's processes (such as the virtual Kubernetes API server) for the past 60 seconds. A profile60.prof file is created on your local system.

Capture memory profile​

In the terminal from your local, execute:

curl -k https://localhost:10443/debug/pprof/heap -o heapprofile.prof

This command fetches a heap profile from the vCluster pod by sending a request to the /debug/pprof/heap endpoint. You should see a heapprofile.prof file created on your local system.

Next steps​

After you've captured these files, you can send them to us. This enables us to identify opportunities for optimization and enhance the performance of your application.