It's much easier to debug code with breakpoints while developing new features or making changes to existing codebase. With this in mind, following steps provides a way to setup secrets store csi driver for local debugging.
NOTE: Steps in this guide are not tested by CI/CD. This is just one of the way to locally debug the code and a good starting point.
- Replace
hostPath
value in kind-config.yaml to match with your local csi driver source code path
# YAML
- hostPath: # /path/to/your/driver/secrets-store-csi-driver/codebase/on/host
- Create Kind cluster:
kind create cluster --config .local/kind-config.yaml
- Build docker image from Dockerfile:
docker build -t debug-driver -f .local/Dockerfile .
- Load image
debug-driver:latest
on kind cluster:
kind load docker-image debug-driver:latest
- Deploy following Driver resources:
kubectl apply -f deploy/rbac-secretproviderclass.yaml
kubectl apply -f deploy/csidriver.yaml
kubectl apply -f deploy/secrets-store.csi.x-k8s.io_secretproviderclasses.yaml
kubectl apply -f deploy/secrets-store.csi.x-k8s.io_secretproviderclasspodstatuses.yaml
kubectl apply -f deploy/rbac-secretprovidersyncing.yaml
kubectl apply -f deploy/rbac-secretproviderrotation.yaml
-
Deploy provider.
-
Deploy pv and pvc to mount codebase into the cluster:
kubectl apply -f .local/persistent-volume.yaml
- Deploy driver:
kubectl apply -f .local/debug-driver.yaml
- Check the logs of debug-driver pod to make sure
dlv
API server is listening:
API server listening at: [::]:30123
Use following launch.json
configuration to attach debugger.
{
"version": "0.2.0",
"configurations": [
{
"name": "Driver debug",
"type": "go",
"request": "attach",
"mode":"remote",
"remotePath": "/secrets-store-csi-driver-codebase",
"port": 30123,
"host": "127.0.0.1",
"showLog": true
}
]
}
Happy Debugging..
kind delete cluster