SlideShare a Scribd company logo
Debugging
Go on Kubernetes
GopherCon 2019, Israel
@alexeiled
Intro
Alexei Ledenev
@alexeiled
alexei-led/pumba
Quick Survey
1. Who is using Docker today?

2. Who is using Kubernetes?
Debugging Go in Kubernetes
What is Kubernetes?
Kubernetes Objects
wordpress
service
210.14.128.31
Debugging Go in Kubernetes
Core Kubernetes
Debugging Go
🤔
👍
🚫
Debugging Go in Kubernetes
K8s Development Flow
K8s Debug Models
100% local 100% remote
Realism Low High
Feedback Fast Slow
Resource Footprint Heavy Lightweight
100% Remote
Build image:x.x.x-debug
Go App Static Binary
(built with `go build --gcflag "-N -l" ...`)
Delve Binary (COPY --from builder OR go get)
EXPOSE 2345 (debugger port)
Base Image (alpine/scratch OR golang)
CMD ["dlv", "exec", "--headless", "--api-version=2",
"--listen=:2345", "--log", "./todo-app"]
Deploy image:x.x.x-debug
• Patch/Re-deploy K8s Deployment: image, SYS_PTRACE

• Expose Delve server port (kubectl port-forward)

• Rollback after debug session
Every
Commit
# build Docker image with delve debugger
docker build -t alexeiled/todo-app-web:debug -f debug/Dockerfile .
# push Docker image to registry
docker push alexeiled/todo-app-web:debug
# patch Kubernetes deployment and service
kubectl patch deploy todo-app --type="json" -ntodo-app 
--patch "$(/bin/cat dbg/patch-debug.json)"
# forward debugger port to the local machine
kubectl port-forward pod/app-pod 2345
# DEBUG SESSION .......
# rollback the patch
kubectl patch deploy todo-app --type="merge" 
--patch "$(/bin/cat k8s-deployment/todo-app-deployment.yaml)" -ntodo-app
Local + Remote
Telepresence (Datawire 👍)
Debug
Locally
Instant
Feedback
Realistic
Environment
Minimal
Resource
Footprint
Use your
own tools
reverse tunnel (sshd) over a
kubectl port-forward
Telepresence Demo
# open VS Code editor
code .
# [code.terminal.#1]: swap todo-app deployment with bash
telepresence --namespace=todo-app --swap-deployment=todo-app 
--expose 3000 --run bash
# [code.terminal.#1] run debugger (with .debug/runDelve.sh)
dlv debug --listen=localhost:2345 
--headless=true --api-version=2 --log=true ./ 
-- -config-file="$TELEPRESENCE_ROOT/etc/todo-app/redis.config"
# [code.terminal.#2] invoke todo-app service in K8s cluster
http http://a8d6ad3e6169111e98c1d02b9ca3b647-624533560.us-
west-2.elb.amazonaws.com:9080/read/todo
# DEBUG SESSION ....... stop debug (dlv); exit (swap back)
Debug Go in K8s
https://telepresence.io
TODO: check this too
@alexeiled

More Related Content

Similar to Debugging Go in Kubernetes (6)

PDF
Google ko: fast Kubernetes microservice development in Go - Sangam Biradar, E...
sangam biradar
 
PDF
Remote debugging of Application in Kubernetes
ConSol Consulting & Solutions Software GmbH
 
PDF
Build Your Own CaaS (Container as a Service)
HungWei Chiu
 
PPTX
Debugging Live Apps in k8s
Faheem Memon
 
PDF
Dev fest 2020 taiwan how to debug microservices on kubernetes as a pros (ht...
KAI CHU CHUNG
 
Google ko: fast Kubernetes microservice development in Go - Sangam Biradar, E...
sangam biradar
 
Remote debugging of Application in Kubernetes
ConSol Consulting & Solutions Software GmbH
 
Build Your Own CaaS (Container as a Service)
HungWei Chiu
 
Debugging Live Apps in k8s
Faheem Memon
 
Dev fest 2020 taiwan how to debug microservices on kubernetes as a pros (ht...
KAI CHU CHUNG
 

Recently uploaded (20)

PPTX
Thermal runway and thermal stability.pptx
godow93766
 
PPTX
What is Shot Peening | Shot Peening is a Surface Treatment Process
Vibra Finish
 
PPTX
Introduction to Design of Machine Elements
PradeepKumarS27
 
PPTX
美国电子版毕业证南卡罗莱纳大学上州分校水印成绩单USC学费发票定做学位证书编号怎么查
Taqyea
 
PPTX
Product Development & DevelopmentLecture02.pptx
zeeshanwazir2
 
PDF
MAD Unit - 2 Activity and Fragment Management in Android (Diploma IT)
JappanMavani
 
PDF
Introduction to Productivity and Quality
মোঃ ফুরকান উদ্দিন জুয়েল
 
DOC
MRRS Strength and Durability of Concrete
CivilMythili
 
PPTX
fatigue in aircraft structures-221113192308-0ad6dc8c.pptx
aviatecofficial
 
PPTX
GitOps_Without_K8s_Training_detailed git repository
DanialHabibi2
 
PPT
Electrical Safety Presentation for Basics Learning
AliJaved79382
 
PDF
Reasons for the succes of MENARD PRESSUREMETER.pdf
majdiamz
 
PPTX
MATLAB : Introduction , Features , Display Windows, Syntax, Operators, Graph...
Amity University, Patna
 
PPT
PPT2_Metal formingMECHANICALENGINEEIRNG .ppt
Praveen Kumar
 
PDF
Viol_Alessandro_Presentazione_prelaurea.pdf
dsecqyvhbowrzxshhf
 
PDF
MAD Unit - 1 Introduction of Android IT Department
JappanMavani
 
PDF
Zilliz Cloud Demo for performance and scale
Zilliz
 
PPTX
Heart Bleed Bug - A case study (Course: Cryptography and Network Security)
Adri Jovin
 
PDF
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
PPTX
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
Thermal runway and thermal stability.pptx
godow93766
 
What is Shot Peening | Shot Peening is a Surface Treatment Process
Vibra Finish
 
Introduction to Design of Machine Elements
PradeepKumarS27
 
美国电子版毕业证南卡罗莱纳大学上州分校水印成绩单USC学费发票定做学位证书编号怎么查
Taqyea
 
Product Development & DevelopmentLecture02.pptx
zeeshanwazir2
 
MAD Unit - 2 Activity and Fragment Management in Android (Diploma IT)
JappanMavani
 
Introduction to Productivity and Quality
মোঃ ফুরকান উদ্দিন জুয়েল
 
MRRS Strength and Durability of Concrete
CivilMythili
 
fatigue in aircraft structures-221113192308-0ad6dc8c.pptx
aviatecofficial
 
GitOps_Without_K8s_Training_detailed git repository
DanialHabibi2
 
Electrical Safety Presentation for Basics Learning
AliJaved79382
 
Reasons for the succes of MENARD PRESSUREMETER.pdf
majdiamz
 
MATLAB : Introduction , Features , Display Windows, Syntax, Operators, Graph...
Amity University, Patna
 
PPT2_Metal formingMECHANICALENGINEEIRNG .ppt
Praveen Kumar
 
Viol_Alessandro_Presentazione_prelaurea.pdf
dsecqyvhbowrzxshhf
 
MAD Unit - 1 Introduction of Android IT Department
JappanMavani
 
Zilliz Cloud Demo for performance and scale
Zilliz
 
Heart Bleed Bug - A case study (Course: Cryptography and Network Security)
Adri Jovin
 
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
Ad

Debugging Go in Kubernetes