SlideShare une entreprise Scribd logo
1  sur  25
Télécharger pour lire hors ligne
Eohyung Lee, Cloud engineer, Kakao enterprise
How to debug the pod
which is hard to debug
Who am I?
● Eohyung Lee
○ A.K.A. 어형부형 in facebook
● Bio
○ Kakao enterprise (NOW)
■ Build kakao cloud service
○ Line plus (~2019)
■ Build cloud native platform by kubernetes
○ Kakao (~2017)
■ Build private cloud service by openstack
○ KT (2010~2014)
■ Build public cloud storage service by openstack swift
Problems while using kubernetes
kubernetes problem
CNI
CSI
kubernetes API
...
node problem
kubelet
kernel
physical network
...
application problem
code
config
Cause of POD problems
POD
problem
kubernetes problem
CNI
CSI
kubernetes API
...
node problem
kubelet
kernel
physical network
...
application problem
code
config
Kind of POD problems
● Stuck in some status
○ pending, waiting, unknown status
● Dying repeatedly
○ crashloopback, error status
How to solve general problems
● Kubernetes problem
○ Check control plane logs
○ Check events
○ Check important component logs
○ ...
● Node problem
○ Check kubelet logs
○ Check kernel logs
○ Test physical network
○ ...
How to solve general problems (2)
● Application problem
○ Check code
○ Check config
○ Check container logs
○ ...
● Basic knowhow
○ Debug Pods and ReplicationControllers
■ https://kubernetes.io/docs/tasks/debug-application-cluster/d
ebug-pod-replication-controller/
Mixed POD problems
Kubernetes
Problem
Node
Problem
Application
Problem
MIXED PROBLEMS
How to debug mixed POD problems?
●Watch logs, events, status about POD
●Add more logs into application code
●Reproduce problem in the stage environment
If Reproduced problem failed
●Run command inside the container
$ kubectl exec ${POD_NAME} -c ${CONTAINER_NAME} -- ${CMD}
${ARG1} ${ARG2} ... ${ARGN}
●Or ssh into container host node then do command
$ ssh ${CONTAINER_HOST}
CONTAINER_HOST:~$ docker exec ${CONTAINER_ID}
Better solution
● Add debugging container
without modification
$ kubectl debug ${TARGET_POD} -c
${CONTAINER_NAME} --image=debian
-- bash
○ Ephemeral containers feature
■ https://github.com/kubernetes/enhancem
ents/blob/master/keps/sig-node/2019021
2-ephemeral-containers.md
● But, still developing. :'(
POD
target
container
ephemeral
container
CREATE
POD
target
container
ephemeral
container
EXEC
DEBUG
POD
target
container DELETE
1
2
3
When is it hard to debug POD?
● Continuously restarting POD (CrashLoopBack,
Error, ...)
● Not enough environment for debugging pod
How to debug
continuously restarting POD?
● Continuously restarting
POD (CrashLoopBack,
Error)
○ Command failed
■ Replace with command that
do not fail while debugging
POD
● e.g. sleep
○ Liveness probe have failed
■ Remove liveness
configuration temporarily
while debugging POD
apiVersion: v1
kind: Pod
metadata:
name: mypod
spec:
containers:
- name: mycontainer
image: k8s.gcr.io/busybox
command:
- /bin/sh
- -c
- touch /tmp/healthy; sleep 600
livenessProbe:
exec:
command:
- cat
- /tmp/healthy
initialDelaySeconds: 3
periodSeconds: 5
How to debug POD
with not enough environment?
● Representative difficult case
○ Based on scratch image
■ No tools for debugging, including shell
● General solution (with restart container)
○ Deploy new image with debugging tools
■ After debugging, redeploy to the original image, but it is
inconvenient
● Proposed solutions (without restart container)
○ Use container host information
○ Enter container namespace in container host
○ Insert debugging tools into the POD
Using container host information
● Gathering information by
checking directories under
/proc/{container_pid}/
○ Check container root directory
$ cd /proc/${CONTAINER_PROCESS_ID}/root/
○ Check container network
information
$ cd /proc/${CONTAINER_PROCESS_ID}/net/
○ More information
■ https://www.linux.com/news/discover-p
ossibilities-proc-directory/
container
/ directory
Enter container namespace in
container host
● Enter container namespace
using nsenter
○ Use lsns to check namespace lists
○ Use network namespace with
container host binaries
$ nsenter -t ${CONTAINER_PROCESS_ID} -n ss
○ But, when using mount namespace
can’t use container host binaries
○ More information
■ http://man7.org/linux/man-pages/man1/n
senter.1.html
UTS
name
space
IPC
name
space
PID
name
space
USR
name
space
NET
name
space
MNT
name
space
container
host
UTS
host
IPC
host
PID
host
USR
host
MNT
nsenter
( only enter container network
namespace)
HOST
Insert debugging tools into the POD
● scratch-debugger
○ Insert busybox binary into the
POD based on scratch image
■ https://github.com/kubernetes-re
tired/contrib/tree/master/scratc
h-debugger
● But, sometimes it can not
work with
○ Using containerd runtime
○ Using read only file system
POD
target
container
1
POD
busybox
container
CREATE
1
HOST
POD
target
container
2
POD
busybox
container
docker cp
COPY BUSYBOX
When using containerd runtime
● Container Runtime
Interface(CRI)
○ No feature for copy binaries into
container like docker cp
○ All other container runtimes has same
problem
● Solution
○ Copy debugging tools into
/proc/${container_pid}/root directory
$ cp busybox /proc/${CONTAINER_PROCESS_ID}/root
$ crictl exec -ti ${CONTAINER_ID} /busybox sh
HOST
host process data
/proc/${CONTAINER_PROCESS_ID}/root
disk
container
/ directory
COPY BUSYBOX
/
disk
same
busybox
Read only file system
in kubernetes
apiVersion: apps/v1
kind: Deployment
metadata:
name: coredns
namespace: kube-system
labels:
k8s-app: kube-dns
kubernetes.io/name: "CoreDNS"
spec:
template:
spec:
containers:
- name: coredns
securityContext:
readOnlyRootFilesystem: true
...
https://github.com/coredns/deployment/blob/master/kubernetes/coredns.yaml.se
When using read only file system
● Can not copy binary into read
only file system
● docker cp command is not
working
$ docker cp binary 0cf670cd0f25:/
Error response from daemon: container rootfs is
marked read-only
● under /proc directories is not
working too
$ cp binary /proc/33608/root
cp: cannot create regular file `binary':
Read-only file system
HOST
host process data
/proc/${CONTAINER_PROCESS_ID}/root
read only disk
container
/ directory
COPY BUSYBOX
/
disk
same
busybox
FAIL
When using read only file system (2)
● Use mount points directory
$ cd
/run/containerd/io.containerd.runtime.v1.linux
/k8s.io/${CONTAINER_ID}/rootfs
$ wget
https://busybox.net/downloads/binaries/1.31.0-
i686-uclibc/busybox
$ chmod +x busybox
$ mkdir bin
$ ./busybox --install ./bin
$ crictl exec -ti ${CONTAINER_ID} /busybox sh
HOST
ephemeral container data
/run/containerd/io.containerd.runtime.v1.lin
ux/k8s.io/${CONTAINER_ID}/rootfs
host process data
/proc/${CONTAINER_PROCESS_ID}/root
disk
read only disk
container
/ directory
INSTALL BUSYBOX
bind mount
src
/
disk
dst
same
busybox
Important thing!
● Most of dynamically-linked executable
$ crictl exec -ti 0cf670cd0f25 /busybox sh
starting container process caused "exec: "/busybox": stat /busybox: no
such file or directory": unknown
● Need to use statically-linked executable
$ ldd busybox
not a dynamic executable
Conclusion
Thank you
Q&A

Contenu connexe

Tendances

KubeCon EU 2016: Kubernetes Storage 101
KubeCon EU 2016: Kubernetes Storage 101KubeCon EU 2016: Kubernetes Storage 101
KubeCon EU 2016: Kubernetes Storage 101KubeAcademy
 
MariaDB 마이그레이션 - 네오클로바
MariaDB 마이그레이션 - 네오클로바MariaDB 마이그레이션 - 네오클로바
MariaDB 마이그레이션 - 네오클로바NeoClova
 
Kubernetes
KubernetesKubernetes
Kuberneteserialc_w
 
eBPF - Rethinking the Linux Kernel
eBPF - Rethinking the Linux KerneleBPF - Rethinking the Linux Kernel
eBPF - Rethinking the Linux KernelThomas Graf
 
Head First to Container&Kubernetes
Head First to Container&KubernetesHead First to Container&Kubernetes
Head First to Container&KubernetesHungWei Chiu
 
[NEW LAUNCH!] Scaling Tightly-coupled HPC workloads on HPC with Elastic Fabri...
[NEW LAUNCH!] Scaling Tightly-coupled HPC workloads on HPC with Elastic Fabri...[NEW LAUNCH!] Scaling Tightly-coupled HPC workloads on HPC with Elastic Fabri...
[NEW LAUNCH!] Scaling Tightly-coupled HPC workloads on HPC with Elastic Fabri...Amazon Web Services
 
쿠버네티스의 이해 #1
쿠버네티스의 이해 #1쿠버네티스의 이해 #1
쿠버네티스의 이해 #1상욱 송
 
A brief study on Kubernetes and its components
A brief study on Kubernetes and its componentsA brief study on Kubernetes and its components
A brief study on Kubernetes and its componentsRamit Surana
 
PostgreSQL continuous backup and PITR with Barman
 PostgreSQL continuous backup and PITR with Barman PostgreSQL continuous backup and PITR with Barman
PostgreSQL continuous backup and PITR with BarmanEDB
 
[KubeConUS2019 Docker, Inc. Booth] Distributed Builds on Kubernetes with Bui...
 [KubeConUS2019 Docker, Inc. Booth] Distributed Builds on Kubernetes with Bui... [KubeConUS2019 Docker, Inc. Booth] Distributed Builds on Kubernetes with Bui...
[KubeConUS2019 Docker, Inc. Booth] Distributed Builds on Kubernetes with Bui...Akihiro Suda
 
OVN - Basics and deep dive
OVN - Basics and deep diveOVN - Basics and deep dive
OVN - Basics and deep diveTrinath Somanchi
 
Namespaces and cgroups - the basis of Linux containers
Namespaces and cgroups - the basis of Linux containersNamespaces and cgroups - the basis of Linux containers
Namespaces and cgroups - the basis of Linux containersKernel TLV
 
[OpenStack Days Korea 2016] Track1 - 카카오는 오픈스택 기반으로 어떻게 5000VM을 운영하고 있을까?
[OpenStack Days Korea 2016] Track1 - 카카오는 오픈스택 기반으로 어떻게 5000VM을 운영하고 있을까?[OpenStack Days Korea 2016] Track1 - 카카오는 오픈스택 기반으로 어떻게 5000VM을 운영하고 있을까?
[OpenStack Days Korea 2016] Track1 - 카카오는 오픈스택 기반으로 어떻게 5000VM을 운영하고 있을까?OpenStack Korea Community
 
Docker Networking Deep Dive
Docker Networking Deep DiveDocker Networking Deep Dive
Docker Networking Deep DiveDocker, Inc.
 
Large scale overlay networks with ovn: problems and solutions
Large scale overlay networks with ovn: problems and solutionsLarge scale overlay networks with ovn: problems and solutions
Large scale overlay networks with ovn: problems and solutionsHan Zhou
 
Keeping Latency Low for User-Defined Functions with WebAssembly
Keeping Latency Low for User-Defined Functions with WebAssemblyKeeping Latency Low for User-Defined Functions with WebAssembly
Keeping Latency Low for User-Defined Functions with WebAssemblyScyllaDB
 
Achieving the Ultimate Performance with KVM
Achieving the Ultimate Performance with KVMAchieving the Ultimate Performance with KVM
Achieving the Ultimate Performance with KVMDevOps.com
 
Kubernetes Networking with Cilium - Deep Dive
Kubernetes Networking with Cilium - Deep DiveKubernetes Networking with Cilium - Deep Dive
Kubernetes Networking with Cilium - Deep DiveMichal Rostecki
 

Tendances (20)

KubeCon EU 2016: Kubernetes Storage 101
KubeCon EU 2016: Kubernetes Storage 101KubeCon EU 2016: Kubernetes Storage 101
KubeCon EU 2016: Kubernetes Storage 101
 
MariaDB 마이그레이션 - 네오클로바
MariaDB 마이그레이션 - 네오클로바MariaDB 마이그레이션 - 네오클로바
MariaDB 마이그레이션 - 네오클로바
 
Kubernetes
KubernetesKubernetes
Kubernetes
 
Kubernetes networking & Security
Kubernetes networking & SecurityKubernetes networking & Security
Kubernetes networking & Security
 
eBPF - Rethinking the Linux Kernel
eBPF - Rethinking the Linux KerneleBPF - Rethinking the Linux Kernel
eBPF - Rethinking the Linux Kernel
 
Head First to Container&Kubernetes
Head First to Container&KubernetesHead First to Container&Kubernetes
Head First to Container&Kubernetes
 
[NEW LAUNCH!] Scaling Tightly-coupled HPC workloads on HPC with Elastic Fabri...
[NEW LAUNCH!] Scaling Tightly-coupled HPC workloads on HPC with Elastic Fabri...[NEW LAUNCH!] Scaling Tightly-coupled HPC workloads on HPC with Elastic Fabri...
[NEW LAUNCH!] Scaling Tightly-coupled HPC workloads on HPC with Elastic Fabri...
 
쿠버네티스의 이해 #1
쿠버네티스의 이해 #1쿠버네티스의 이해 #1
쿠버네티스의 이해 #1
 
A brief study on Kubernetes and its components
A brief study on Kubernetes and its componentsA brief study on Kubernetes and its components
A brief study on Kubernetes and its components
 
PostgreSQL continuous backup and PITR with Barman
 PostgreSQL continuous backup and PITR with Barman PostgreSQL continuous backup and PITR with Barman
PostgreSQL continuous backup and PITR with Barman
 
[KubeConUS2019 Docker, Inc. Booth] Distributed Builds on Kubernetes with Bui...
 [KubeConUS2019 Docker, Inc. Booth] Distributed Builds on Kubernetes with Bui... [KubeConUS2019 Docker, Inc. Booth] Distributed Builds on Kubernetes with Bui...
[KubeConUS2019 Docker, Inc. Booth] Distributed Builds on Kubernetes with Bui...
 
OVN - Basics and deep dive
OVN - Basics and deep diveOVN - Basics and deep dive
OVN - Basics and deep dive
 
Namespaces and cgroups - the basis of Linux containers
Namespaces and cgroups - the basis of Linux containersNamespaces and cgroups - the basis of Linux containers
Namespaces and cgroups - the basis of Linux containers
 
[OpenStack Days Korea 2016] Track1 - 카카오는 오픈스택 기반으로 어떻게 5000VM을 운영하고 있을까?
[OpenStack Days Korea 2016] Track1 - 카카오는 오픈스택 기반으로 어떻게 5000VM을 운영하고 있을까?[OpenStack Days Korea 2016] Track1 - 카카오는 오픈스택 기반으로 어떻게 5000VM을 운영하고 있을까?
[OpenStack Days Korea 2016] Track1 - 카카오는 오픈스택 기반으로 어떻게 5000VM을 운영하고 있을까?
 
Kubernetes
KubernetesKubernetes
Kubernetes
 
Docker Networking Deep Dive
Docker Networking Deep DiveDocker Networking Deep Dive
Docker Networking Deep Dive
 
Large scale overlay networks with ovn: problems and solutions
Large scale overlay networks with ovn: problems and solutionsLarge scale overlay networks with ovn: problems and solutions
Large scale overlay networks with ovn: problems and solutions
 
Keeping Latency Low for User-Defined Functions with WebAssembly
Keeping Latency Low for User-Defined Functions with WebAssemblyKeeping Latency Low for User-Defined Functions with WebAssembly
Keeping Latency Low for User-Defined Functions with WebAssembly
 
Achieving the Ultimate Performance with KVM
Achieving the Ultimate Performance with KVMAchieving the Ultimate Performance with KVM
Achieving the Ultimate Performance with KVM
 
Kubernetes Networking with Cilium - Deep Dive
Kubernetes Networking with Cilium - Deep DiveKubernetes Networking with Cilium - Deep Dive
Kubernetes Networking with Cilium - Deep Dive
 

Similaire à How to debug the pod which is hard to debug (디버그 하기 어려운 POD 디버그 하기)

[KubeConEU] Building images efficiently and securely on Kubernetes with BuildKit
[KubeConEU] Building images efficiently and securely on Kubernetes with BuildKit[KubeConEU] Building images efficiently and securely on Kubernetes with BuildKit
[KubeConEU] Building images efficiently and securely on Kubernetes with BuildKitAkihiro Suda
 
Building images efficiently and securely on Kubernetes with BuildKit
Building images efficiently and securely on Kubernetes with BuildKitBuilding images efficiently and securely on Kubernetes with BuildKit
Building images efficiently and securely on Kubernetes with BuildKitNTT Software Innovation Center
 
Настройка окружения для кросскомпиляции проектов на основе docker'a
Настройка окружения для кросскомпиляции проектов на основе docker'aНастройка окружения для кросскомпиляции проектов на основе docker'a
Настройка окружения для кросскомпиляции проектов на основе docker'acorehard_by
 
Build optimization mechanisms in GitLab and Docker
Build optimization mechanisms in GitLab and DockerBuild optimization mechanisms in GitLab and Docker
Build optimization mechanisms in GitLab and DockerDmytro Patkovskyi
 
Making kubernetes simple for developers
Making kubernetes simple for developersMaking kubernetes simple for developers
Making kubernetes simple for developersSuraj Deshmukh
 
Introduction to Docker at SF Peninsula Software Development Meetup @Guidewire
Introduction to Docker at SF Peninsula Software Development Meetup @GuidewireIntroduction to Docker at SF Peninsula Software Development Meetup @Guidewire
Introduction to Docker at SF Peninsula Software Development Meetup @GuidewiredotCloud
 
Getting-Started-with-Containers-and-Kubernetes_-March-2020-CNCF-Webinar.pdf
Getting-Started-with-Containers-and-Kubernetes_-March-2020-CNCF-Webinar.pdfGetting-Started-with-Containers-and-Kubernetes_-March-2020-CNCF-Webinar.pdf
Getting-Started-with-Containers-and-Kubernetes_-March-2020-CNCF-Webinar.pdfssuser348b1c
 
Introduction to Docker and Containers
Introduction to Docker and ContainersIntroduction to Docker and Containers
Introduction to Docker and ContainersDocker, Inc.
 
Perspectives on Docker
Perspectives on DockerPerspectives on Docker
Perspectives on DockerRightScale
 
Docker Up and Running Introduction
Docker Up and Running IntroductionDocker Up and Running Introduction
Docker Up and Running IntroductionMark Beacom
 
A Gentle Introduction to Docker and Containers
A Gentle Introduction to Docker and ContainersA Gentle Introduction to Docker and Containers
A Gentle Introduction to Docker and ContainersDocker, Inc.
 
Docker primer and tips
Docker primer and tipsDocker primer and tips
Docker primer and tipsSamuel Chow
 
Real-World Docker: 10 Things We've Learned
Real-World Docker: 10 Things We've Learned  Real-World Docker: 10 Things We've Learned
Real-World Docker: 10 Things We've Learned RightScale
 
[HKOSCon x COSCUP 2020][20200801][Ansible: From VM to Kubernetes]
[HKOSCon x COSCUP 2020][20200801][Ansible: From VM to Kubernetes][HKOSCon x COSCUP 2020][20200801][Ansible: From VM to Kubernetes]
[HKOSCon x COSCUP 2020][20200801][Ansible: From VM to Kubernetes]Wong Hoi Sing Edison
 
Kubernetes & Google Container Engine @ mabl
Kubernetes & Google Container Engine @ mablKubernetes & Google Container Engine @ mabl
Kubernetes & Google Container Engine @ mablJoseph Lust
 
Docker slides
Docker slidesDocker slides
Docker slidesAyla Khan
 
AllTheTalks 2020: Buildpacks - container for everyone!
AllTheTalks 2020: Buildpacks - container for everyone!AllTheTalks 2020: Buildpacks - container for everyone!
AllTheTalks 2020: Buildpacks - container for everyone!Zander Mackie
 
Talk on PHP Day Uruguay about Docker
Talk on PHP Day Uruguay about DockerTalk on PHP Day Uruguay about Docker
Talk on PHP Day Uruguay about DockerWellington Silva
 
Docker and-containers-for-development-and-deployment-scale12x
Docker and-containers-for-development-and-deployment-scale12xDocker and-containers-for-development-and-deployment-scale12x
Docker and-containers-for-development-and-deployment-scale12xrkr10
 

Similaire à How to debug the pod which is hard to debug (디버그 하기 어려운 POD 디버그 하기) (20)

[KubeConEU] Building images efficiently and securely on Kubernetes with BuildKit
[KubeConEU] Building images efficiently and securely on Kubernetes with BuildKit[KubeConEU] Building images efficiently and securely on Kubernetes with BuildKit
[KubeConEU] Building images efficiently and securely on Kubernetes with BuildKit
 
Building images efficiently and securely on Kubernetes with BuildKit
Building images efficiently and securely on Kubernetes with BuildKitBuilding images efficiently and securely on Kubernetes with BuildKit
Building images efficiently and securely on Kubernetes with BuildKit
 
Настройка окружения для кросскомпиляции проектов на основе docker'a
Настройка окружения для кросскомпиляции проектов на основе docker'aНастройка окружения для кросскомпиляции проектов на основе docker'a
Настройка окружения для кросскомпиляции проектов на основе docker'a
 
Build optimization mechanisms in GitLab and Docker
Build optimization mechanisms in GitLab and DockerBuild optimization mechanisms in GitLab and Docker
Build optimization mechanisms in GitLab and Docker
 
Making kubernetes simple for developers
Making kubernetes simple for developersMaking kubernetes simple for developers
Making kubernetes simple for developers
 
Introduction to Docker at SF Peninsula Software Development Meetup @Guidewire
Introduction to Docker at SF Peninsula Software Development Meetup @GuidewireIntroduction to Docker at SF Peninsula Software Development Meetup @Guidewire
Introduction to Docker at SF Peninsula Software Development Meetup @Guidewire
 
Getting-Started-with-Containers-and-Kubernetes_-March-2020-CNCF-Webinar.pdf
Getting-Started-with-Containers-and-Kubernetes_-March-2020-CNCF-Webinar.pdfGetting-Started-with-Containers-and-Kubernetes_-March-2020-CNCF-Webinar.pdf
Getting-Started-with-Containers-and-Kubernetes_-March-2020-CNCF-Webinar.pdf
 
Introduction to Docker and Containers
Introduction to Docker and ContainersIntroduction to Docker and Containers
Introduction to Docker and Containers
 
Perspectives on Docker
Perspectives on DockerPerspectives on Docker
Perspectives on Docker
 
Docker n co
Docker n coDocker n co
Docker n co
 
Docker Up and Running Introduction
Docker Up and Running IntroductionDocker Up and Running Introduction
Docker Up and Running Introduction
 
A Gentle Introduction to Docker and Containers
A Gentle Introduction to Docker and ContainersA Gentle Introduction to Docker and Containers
A Gentle Introduction to Docker and Containers
 
Docker primer and tips
Docker primer and tipsDocker primer and tips
Docker primer and tips
 
Real-World Docker: 10 Things We've Learned
Real-World Docker: 10 Things We've Learned  Real-World Docker: 10 Things We've Learned
Real-World Docker: 10 Things We've Learned
 
[HKOSCon x COSCUP 2020][20200801][Ansible: From VM to Kubernetes]
[HKOSCon x COSCUP 2020][20200801][Ansible: From VM to Kubernetes][HKOSCon x COSCUP 2020][20200801][Ansible: From VM to Kubernetes]
[HKOSCon x COSCUP 2020][20200801][Ansible: From VM to Kubernetes]
 
Kubernetes & Google Container Engine @ mabl
Kubernetes & Google Container Engine @ mablKubernetes & Google Container Engine @ mabl
Kubernetes & Google Container Engine @ mabl
 
Docker slides
Docker slidesDocker slides
Docker slides
 
AllTheTalks 2020: Buildpacks - container for everyone!
AllTheTalks 2020: Buildpacks - container for everyone!AllTheTalks 2020: Buildpacks - container for everyone!
AllTheTalks 2020: Buildpacks - container for everyone!
 
Talk on PHP Day Uruguay about Docker
Talk on PHP Day Uruguay about DockerTalk on PHP Day Uruguay about Docker
Talk on PHP Day Uruguay about Docker
 
Docker and-containers-for-development-and-deployment-scale12x
Docker and-containers-for-development-and-deployment-scale12xDocker and-containers-for-development-and-deployment-scale12x
Docker and-containers-for-development-and-deployment-scale12x
 

Plus de 어형 이

Toward kubernetes native data center
Toward kubernetes native data centerToward kubernetes native data center
Toward kubernetes native data center어형 이
 
Truly understanding container
Truly understanding containerTruly understanding container
Truly understanding container어형 이
 
Immutable kubernetes architecture by linuxkit
Immutable kubernetes architecture by linuxkitImmutable kubernetes architecture by linuxkit
Immutable kubernetes architecture by linuxkit어형 이
 
How to make cloud native platform by kubernetes
How to make cloud native platform by kubernetesHow to make cloud native platform by kubernetes
How to make cloud native platform by kubernetes어형 이
 
Live upgrade neutron architecture without downtime
Live upgrade neutron architecture without downtimeLive upgrade neutron architecture without downtime
Live upgrade neutron architecture without downtime어형 이
 
Making cloud native platform by kubernetes
Making cloud native platform by kubernetesMaking cloud native platform by kubernetes
Making cloud native platform by kubernetes어형 이
 
Kakao Openstack CI/CD
Kakao Openstack CI/CDKakao Openstack CI/CD
Kakao Openstack CI/CD어형 이
 
manage inhouse openstack the hard way(kakao case study about 10,000 vms)
manage inhouse openstack the hard way(kakao case study about 10,000 vms)manage inhouse openstack the hard way(kakao case study about 10,000 vms)
manage inhouse openstack the hard way(kakao case study about 10,000 vms)어형 이
 
Install openstack
Install openstackInstall openstack
Install openstack어형 이
 
Openstack Swift overview
Openstack Swift overviewOpenstack Swift overview
Openstack Swift overview어형 이
 
debugging openstack neutron /w openvswitch
debugging openstack neutron /w openvswitchdebugging openstack neutron /w openvswitch
debugging openstack neutron /w openvswitch어형 이
 

Plus de 어형 이 (11)

Toward kubernetes native data center
Toward kubernetes native data centerToward kubernetes native data center
Toward kubernetes native data center
 
Truly understanding container
Truly understanding containerTruly understanding container
Truly understanding container
 
Immutable kubernetes architecture by linuxkit
Immutable kubernetes architecture by linuxkitImmutable kubernetes architecture by linuxkit
Immutable kubernetes architecture by linuxkit
 
How to make cloud native platform by kubernetes
How to make cloud native platform by kubernetesHow to make cloud native platform by kubernetes
How to make cloud native platform by kubernetes
 
Live upgrade neutron architecture without downtime
Live upgrade neutron architecture without downtimeLive upgrade neutron architecture without downtime
Live upgrade neutron architecture without downtime
 
Making cloud native platform by kubernetes
Making cloud native platform by kubernetesMaking cloud native platform by kubernetes
Making cloud native platform by kubernetes
 
Kakao Openstack CI/CD
Kakao Openstack CI/CDKakao Openstack CI/CD
Kakao Openstack CI/CD
 
manage inhouse openstack the hard way(kakao case study about 10,000 vms)
manage inhouse openstack the hard way(kakao case study about 10,000 vms)manage inhouse openstack the hard way(kakao case study about 10,000 vms)
manage inhouse openstack the hard way(kakao case study about 10,000 vms)
 
Install openstack
Install openstackInstall openstack
Install openstack
 
Openstack Swift overview
Openstack Swift overviewOpenstack Swift overview
Openstack Swift overview
 
debugging openstack neutron /w openvswitch
debugging openstack neutron /w openvswitchdebugging openstack neutron /w openvswitch
debugging openstack neutron /w openvswitch
 

Dernier

A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 

Dernier (20)

A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 

How to debug the pod which is hard to debug (디버그 하기 어려운 POD 디버그 하기)

  • 1.
  • 2. Eohyung Lee, Cloud engineer, Kakao enterprise How to debug the pod which is hard to debug
  • 3. Who am I? ● Eohyung Lee ○ A.K.A. 어형부형 in facebook ● Bio ○ Kakao enterprise (NOW) ■ Build kakao cloud service ○ Line plus (~2019) ■ Build cloud native platform by kubernetes ○ Kakao (~2017) ■ Build private cloud service by openstack ○ KT (2010~2014) ■ Build public cloud storage service by openstack swift
  • 4. Problems while using kubernetes kubernetes problem CNI CSI kubernetes API ... node problem kubelet kernel physical network ... application problem code config
  • 5. Cause of POD problems POD problem kubernetes problem CNI CSI kubernetes API ... node problem kubelet kernel physical network ... application problem code config
  • 6. Kind of POD problems ● Stuck in some status ○ pending, waiting, unknown status ● Dying repeatedly ○ crashloopback, error status
  • 7. How to solve general problems ● Kubernetes problem ○ Check control plane logs ○ Check events ○ Check important component logs ○ ... ● Node problem ○ Check kubelet logs ○ Check kernel logs ○ Test physical network ○ ...
  • 8. How to solve general problems (2) ● Application problem ○ Check code ○ Check config ○ Check container logs ○ ... ● Basic knowhow ○ Debug Pods and ReplicationControllers ■ https://kubernetes.io/docs/tasks/debug-application-cluster/d ebug-pod-replication-controller/
  • 10. How to debug mixed POD problems? ●Watch logs, events, status about POD ●Add more logs into application code ●Reproduce problem in the stage environment
  • 11. If Reproduced problem failed ●Run command inside the container $ kubectl exec ${POD_NAME} -c ${CONTAINER_NAME} -- ${CMD} ${ARG1} ${ARG2} ... ${ARGN} ●Or ssh into container host node then do command $ ssh ${CONTAINER_HOST} CONTAINER_HOST:~$ docker exec ${CONTAINER_ID}
  • 12. Better solution ● Add debugging container without modification $ kubectl debug ${TARGET_POD} -c ${CONTAINER_NAME} --image=debian -- bash ○ Ephemeral containers feature ■ https://github.com/kubernetes/enhancem ents/blob/master/keps/sig-node/2019021 2-ephemeral-containers.md ● But, still developing. :'( POD target container ephemeral container CREATE POD target container ephemeral container EXEC DEBUG POD target container DELETE 1 2 3
  • 13. When is it hard to debug POD? ● Continuously restarting POD (CrashLoopBack, Error, ...) ● Not enough environment for debugging pod
  • 14. How to debug continuously restarting POD? ● Continuously restarting POD (CrashLoopBack, Error) ○ Command failed ■ Replace with command that do not fail while debugging POD ● e.g. sleep ○ Liveness probe have failed ■ Remove liveness configuration temporarily while debugging POD apiVersion: v1 kind: Pod metadata: name: mypod spec: containers: - name: mycontainer image: k8s.gcr.io/busybox command: - /bin/sh - -c - touch /tmp/healthy; sleep 600 livenessProbe: exec: command: - cat - /tmp/healthy initialDelaySeconds: 3 periodSeconds: 5
  • 15. How to debug POD with not enough environment? ● Representative difficult case ○ Based on scratch image ■ No tools for debugging, including shell ● General solution (with restart container) ○ Deploy new image with debugging tools ■ After debugging, redeploy to the original image, but it is inconvenient ● Proposed solutions (without restart container) ○ Use container host information ○ Enter container namespace in container host ○ Insert debugging tools into the POD
  • 16. Using container host information ● Gathering information by checking directories under /proc/{container_pid}/ ○ Check container root directory $ cd /proc/${CONTAINER_PROCESS_ID}/root/ ○ Check container network information $ cd /proc/${CONTAINER_PROCESS_ID}/net/ ○ More information ■ https://www.linux.com/news/discover-p ossibilities-proc-directory/ container / directory
  • 17. Enter container namespace in container host ● Enter container namespace using nsenter ○ Use lsns to check namespace lists ○ Use network namespace with container host binaries $ nsenter -t ${CONTAINER_PROCESS_ID} -n ss ○ But, when using mount namespace can’t use container host binaries ○ More information ■ http://man7.org/linux/man-pages/man1/n senter.1.html UTS name space IPC name space PID name space USR name space NET name space MNT name space container host UTS host IPC host PID host USR host MNT nsenter ( only enter container network namespace)
  • 18. HOST Insert debugging tools into the POD ● scratch-debugger ○ Insert busybox binary into the POD based on scratch image ■ https://github.com/kubernetes-re tired/contrib/tree/master/scratc h-debugger ● But, sometimes it can not work with ○ Using containerd runtime ○ Using read only file system POD target container 1 POD busybox container CREATE 1 HOST POD target container 2 POD busybox container docker cp COPY BUSYBOX
  • 19. When using containerd runtime ● Container Runtime Interface(CRI) ○ No feature for copy binaries into container like docker cp ○ All other container runtimes has same problem ● Solution ○ Copy debugging tools into /proc/${container_pid}/root directory $ cp busybox /proc/${CONTAINER_PROCESS_ID}/root $ crictl exec -ti ${CONTAINER_ID} /busybox sh HOST host process data /proc/${CONTAINER_PROCESS_ID}/root disk container / directory COPY BUSYBOX / disk same busybox
  • 20. Read only file system in kubernetes apiVersion: apps/v1 kind: Deployment metadata: name: coredns namespace: kube-system labels: k8s-app: kube-dns kubernetes.io/name: "CoreDNS" spec: template: spec: containers: - name: coredns securityContext: readOnlyRootFilesystem: true ... https://github.com/coredns/deployment/blob/master/kubernetes/coredns.yaml.se
  • 21. When using read only file system ● Can not copy binary into read only file system ● docker cp command is not working $ docker cp binary 0cf670cd0f25:/ Error response from daemon: container rootfs is marked read-only ● under /proc directories is not working too $ cp binary /proc/33608/root cp: cannot create regular file `binary': Read-only file system HOST host process data /proc/${CONTAINER_PROCESS_ID}/root read only disk container / directory COPY BUSYBOX / disk same busybox FAIL
  • 22. When using read only file system (2) ● Use mount points directory $ cd /run/containerd/io.containerd.runtime.v1.linux /k8s.io/${CONTAINER_ID}/rootfs $ wget https://busybox.net/downloads/binaries/1.31.0- i686-uclibc/busybox $ chmod +x busybox $ mkdir bin $ ./busybox --install ./bin $ crictl exec -ti ${CONTAINER_ID} /busybox sh HOST ephemeral container data /run/containerd/io.containerd.runtime.v1.lin ux/k8s.io/${CONTAINER_ID}/rootfs host process data /proc/${CONTAINER_PROCESS_ID}/root disk read only disk container / directory INSTALL BUSYBOX bind mount src / disk dst same busybox
  • 23. Important thing! ● Most of dynamically-linked executable $ crictl exec -ti 0cf670cd0f25 /busybox sh starting container process caused "exec: "/busybox": stat /busybox: no such file or directory": unknown ● Need to use statically-linked executable $ ldd busybox not a dynamic executable