Is there a way to setup a debug a go application on kubernetes with skaffold and vscode?

191 Views Asked by At

My app is written in go and is packaged in a helm chart which is deployed on the k3s cluster.

I am able to use skaffold to deploy to the k3s cluster. I am also able to deploy to the cluster using Google Cloud Code VS Code Extension. However, if I set a break point in my main.go, the debugger never hands me control and simply continues execution. Below is my launch.json

{
    "configurations": [
        {
            "name": "Kubernetes: Run/Debug",
            "type": "cloudcode.kubernetes",
            "request": "launch",
            "skaffoldConfig": "${workspaceFolder}/skaffold.yaml",
            "watch": true,
            "cleanUp": true,
            "portForward": true,
            "imageRegistry": "docker_image_registry"
        },
        {
            "name": "Attach to Kubernetes Pod (Go)",
            "type": "cloudcode.kubernetes",
            "request": "attach",
            "language": "Go",
            "debugPort": 2345,
            "podSelector": {
                "app": "collector"
            },
            "localRoot": "${workspaceFolder}",
            "remoteRoot": "/opt/remote_root"
        }
    ]
}

The first configuration works well. Please can someone help me get the Attach to Kubernetes Pod (Go) configuration to work.

0

There are 0 best solutions below