Debugging in Kubernetes Olaf Meyer Senior Consultant 05.02.2020
Debugging in Kubernetes Page 2 of 28 Who am I and what do I do for living? Former: – Web-Developer with Lotus Domino – Java-Backend-Developer – Requirements-Engineer Currently: – Playing around with OpenShift and Kubernetes and help customer use it as best as possible E-Mail: olaf.meyer@consol.de Twitter: ola_mey
Debugging in Kubernetes Page 3 of 28 Agenda • Introduction to Kubernetes • Debugging with the command line tool • Debugging with Telepresence • Debugging with Squash • Summary
Debugging in Kubernetes Page 4 of 28 Introduction to Kubernetes Kubernetes → Greek for "governor", "helmsman" or "captain" Definition from github project page: Kubernetes is an open source system for managing containerized applications across multiple hosts. It provides basic mechanisms for deployment, maintenance, and scaling of applications.
Debugging in Kubernetes Page 5 of 28 Introduction to Kubernetes Image source: https://medium.com/containermind/a- beginners-guide-to-kubernetes-7e8ca56420b6
Debugging in Kubernetes Page 6 of 28 Introduction to Kubernetes Image source: https://medium.com/containermind/a- beginners-guide-to-kubernetes-7e8ca56420b6
Debugging in Kubernetes Page 7 of 28 Example application Shopfront ProductCatalogue StockManager Starting Java application in debug mode with following parameter „-agentlib:jdwp=transport=dt_socket,server=y,address=8000,suspend=n“
Debugging in Kubernetes Page 8 of 28 Debugging with kubectl • kubectl port-forward <pod-name> <port>… • Forwards port from port of pod to local computer • Works similar to ssh tunnel.
Debugging in Kubernetes Page 9 of 28 Debugging with kubectl Remote Pod Port 4000 Open Ports: 8080 HTTP 4000 Java-Debug-Port Forwarded port 4000Yourapplication.acme.com:8080 Localhost:4000
Debugging in Kubernetes Page 10 of 28 Debugging with kubectl Demo
Debugging in Kubernetes Page 11 of 28 Debugging with Telepresence • Open source application from Datawire • Made to increase productivity for developing k8s containers • Can be used to debug pod/containers as well • Website: https://www.telepresence.io/ • Slack channel: https://datawire-oss.slack.com
Debugging in Kubernetes Page 12 of 28 Debugging with Telepresence How is works (quote from documentation): Telepresence deploys a two-way network proxy in a pod running in your Kubernetes cluster. This pod proxies data from your Kubernetes environment (e.g., TCP connections, environment variables, volumes) to the local process. The local process has its networking transparently overridden so that DNS calls and TCP connections are routed over the proxy to the remote Kubernetes cluster
Debugging in Kubernetes Page 13 of 28 Debugging with Telepresence Your Laptop Shopfront ProductCatalogue StockManager
Debugging in Kubernetes Page 14 of 28 Debugging with Telepresence Laptop Source code for service Local process Telepresence client Kubernetes K8s.Pod: Telepresence proxy K8s.Service: Backend1 K8s.Service: Backend2K8s.Service: Backend1 RDBMS K8s.Service: Service name
Debugging in Kubernetes Page 15 of 28 Debugging with Telepresence Demo
Debugging in Kubernetes Page 16 of 28 Debugging with Squash • Open source application from Solo.io • Aim is to debug containers, pods, services or images • Well integrated in IDE‘s • Debug multiple pods • Website: https://squash.solo.io/ • Slack channel: http://slack.solo.io/
Debugging in Kubernetes Page 18 of 28 Debugging with Squash Demo
Debugging in Kubernetes Page 19 of 28 Summary • For pure debugging purposes I like Squash best • Nice integration in IDE – Intellij – Eclipse – VS Code • No overhead for Java application
Debugging in Kubernetes Page 20 of 28 Summary • For development of containers Telepresence does an excellent job. • Easy to use CLI, if you are working with Linux • Would use it on minikube • On prod clusters … I‘m not so sure
Debugging in Kubernetes Page 21 of 28 Summary • If no other ways are available you can always use port-forward • Just works … but nothing fancy
Debugging in Kubernetes Page 22 of 28 What could be a problem (?!) • Might need higher privileges in k8s to use Telepresence and Squash! • Telepresence works for Debugging of normal “deployments“ – For other kinds of pods you need to find a work around: ● StatefulSets ● CronJobs and Jobs ● DaemonSets ● Operators
Debugging in Kubernetes Page 23 of 28 Bonus „debugger“ kubefwd • Aim: Kubernetes port forwarding for local development • Website: https://github.com/txn2/kubefwd
Debugging in Kubernetes Page 24 of 28 Bonus application kubefwd
Debugging in Kubernetes Page 25 of 28 Debugging with kubefwd Demo
Debugging in Kubernetes Page 26 of 28 Bonus debugger Rookout • Providing virtual logging and passive debugging SaaS solution • On prem solution available • Add i.e. java-agent to code to send status info • Support Python, Java, Node.Js more to come • Website: https://www.rookout.com/
Debugging in Kubernetes Page 27 of 28 Bonus debugger Rookout
Thank you!
ConSol Consulting & Solutions Software GmbH Franziskanerstr. 38 D-81669 München Tel.: +49-89-45841-100 info@consol.de www.consol.de Twitter: @consol_de

