Skip to content

Commit f2eae7a

Browse files
authored
remove manual change to pxl documentation, add tutorial for using TraceProgram to scope tracepoint deployments to supported nodes (#277)
Signed-off-by: Benjamin Kilimnik <bkilimnik@pixielabs.ai>
1 parent 6b5722a commit f2eae7a

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

content/en/04-tutorials/04-custom-data/01-distributed-bpftrace-deployment.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,43 @@ If you'd like to filter the results to a particular service, modify line 67 to i
170170
df = df[px.contains(df['dst'], 'sock-shop')]
171171
```
172172

173+
### Deploying different BPFtrace programs depending on properties of the host
174+
175+
Pixie has introduced a `TraceProgram` object in the `pxtrace` module, which allows you to specify deployment restrictions for your BPFtrace programs. You can use the `TraceProgram` object to define a BPFtrace program and specify the kernel versions on which it should be deployed (more selectors may be added in the future).
176+
177+
The `TraceProgram` object currently accepts the following parameters:
178+
179+
- `program`: The BPFtrace program as a string.
180+
- `max_kernel`: The maximum kernel version on which the program should be deployed.
181+
- `min_kernel`: The minimum kernel version on which the program should be deployed.
182+
183+
You can use the `TraceProgram` object to deploy different BPFtrace programs based on the kernel version of the nodes in your cluster. For example, you might have one version of a BPFtrace program that works on kernel versions up to 5.18, and another version that works on kernel versions 5.19 and above. $0 and $1 are placeholders for BPFtrace programs. You can define two `TraceProgram` objects and use them both in the `UpsertTracepoint` function.
184+
185+
Here's an example:
186+
187+
```python
188+
import pxtrace
189+
import px
190+
191+
before_518_trace_program = pxtrace.TraceProgram(
192+
program="""$0""",
193+
max_kernel='5.18',
194+
)
195+
after_519_trace_program = pxtrace.TraceProgram(
196+
program="""$1""",
197+
min_kernel='5.19',
198+
)
199+
200+
table_name = 'tcp_drop_table'
201+
pxtrace.UpsertTracepoint('tcp_drop_tracer',
202+
table_name,
203+
[before_518_trace_program, after_519_trace_program],
204+
pxtrace.kprobe(),
205+
'10m')
206+
```
207+
208+
In this example, the `before_518_trace_program` will be deployed on nodes with kernel versions up to 5.18, and the `after_519_trace_program` will be deployed on nodes with kernel versions 5.19 and above.
209+
173210
### Tracepoint status
174211

175212
Run `px/tracepoint_status` to see the information about all of the tracepoints running on your cluster. The `STATUS` column can be used to debug why a tracepoint fails to deploy.

0 commit comments

Comments
 (0)