'Debugging NodeJs app running inside pod on Kind (Kubernetes in docker) cluster

I am running a kubernetes cluster with Kind configured as shown bellow:

kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
  - role: control-plane
    kubeadmConfigPatches:
      - |
        kind: InitConfiguration
        nodeRegistration:
          kubeletExtraArgs:
            node-labels: "ingress-ready=true"
    extraPortMappings:
      - containerPort: 80
        hostPort: ${ingress_http_port}
        protocol: TCP
      - containerPort: 443
        hostPort: ${ingress_https_port}
        protocol: TCP
networking:
  kubeProxyMode: "ipvs"

The cluster is running inside the kind-control-plane docker container:

CONTAINER ID   IMAGE                  COMMAND                  CREATED        STATUS       PORTS                                                                 NAMES
53d9511b8282   kindest/node:v1.21.1   "/usr/local/bin/entr…"   5 hours ago    Up 5 hours   0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp, 127.0.0.1:41393->6443/tcp   kind-control-plane

I have also successfully deployed a deployment running a nodeJs application inside a pod and i have already exposed a service to access the app through an ingress controller and everything works as expected:

apiVersion: v1
kind: Service
metadata:
  name: application-deployment
spec:
  ports:
    - name: http
      port: 3000
      protocol: TCP
  selector:
    app: application-deployment
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: application-deployment
spec:
  rules:
    - http:
        paths:
          - path: "/"
            pathType: Prefix
            backend:
              service:
                name: application-deployment
                port:
                  number: 3000

I am using the WebStorm IDE to develop the application running inside the pod and i am trying to configure a remote debugger to connect to the application inside the Kind cluster. I know how to configure a debugger running inside a docker container but i dont know how to run a debugger inside a kubernetes pod running in a docker container.

I have already tried to configure it through WebStrom with the settings bellow:

enter image description here

And these are the settings under the Docker container settings label:

enter image description here

Any suggestions or workarounds in order to accomplish this would be more than appreciated.

Thank you in advance!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source