You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tools/demo.md
+5-9Lines changed: 5 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -108,8 +108,10 @@ These examples show various ways to leverage the gadget for tracing executions i
108
108
# Run simple example with trace_exec with a 10-second timeout to prevent indefinite execution:
109
109
timeout 5s kubectl gadget run trace_exec ||true
110
110
111
+
kubectl delete pod demo-pod
112
+
111
113
# Create a background pod that will generate events for us to trace:
112
-
kubectl run demo-pod --image=ubuntu -- /bin/bash -c "for i in {1..30}; do echo Running commands...; ls -la /; sleep 1; done"
114
+
kubectl run demo-pod --image=ubuntu -- /bin/bash -c "for i in {1..11}; do echo Running commands...; ls -la /; sleep 1; done"
113
115
114
116
# Wait briefly for the pod to start generating events
115
117
sleep 5
@@ -118,7 +120,7 @@ sleep 5
118
120
timeout 5s kubectl gadget run trace_exec --output jsonpretty ||true
119
121
120
122
# Run gadget with filtering and timeout
121
-
timeout 5s kubectl gadget run trace_exec --all-namespaces --filter proc.comm=bash ||true
123
+
timeout 5s kubectl gadget run trace_exec --all-namespaces --filter proc.comm=bash ||echo"Attachment timed out, continuing with demo"
122
124
```
123
125
124
126
Each command demonstrates a different facet of the gadget's capabilities, from initiating traces to filtering outputs based on process names.
@@ -139,20 +141,14 @@ cat alert-bad-process.yaml
139
141
140
142
## Exporting Metrics and Managing Gadget Lifecycle
141
143
142
-
This section deploys the gadget manifest using the YAML file created in the previous section. The command includes several annotations to instruct the gadget to collect metrics. The process is detached so that it runs in the background. Subsequently, the script lists the running gadget instances and attaches to the deployed alert for further inspection if necessary.
144
+
This section deploys the gadget manifest using the YAML file created in the previous section. The command includes several annotations to instruct the gadget to collect metrics. The process is detached so that it runs in the background. Subsequently, the script lists the running gadget instances.
143
145
144
146
```bash
145
147
# Clean up any existing instance of the same name
146
148
kubectl gadget delete alert-bad-process
147
149
148
150
# Run gadget manifest to export metrics:
149
151
kubectl gadget run -f alert-bad-process.yaml --annotate exec:metrics.collect=true,exec:metrics.implicit-counter.name=shell_executions,exec.k8s.namespace:metrics.type=key,exec.k8s.podname:metrics.type=key,exec.k8s.containername:metrics.type=key --detach
These commands ensure that metrics are being collected as defined in the YAML manifest and verify that the gadget is running correctly in headless mode.
0 commit comments