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
@@ -115,6 +119,10 @@ You must install these tools:
115
119
request. To ensure your work does not contain offensive language, you may
116
120
want to install and run this tool locally.
117
121
122
+
1. (Optional)
123
+
[`delve`](https://github.com/go-delve/delve/tree/master/Documentation/installation) is needed if you want to setup
124
+
a debugging of the Tekton controller in VSCode or your IDE of choice.
125
+
118
126
### Configure environment
119
127
120
128
To [build, deploy and run your Tekton Objects with `ko`](#install-pipeline), you'll need to set these environment variables:
@@ -464,7 +472,6 @@ This script will cause `ko` to:
464
472
465
473
It will also update the default system namespace used for K8s `deployments` to the new value for all subsequent `kubectl` commands.
466
474
467
-
468
475
---
469
476
470
477
### Accessing logs
@@ -505,3 +512,94 @@ If you need to add a new CRD type, you will need to add:
505
512
[list of known types](./pkg/apis/pipeline/v1alpha1/register.go)
506
513
507
514
_See [the API compatibility policy](api_compatibility_policy.md)._
515
+
516
+
## Debugging
517
+
518
+
`ko` has build in support for the `delve` debugger. To use it you need to build your controller image with the `--debug` and `--disable-optimizations` flag.
519
+
520
+
### Change Controller
521
+
522
+
If you want to debug your controller you first need to update its deployment configuration and comment the probes. If you don't do that the short probe timeouts will crash the pod:
523
+
524
+
```yaml
525
+
# config/controller.yaml
526
+
527
+
# livenessProbe:
528
+
# httpGet:
529
+
# path: /health
530
+
# port: probes
531
+
# scheme: HTTP
532
+
# initialDelaySeconds: 5
533
+
# periodSeconds: 10
534
+
# timeoutSeconds: 5
535
+
# readinessProbe:
536
+
# httpGet:
537
+
# path: /readiness
538
+
# port: probes
539
+
# scheme: HTTP
540
+
# initialDelaySeconds: 5
541
+
# periodSeconds: 10
542
+
# timeoutSeconds: 5
543
+
```
544
+
545
+
Then you need to rebuild the the controller in debug mode:
546
+
547
+
```sh
548
+
ko apply -f config/controller.yaml --debug --disable-optimizations
549
+
```
550
+
551
+
### Forward Debugging Port
552
+
553
+
Now the controller will be re-started with `delve`in headless mode and you can attach a client to it on port `40000` but first you need to forward the port from the controller pod:
In VSCode add the following `launch.json` configuration for go remote debugging:
562
+
563
+
```json
564
+
{
565
+
"version": "0.2.0",
566
+
"configurations": [
567
+
{
568
+
"name": "Attach to Delve (Tekton Controller)",
569
+
"type": "go",
570
+
"request": "attach",
571
+
"mode": "remote",
572
+
"port": 40000,
573
+
"host": "127.0.0.1",
574
+
"apiVersion": 2,
575
+
"substitutePath": [
576
+
{
577
+
"from": "${workspaceFolder}",
578
+
"to": "github.com/tektoncd/pipeline"
579
+
}
580
+
]
581
+
}
582
+
]
583
+
}
584
+
```
585
+
586
+
Now you ar able to attach to `delve`in VSCode. Set breakpoints e.g. in`pipelinerun.go`in the `reconcile` method and execute a `PipelineRun` and VSCode should stop at the breakpoint. You can use this sample `PipelineRun`for testing:
0 commit comments