Skip to content

Commit 7f00b13

Browse files
authored
Add documentation on setting up live debugging (#1653)
Adds a short doc on how to set up breakpoints with VSCode through Tilt. Also expands on the existing podman local environment document. Signed-off-by: Tayler Geiger <[email protected]>
1 parent f7ff6bd commit 7f00b13

File tree

2 files changed

+118
-21
lines changed

2 files changed

+118
-21
lines changed

Diff for: dev/local-debugging-with-tilt-and-vscode.md

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Local Debugging in VSCode with Tilt
2+
3+
This tutorial will show you how to connect the go debugger in VSCode to your running
4+
kind cluster with Tilt for live debugging.
5+
6+
* Follow the instructions in [this document](podman/setup-local-env-podman.md) to set up your local kind cluster and image registry.
7+
* Next, execute `tilt up` to start the Tilt service (if using podman, you might need to run `DOCKER_BUILDKIT=0 tilt up`).
8+
9+
Press space to open the web UI where you can monitor the current status of operator-controller and catalogd inside Tilt.
10+
11+
Create a `launch.json` file in your operator-controller repository if you do not already have one.
12+
Add the following configurations:
13+
14+
```json
15+
{
16+
"version": "0.2.0",
17+
"configurations": [
18+
{
19+
"name": "Debug operator-controller via Tilt",
20+
"type": "go",
21+
"request": "attach",
22+
"mode": "remote",
23+
"port": 30000,
24+
"host": "localhost",
25+
"cwd": "${workspaceFolder}",
26+
"trace": "verbose"
27+
},
28+
{
29+
"name": "Debug catalogd via Tilt",
30+
"type": "go",
31+
"request": "attach",
32+
"mode": "remote",
33+
"port": 20000,
34+
"host": "localhost",
35+
"cwd": "${workspaceFolder}",
36+
"trace": "verbose"
37+
},
38+
]
39+
}
40+
```
41+
42+
This creates two "Run and debug" entries in the Debug panel of VSCode.
43+
44+
Now you can start either debug configuration depending on which component you want to debug.
45+
VSCode will connect the debugger to the port exposed by Tilt.
46+
47+
Breakpoints should now be fully functional. The debugger can even maintain its
48+
connection through live code updates.

Diff for: dev/podman/setup-local-env-podman.md

+70-21
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,103 @@
1-
## The following are Podman specific steps used to set up on a MacBook (Intel or Apple Silicon)
1+
# Configuring Podman for Tilt
22

3-
### Verify installed tools (install if needed)
3+
The following tutorial explains how to set up a local development environment using Podman and Tilt on a Linux host.
4+
A few notes on achieving the same result for MacOS are included at the end, but you will likely need to do some
5+
tinkering on your own.
6+
7+
## Verify installed tools (install if needed)
8+
9+
Ensure you have installed [Podman](https://podman.io/), [Kind](https://github.com/kubernetes-sigs/kind/), and [Tilt](https://tilt.dev/).
410

511
```sh
612
$ podman --version
713
podman version 5.0.1
814
$ kind version
9-
kind v0.23.0 go1.22.3 darwin/arm64
10-
11-
(optional)
15+
kind v0.26.0 go1.23.4 linux/amd64
1216
$ tilt version
13-
v0.33.12, built 2024-03-28
17+
v0.33.15, built 2024-05-31
1418
```
1519

16-
### Start Kind with a local registry
17-
Use this [helper script](./kind-with-registry-podman.sh) to create a local single-node Kind cluster with an attached local image registry.
20+
## Start Kind with a local registry
1821

19-
#### Disable secure access on the local kind registry:
22+
Use this [helper script](./kind-with-registry-podman.sh) to create a local single-node Kind cluster with an attached local image registry.
2023

21-
`podman inspect kind-registry --format '{{.NetworkSettings.Ports}}'`
2224

23-
With the port you find for 127.0.0.1 edit the Podman machine's config file:
25+
## Disable secure access on the local kind registry:
2426

25-
`podman machine ssh`
27+
Verify the port used by the image registry:
2628

27-
`sudo vi /etc/containers/registries.conf.d/100-kind.conf`
29+
```sh
30+
podman inspect kind-registry --format '{{.NetworkSettings.Ports}}'
31+
```
2832

29-
Should look like:
33+
Edit `/etc/containers/registries.conf.d/100-kind.conf` so it contains the following, substituting 5001 if your registry is using a different port:
3034

3135
```ini
3236
[[registry]]
3337
location = "localhost:5001"
3438
insecure = true
3539
```
3640

37-
### export DOCKER_HOST
41+
## Configure the Podman socket
3842

39-
`export DOCKER_HOST=unix:///var/run/docker.sock`
43+
Tilt needs to connect to the Podman socket to initiate image builds. The socket address can differ
44+
depending on your host OS and whether you want to use rootful or rootless Podman. If you're not sure,
45+
you should use rootless.
4046

47+
You can start the rootless Podman socket by running `podman --user start podman.socket`.
48+
If you would like to automatically start the socket in your user session, you can run
49+
`systemctl --user enable --now podman.socket`.
4150

42-
### Optional - Start tilt with the tilt file in the parent directory
51+
Find the location of your user socket with `systemctl --user status podman.socket`:
4352

44-
`DOCKER_BUILDKIT=0 tilt up`
53+
```sh
54+
● podman.socket - Podman API Socket
55+
Loaded: loaded (/usr/lib/systemd/user/podman.socket; enabled; preset: disabled)
56+
Active: active (listening) since Tue 2025-01-28 11:40:50 CST; 7s ago
57+
Invocation: d9604e587f2a4581bc79cbe4efe9c7e7
58+
Triggers: ● podman.service
59+
Docs: man:podman-system-service(1)
60+
Listen: /run/user/1000/podman/podman.sock (Stream)
61+
CGroup: /user.slice/user-1000.slice/[email protected]/app.slice/podman.socket
62+
```
4563

46-
### Optional troubleshooting
64+
The location of the socket is shown in the `Listen` section, which in the example above
65+
is `/run/user/1000/podman/podman.sock`.
4766

48-
In some cases it may be needed to do
67+
Set `DOCKER_HOST` to a unix address at the socket location:
68+
69+
```sh
70+
export DOCKER_HOST=unix:///run/user/1000/podman/podman.sock
4971
```
50-
sudo podman-mac-helper install
72+
73+
Some systems might symlink the Podman socket to a docker socket, in which case
74+
you might need to try something like:
75+
76+
```sh
77+
export DOCKER_HOST=unix:///var/run/docker.sock
5178
```
79+
80+
## Start Tilt
81+
82+
Running Tilt with a container engine other than Docker requires setting `DOCKER_BUILDKIT=0`.
83+
You can export this, or just run:
84+
85+
```sh
86+
DOCKER_BUILDKIT=0 tilt up
5287
```
88+
89+
## MacOS Troubleshooting
90+
91+
The instructions above are written for use on a Linux system. You should be able to create
92+
the same or a similar configuration on MacOS, but specific steps will differ.
93+
94+
In some cases you might need to run:
95+
96+
```sh
97+
sudo podman-mac-helper install
98+
5399
podman machine stop/start
54100
```
101+
102+
When disabling secure access to the registry, you will need to first enter the Podman virtual machine:
103+
`podman machine ssh`

0 commit comments

Comments
 (0)