-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathebpf-profiler.yaml
82 lines (81 loc) · 2.18 KB
/
ebpf-profiler.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
apiVersion: v1
kind: Pod
metadata:
name: ebpf-profiler
spec:
hostPID: true
containers:
- name: ebpf-profiler
image: {{PROFILER_IMAGE}}
imagePullPolicy: Always
securityContext:
privileged: true
command:
- nsenter
- --target
- "1"
- --uts
- --ipc
- --net
- --pid
- --cgroup
- --
- "/bin/bash"
- "-c"
- |-
export CONTAINER_RUNTIME_ENDPOINT=unix:///run/containerd/containerd.sock
TARGET_CONTAINER_ID=$(crictl ps | awk "/${TARGET_CONTAINER}/{print $1}")
TARGET_CONTAINER_PID=$(crictl inspect --output go-template --template '{{.info.pid}}' $TARGET_CONTAINER_ID)
echo "profiling pid $TARGET_CONTAINER_PID for seconds $SAMPLING_PERIOD"
SAMPLING_PERIOD=$(echo $SAMPLING_PERIOD | sed s/\"//g)
profile-bpfcc -dF 99 -f $SAMPLING_PERIOD -p $TARGET_CONTAINER_PID | tee ${TARGET_CONTAINER}.perf |/flamegraph.pl > /${TARGET_CONTAINER}.svg
echo "profiling complete"
sleep 30s #gives our script chance to copy out the flamegraph
env:
- name: SAMPLING_PERIOD
value: "{{SAMPLING_PERIOD}}"
- name: TARGET_POD
value: {{TARGET_POD}}
- name: TARGET_CONTAINER
value: {{TARGET_CONTAINER}}
volumeMounts:
- mountPath: /sys/kernel/debug
name: kernel-debug
- mountPath: /sys/fs/cgroup
name: fs-cgroup
- mountPath: /sys/fs/bpf
name: fs-bpf
- mountPath: /run/containerd
name: run-containerd
- mountPath: /usr/src
name: usr-src
- mountPath: /usr/local/bin
name: usr-local-bin
- mountPath: /lib/modules
name: lib-modules
nodeSelector:
kubernetes.io/hostname: {{AKS_NODE}}
imagePullSecrets:
- name: registrykey
volumes:
- name: kernel-debug
hostPath:
path: /sys/kernel/debug
- name: fs-cgroup
hostPath:
path: /sys/fs/cgroup
- name: fs-bpf
hostPath:
path: /sys/fs/bpf
- name: run-containerd
hostPath:
path: /run/containerd
- name: usr-src
hostPath:
path: /usr/src
- name: usr-local-bin
hostPath:
path: /usr/local/bin
- name: lib-modules
hostPath:
path: /lib/modules