Skip to content

Latest commit

 

History

History
36 lines (23 loc) · 945 Bytes

debugging-nodejs-inside-k8s.md

File metadata and controls

36 lines (23 loc) · 945 Bytes

Debugging NodeJS inside K8s

  1. Find the pod you want to debug
kubectl get pods | grep my-awesome-api 
  1. Give a look at the process PIDs inside this pod

Obs: You have to get the PID from the NodeJS process, it is usually the one with a command started as 'node'.

kubectl exec -it my-awesome-api  -- /bin/sh -c "ps aux"
  1. Enable devtool in the application

Obs: You have to use the correct PID in the final of the command '...-USR1 $PID'.

kubectl exec -it my-awesome-api -- /bin/sh -c "kill -USR1 18"
  1. Forward debug port to your computer
kubectl port-forward my-awesome-api 9229:9229

Now you just have to open your browser and click on the debug icon on devtools page.

Bibliographic References:

https://medium.com/@amirilovic/how-to-debug-node-js-applications-in-kubernetes-c169f1e88c37