This repository contains the configuration files and setup instructions for implementing Continuous Application Profiling in a Kubernetes environment using Calico Open Source and Grafana Pyroscope.
Continuous profiling allows you to identify performance bottlenecks and resource inefficiencies at a granular level (CPU, memory, etc.) in production environments with minimal overhead.
- Helm installed.
- Multipass installed (for local cluster setup).
- A Kubernetes cluster (setup instructions included below).
- Calico v3.28 or above
Use the following commands to launch a 3-node Kubernetes cluster using Multipass and K3s.
multipass launch -n c1-control -c 2 -m 8192M -d 50G 22.04 --cloud-init release/control-init.yaml
multipass launch -n c1-node1 -c 2 -m 4096M -d 50G 22.04 --cloud-init release/node-init.yaml
multipass launch -n c1-node2 -c 2 -m 4096M -d 50G 22.04 --cloud-init release/node-init.yamlmultipass transfer c1-control:/etc/rancher/k3s/k3s.yaml ./c1.configexport KUBECONFIG=$(pwd)/c1.config
CONTROL=$(multipass list --format csv | egrep c1-control | cut -d, -f3)
sed -i c1.config "s/127.0.0.1/$CONTROL/" First install Tigera opreator
kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.28.0/manifests/tigera-operator.yamlUse the following installation manifest to install Calico
kubectl create -f -<<EOF
apiVersion: operator.tigera.io/v1
kind: Installation
metadata:
name: default
spec:
registry: quay.io/
calicoNetwork:
bgp: Disabled
ipPools:
- blockSize: 26
cidr: 172.16.0.0/16
encapsulation: VXLAN
natOutgoing: Enabled
nodeSelector: all()
---
apiVersion: operator.tigera.io/v1
kind: APIServer
metadata:
name: default
spec: {}
EOFCalico 3.28+ supports native Go pprof profiling. By default, the profiling server is disabled.
Use the following command to enable the debug port (9096) on the default Felix configuration:
kubectl patch felixconfiguration default --type=merge -p='{"spec":{"debugPort":9096}}'To allow the profiling server to respond to requests from any origin (required for scraping by external agents):
kubectl patch felixconfiguration default --type=merge -p='{"spec":{"debugHost":"0.0.0.0"}}'Pyroscope is used to collect and visualize profiling data.
helm repo add grafana https://grafana.github.io/helm-charts
helm repo update
helm install pyroscope grafana/pyroscope -n calico-monitoringWe use the Grafana Agent to scrape profiling data from our workloads.
Scrape Calico’s native pprof metrics using the provided configuration:
helm install -n calico-monitoring pyroscope-agent grafana/grafana-agent \
-f https://raw.githubusercontent.com/frozenprocess/pyroscope_observability_blog/main/scrape-pprof.yamlFor applications that do not have native profiling libraries, use eBPF probes. This method is transparent and requires no code changes.
helm upgrade -n calico-monitoring pyroscope-agent grafana/grafana-agent \
-f https://raw.githubusercontent.com/frozenprocess/pyroscope_observability_blog/main/scrape-combine.yaml