Skip to content

Commit 6557fc5

Browse files
committed
Add documentation on setting up live debugging
Adds a short doc on how to set up breakpoints with VSCode through Tilt. Also expands on the existing podman local environment document with instructions that apply to both Linux and MacOS installations. Signed-off-by: Tayler Geiger <[email protected]>
1 parent a46ff7d commit 6557fc5

File tree

2 files changed

+108
-18
lines changed

2 files changed

+108
-18
lines changed
Lines changed: 48 additions & 0 deletions
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.
Lines changed: 60 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,96 @@
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+
## Verify installed tools (install if needed)
4+
5+
Ensure you have installed [Podman](https://podman.io/), [Kind](https://github.com/kubernetes-sigs/kind/), and [Tilt](https://tilt.dev/).
46

57
```sh
68
$ podman --version
79
podman version 5.0.1
810
$ kind version
911
kind v0.23.0 go1.22.3 darwin/arm64
10-
11-
(optional)
1212
$ tilt version
1313
v0.33.12, built 2024-03-28
1414
```
1515

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

19-
#### Disable secure access on the local kind registry:
2020

21-
`podman inspect kind-registry --format '{{.NetworkSettings.Ports}}'`
21+
## Disable secure access on the local kind registry:
2222

23-
With the port you find for 127.0.0.1 edit the Podman machine's config file:
23+
Verify the port used by the image registry:
2424

25-
`podman machine ssh`
25+
```sh
26+
podman inspect kind-registry --format '{{.NetworkSettings.Ports}}'
27+
```
2628

27-
`sudo vi /etc/containers/registries.conf.d/100-kind.conf`
29+
If your host is a Mac, first run:
30+
`podman machine ssh`
2831

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

3134
```ini
3235
[[registry]]
3336
location = "localhost:5001"
3437
insecure = true
3538
```
3639

37-
### export DOCKER_HOST
40+
## Configure the Podman socket
3841

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

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

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

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

46-
### Optional troubleshooting
66+
Set `DOCKER_HOST` to a unix address at the socket location:
4767

48-
In some cases it may be needed to do
68+
```sh
69+
export DOCKER_HOST=unix:///run/user/1000/podman/podman.sock
4970
```
50-
sudo podman-mac-helper install
71+
72+
Some systems might symlink the Podman socket to a docker socket, in which case
73+
you might need to try something like:
74+
75+
```sh
76+
export DOCKER_HOST=unix:///var/run/docker.sock
5177
```
78+
79+
## Start Tilt
80+
81+
Running Tilt with a container engine other than Docker requires setting `DOCKER_BUILDKIT=0`.
82+
You can export this, or just run:
83+
84+
```sh
85+
DOCKER_BUILDKIT=0 tilt up
5286
```
87+
88+
## MacOS Troubleshooting
89+
90+
In some cases you might need to run:
91+
92+
```sh
93+
sudo podman-mac-helper install
94+
5395
podman machine stop/start
5496
```

0 commit comments

Comments
 (0)