Remote debugging of Application in Kubernetes

  • 1.
    Debugging in Kubernetes OlafMeyer Senior Consultant 05.02.2020
  • 2.
    Debugging in KubernetesPage 2 of 28 Who am I and what do I do for living? Former: – Web-Developer with Lotus Domino – Java-Backend-Developer – Requirements-Engineer Currently: – Playing around with OpenShift and Kubernetes and help customer use it as best as possible E-Mail: olaf.meyer@consol.de Twitter: ola_mey
  • 3.
    Debugging in KubernetesPage 3 of 28 Agenda • Introduction to Kubernetes • Debugging with the command line tool • Debugging with Telepresence • Debugging with Squash • Summary
  • 4.
    Debugging in KubernetesPage 4 of 28 Introduction to Kubernetes Kubernetes → Greek for "governor", "helmsman" or "captain" Definition from github project page: Kubernetes is an open source system for managing containerized applications across multiple hosts. It provides basic mechanisms for deployment, maintenance, and scaling of applications.
  • 5.
    Debugging in KubernetesPage 5 of 28 Introduction to Kubernetes Image source: https://medium.com/containermind/a- beginners-guide-to-kubernetes-7e8ca56420b6
  • 6.
    Debugging in KubernetesPage 6 of 28 Introduction to Kubernetes Image source: https://medium.com/containermind/a- beginners-guide-to-kubernetes-7e8ca56420b6
  • 7.
    Debugging in KubernetesPage 7 of 28 Example application Shopfront ProductCatalogue StockManager Starting Java application in debug mode with following parameter „-agentlib:jdwp=transport=dt_socket,server=y,address=8000,suspend=n“
  • 8.
    Debugging in KubernetesPage 8 of 28 Debugging with kubectl • kubectl port-forward <pod-name> <port>… • Forwards port from port of pod to local computer • Works similar to ssh tunnel.
  • 9.
    Debugging in KubernetesPage 9 of 28 Debugging with kubectl Remote Pod Port 4000 Open Ports: 8080 HTTP 4000 Java-Debug-Port Forwarded port 4000Yourapplication.acme.com:8080 Localhost:4000
  • 10.
    Debugging in KubernetesPage 10 of 28 Debugging with kubectl Demo
  • 11.
    Debugging in KubernetesPage 11 of 28 Debugging with Telepresence • Open source application from Datawire • Made to increase productivity for developing k8s containers • Can be used to debug pod/containers as well • Website: https://www.telepresence.io/ • Slack channel: https://datawire-oss.slack.com
  • 12.
    Debugging in KubernetesPage 12 of 28 Debugging with Telepresence How is works (quote from documentation): Telepresence deploys a two-way network proxy in a pod running in your Kubernetes cluster. This pod proxies data from your Kubernetes environment (e.g., TCP connections, environment variables, volumes) to the local process. The local process has its networking transparently overridden so that DNS calls and TCP connections are routed over the proxy to the remote Kubernetes cluster
  • 13.
    Debugging in KubernetesPage 13 of 28 Debugging with Telepresence Your Laptop Shopfront ProductCatalogue StockManager
  • 14.
    Debugging in KubernetesPage 14 of 28 Debugging with Telepresence Laptop Source code for service Local process Telepresence client Kubernetes K8s.Pod: Telepresence proxy K8s.Service: Backend1 K8s.Service: Backend2K8s.Service: Backend1 RDBMS K8s.Service: Service name
  • 15.
    Debugging in KubernetesPage 15 of 28 Debugging with Telepresence Demo
  • 16.
    Debugging in KubernetesPage 16 of 28 Debugging with Squash • Open source application from Solo.io • Aim is to debug containers, pods, services or images • Well integrated in IDE‘s • Debug multiple pods • Website: https://squash.solo.io/ • Slack channel: http://slack.solo.io/
  • 17.
    Debugging in KubernetesPage 18 of 28 Debugging with Squash Demo
  • 18.
    Debugging in KubernetesPage 19 of 28 Summary • For pure debugging purposes I like Squash best • Nice integration in IDE – Intellij – Eclipse – VS Code • No overhead for Java application
  • 19.
    Debugging in KubernetesPage 20 of 28 Summary • For development of containers Telepresence does an excellent job. • Easy to use CLI, if you are working with Linux • Would use it on minikube • On prod clusters … I‘m not so sure
  • 20.
    Debugging in KubernetesPage 21 of 28 Summary • If no other ways are available you can always use port-forward • Just works … but nothing fancy
  • 21.
    Debugging in KubernetesPage 22 of 28 What could be a problem (?!) • Might need higher privileges in k8s to use Telepresence and Squash! • Telepresence works for Debugging of normal “deployments“ – For other kinds of pods you need to find a work around: ● StatefulSets ● CronJobs and Jobs ● DaemonSets ● Operators
  • 22.
    Debugging in KubernetesPage 23 of 28 Bonus „debugger“ kubefwd • Aim: Kubernetes port forwarding for local development • Website: https://github.com/txn2/kubefwd
  • 23.
    Debugging in KubernetesPage 24 of 28 Bonus application kubefwd
  • 24.
    Debugging in KubernetesPage 25 of 28 Debugging with kubefwd Demo
  • 25.
    Debugging in KubernetesPage 26 of 28 Bonus debugger Rookout • Providing virtual logging and passive debugging SaaS solution • On prem solution available • Add i.e. java-agent to code to send status info • Support Python, Java, Node.Js more to come • Website: https://www.rookout.com/
  • 26.
    Debugging in KubernetesPage 27 of 28 Bonus debugger Rookout
  • 27.
  • 28.
    ConSol Consulting & SolutionsSoftware GmbH Franziskanerstr. 38 D-81669 München Tel.: +49-89-45841-100 info@consol.de www.consol.de Twitter: @consol_de