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
To debug Burrito efficiently in Kubernetes, you can use [Delve](https://github.com/go-delve/delve), optionally with [Visual Studio Code](https://code.visualstudio.com/) (recommended). We have set a few things to help you getting started.
195
+
196
+
You'll need to follow instructions in [Getting Started: Set Up a Local Development Environment (kind)](#getting-started-set-up-a-local-development-environment-kind) to get a local Kubernetes development instance.
197
+
198
+
### Enable debugging
199
+
200
+
First, being by installing dlv: `go install github.com/go-delve/delve/cmd/dlv@latest`
201
+
202
+
We'll rely on `deploy/charts/burrito/values-debug.yaml` to deploy the configuration to start the debugging session.
203
+
204
+
By default, the `controller` (that includes the runner) and `datastore` are commented in the Helm values. Indeed, starting the application with dlv server will hang until you connect with the dlv client so it has to be enabled only when you need it.
By default, we'll start the application with the usual command. If you want to debug the controller or the runner, uncomment the required block. This will open a port on the pod on which you'll connect from your computer.
227
+
228
+
`mode: Debug` is removing liveness and readiness probes: they won't be able to start as dlv will await for you to start the debugging session.
229
+
230
+
### Deploy/refresh commands
231
+
232
+
You'll need to deploy the debug container images and config. This is the same commandif you need to refresh your deployment.
233
+
234
+
To build a new local debug image of Burrito, push it into your local Kind cluster, and update the Helm release with the new image tag, run the following:
235
+
236
+
```bash
237
+
make upgrade-debug-kind
238
+
```
239
+
240
+
To refresh the Helm chart with debug values, run:
241
+
242
+
```bash
243
+
make upgrade-debug-helm
244
+
```
245
+
246
+
Check the [Makefile](https://github.com/padok-team/burrito/blob/main/Makefile) for more details about these commands.
247
+
248
+
### Connect from your computer to the debug session
249
+
250
+
The debugging port won't be exposed by default so you'll need to port-forward it.
It will listen on the same port than the controller so we're exposing it on port 2346 on your computer so you can debug the controller and the runner if needed.
You can get more information about Vscode+Go debugging [here](https://github.com/golang/vscode-go/blob/master/docs/debugging.md)
284
+
285
+
If you want to use Vscode to debug the app, you'll need to get the [Go extension](https://marketplace.visualstudio.com/items?itemName=golang.go) and create a `.vscode/launch.json`:
286
+
287
+
```json
288
+
{
289
+
"version": "0.2.0",
290
+
"configurations": [
291
+
{
292
+
"name": "Attach to Controller",
293
+
"type": "go",
294
+
"request": "attach",
295
+
"mode": "remote",
296
+
"port": 2345,
297
+
"host": "127.0.0.1",
298
+
"apiVersion": 2
299
+
},
300
+
{
301
+
"name": "Attach to Runner",
302
+
"type": "go",
303
+
"request": "attach",
304
+
"mode": "remote",
305
+
"port": 2346,
306
+
"host": "127.0.0.1",
307
+
"apiVersion": 2
308
+
},
309
+
{
310
+
"name": "Attach to Datastore",
311
+
"type": "go",
312
+
"request": "attach",
313
+
"mode": "remote",
314
+
"port": 2347,
315
+
"host": "127.0.0.1",
316
+
"apiVersion": 2
317
+
},
318
+
{
319
+
"name": "Attach to Server",
320
+
"type": "go",
321
+
"request": "attach",
322
+
"mode": "remote",
323
+
"port": 2348,
324
+
"host": "127.0.0.1",
325
+
"apiVersion": 2
326
+
}
327
+
]
328
+
}
329
+
```
330
+
331
+
!!! question "New to debugging on Vscode?"
332
+
For a vscode debug introduction, you can check [Debug code with Visual Studio Code](https://code.visualstudio.com/docs/debugtest/debugging).
333
+
334
+
Browse your code to set breakpoints by clicking on the left side of your line.
If you prefer to debug on cli, you can connect with `dlv connect 127.0.0.1:<debuggingPort>` where `<debuggingPort>` is 2345, 2346, 2347 or 2348, depending on what you're debugging.
0 commit comments