Skip to content

Commit 94c0739

Browse files
improved claude commands
1 parent 9ef7e31 commit 94c0739

File tree

2 files changed

+59
-62
lines changed

2 files changed

+59
-62
lines changed

.claude/commands/debug-operator.md

Lines changed: 33 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,34 @@ This command prepares the environment for debugging the operator locally.
88

99
### 1. Scale down the in-cluster operator
1010

11-
To debug locally, scale down the operator running in the cluster:
11+
Scale down the operator running in the cluster to avoid conflicts:
1212

1313
```bash
1414
kubectl scale deployment netobserv-controller-manager -n netobserv --replicas=0
1515
```
1616

17-
### 2. Remove the validating webhook for local development
17+
### 2. Remove the validating webhook
18+
19+
Delete the webhook to allow free modification of the FlowCollector CR during local development:
1820

1921
```bash
2022
kubectl delete validatingwebhookconfiguration netobserv-validating-webhook-configuration
2123
```
2224

23-
This allows you to freely modify the FlowCollector CR while running the operator locally.
24-
2525
### 3. Run the operator locally
2626

27-
**Now ask the user which option they prefer:**
27+
Use the AskUserQuestion tool to ask which debugging method to use:
2828

29-
- **Option A: Run with go run** (simple execution without debugging)
30-
- **Option B: Run with delve** (interactive debugging in terminal with dlv commands)
31-
- **Option C: Run with delve headless + VSCode** (debugging with VSCode UI and breakpoints)
29+
**Question:** "How do you want to run the operator locally?"
30+
- **Header:** "Debug method"
31+
- **Options:**
32+
1. "go run - Simple execution without debugging"
33+
2. "delve interactive - Terminal debugging with dlv commands"
34+
3. "delve headless + VSCode - UI debugging with breakpoints"
3235

33-
**After the user responds:**
36+
**Based on the user's selection, execute the corresponding command:**
3437

35-
#### If Option A (go run):
36-
Execute this command:
38+
#### Option 1: go run
3739
```bash
3840
go run ./main.go \
3941
-ebpf-agent-image=quay.io/netobserv/netobserv-ebpf-agent:main \
@@ -42,8 +44,7 @@ go run ./main.go \
4244
-namespace=netobserv
4345
```
4446

45-
#### If Option B (delve interactive):
46-
Execute this command:
47+
#### Option 2: delve interactive
4748
```bash
4849
dlv debug ./main.go -- \
4950
-ebpf-agent-image=quay.io/netobserv/netobserv-ebpf-agent:main \
@@ -52,14 +53,15 @@ dlv debug ./main.go -- \
5253
-namespace=netobserv
5354
```
5455

55-
This will start an interactive delve session where you can use commands like:
56+
After starting, inform the user they can use these delve commands:
5657
- `break main.main` - set breakpoint
5758
- `continue` - continue execution
5859
- `next` - step to next line
59-
- `print variable` - inspect variables
60+
- `print <variable>` - inspect variables
61+
62+
#### Option 3: delve headless + VSCode
6063

61-
#### If Option C (delve headless + VSCode):
62-
**Step 1:** Execute this command to start Delve in headless mode:
64+
**Step 1:** Start Delve in headless mode:
6365
```bash
6466
dlv debug ./main.go --headless --listen=:2345 --api-version=2 --accept-multiclient -- \
6567
-ebpf-agent-image=quay.io/netobserv/netobserv-ebpf-agent:main \
@@ -68,42 +70,34 @@ dlv debug ./main.go --headless --listen=:2345 --api-version=2 --accept-multiclie
6870
-namespace=netobserv
6971
```
7072

71-
**Step 2:** Then inform the user:
73+
**Step 2:** Inform the user:
74+
7275
"Delve is now running in headless mode on port 2345. To connect from VSCode:
7376
1. Open the Debug view (Ctrl+Shift+D / Cmd+Shift+D)
74-
2. Select 'Connect to Delve (Remote - Port 2345)' from the dropdown
77+
2. Select 'Connect to Delve (Operator Debug)' from the dropdown
7578
3. Press F5 or click 'Start Debugging'
7679

77-
You can now set breakpoints in VSCode and debug the operator!"
78-
79-
### 4. Setting your first breakpoint - FlowCollector Reconcile
80+
You can now set breakpoints in VSCode and debug the operator."
8081

81-
**Example: Set a breakpoint in the FlowCollector reconciler**
82+
### 4. Example: Debug FlowCollector reconciliation
8283

83-
The FlowCollector reconciliation logic is located in:
84-
`internal/controller/flowcollector/flowcollector_controller.go`
84+
**To help the user get started with debugging:**
8585

86-
**In VSCode:**
87-
1. Open the file `internal/controller/flowcollector/flowcollector_controller.go`
88-
2. Find the `Reconcile` function (around line 100-150)
89-
3. Click on the left margin next to the line number where you want to pause (e.g., the first line inside the Reconcile function)
90-
4. A red dot will appear indicating the breakpoint is set
86+
The main reconciliation logic is in `internal/controller/flowcollector/flowcollector_controller.go` (look for the `Reconcile` function around line 100-150).
9187

92-
**To trigger the reconciliation:**
93-
Execute this command in a terminal to modify the FlowCollector CR:
88+
**If using VSCode debugging:**
89+
1. Open `internal/controller/flowcollector/flowcollector_controller.go`
90+
2. Click the left margin next to the line number inside the `Reconcile` function to set a breakpoint
91+
3. Trigger a reconciliation by running:
9492
```bash
9593
kubectl patch flowcollector cluster --type=merge -p '{"spec":{"processor":{"logLevel":"debug"}}}'
9694
```
9795

98-
This will trigger a reconciliation and the debugger will pause at your breakpoint, allowing you to:
99-
- Inspect the FlowCollector object
100-
- Step through the reconciliation logic
101-
- See how the operator processes changes
102-
- Debug any issues in the reconciliation loop
96+
The debugger will pause at your breakpoint, allowing you to inspect the FlowCollector object and step through the reconciliation logic.
10397

10498
## Cleanup
10599

106-
When you're done debugging:
100+
When finished debugging:
107101

108102
1. Stop the local operator (Ctrl+C in terminal, or stop debugging in VSCode)
109103

@@ -112,4 +106,4 @@ When you're done debugging:
112106
kubectl scale deployment netobserv-controller-manager -n netobserv --replicas=1
113107
```
114108

115-
**Note:** The validating webhook will be automatically recreated by the operator when it starts back up, so you don't need to manually restore it.
109+
**Note:** The validating webhook will be automatically recreated by the operator.

.claude/commands/setup-dev-env.md

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,56 +2,59 @@
22

33
This command sets up a complete development environment for NetObserv.
44

5-
**First, check if the user specified custom images:**
6-
- Did the user provide a **USER** (quay.io username/repo)?
7-
- Did the user provide a **VERSION** (image tag)?
5+
## Gather Configuration
86

9-
If the user specified custom images (e.g., "using the image from my repo, leandroberetta with tag v1.2.3"), extract those values. Otherwise, use the defaults: `USER=netobserv` and `VERSION=main`.
7+
First, use the AskUserQuestion tool to gather the necessary configuration:
108

11-
**Next, determine your platform:**
12-
- Are you using **OpenShift** or **vanilla Kubernetes**?
9+
**Question 1:** What platform are you using?
10+
- Options: OpenShift, Kubernetes
11+
- Header: "Platform"
12+
- Store the answer to determine if `make set-release-kind-downstream` should be run in step 2.
1313

14-
This will determine whether to run `make set-release-kind-downstream` in step 2.
14+
**Question 2:** Are you using custom images?
15+
- Options: "Yes, custom images", "No, use defaults (netobserv/main)"
16+
- Header: "Images"
17+
18+
**If the user selected custom images**, ask follow-up questions to get:
19+
- USER (quay.io username/repo, e.g., "leandroberetta")
20+
- VERSION (image tag, e.g., "v1.2.3" or "main")
21+
22+
Set the variables:
23+
- If using defaults: `USER=netobserv` and `VERSION=main`
24+
- If using custom: `USER=<user_value>` and `VERSION=<version_value>`
1525

1626
## Steps
1727

18-
### 1. Deploy the operator to the cluster
28+
### 1. Deploy the operator
1929

20-
Deploy the operator with the specified or default images:
30+
Run the deployment command with the configured values:
2131

22-
**If custom USER and VERSION were provided:**
32+
**If custom USER and VERSION:**
2333
```bash
2434
USER=<user_value> VERSION=<version_value> make deploy
2535
```
2636

27-
**If using defaults (no custom images specified):**
37+
**If using defaults:**
2838
```bash
2939
USER=netobserv make deploy
3040
```
3141

32-
**Note:**
33-
- Using `USER=netobserv` (default) ensures the operator uses public images from `quay.io/netobserv` without authentication.
34-
- Custom USER values like `USER=leandroberetta` will use images from `quay.io/leandroberetta/`.
35-
- The VERSION parameter controls the image tag (e.g., `VERSION=v1.2.3` or `VERSION=main`).
36-
3742
### 2. Configure for OpenShift (if applicable)
3843

39-
**Only if you're using OpenShift**, run:
44+
**Only run this if the user selected OpenShift** in the platform question:
4045

4146
```bash
4247
make set-release-kind-downstream
4348
```
4449

45-
**If you're using vanilla Kubernetes**, skip this step entirely.
50+
Skip this step for Kubernetes.
4651

4752
### 3. Deploy Loki
4853

4954
```bash
5055
make deploy-loki
5156
```
5257

53-
This will deploy Loki and make it available at http://localhost:3100
54-
5558
### 4. Deploy sample FlowCollector CR
5659

5760
```bash
@@ -60,7 +63,7 @@ make deploy-sample-cr
6063

6164
### 5. Verify deployment
6265

63-
Check that all components are running:
66+
Run these commands to verify all components are running:
6467

6568
```bash
6669
kubectl get pods -n netobserv
@@ -69,8 +72,8 @@ kubectl get flowcollector cluster -o yaml
6972

7073
## Cleanup
7174

72-
To clean up the entire environment:
75+
To remove the entire environment:
7376

7477
```bash
7578
make undeploy
76-
```
79+
```

0 commit comments

Comments
 (0)