Kubernetes debugging

cloud2000·2024년 10월 15일
0
  1. kubectl 사용
kubectl get pods -A
kubectl -n <namespace> explain pod <pod-name>
kubectl -n <namespace> describe pods <pod-name>
kubectl -n <namespace> logs <pod-name>
  1. 임시 컨테이너 사용
kubectl debug -it <pod-name> --image=busybox --target=<container-name>
  1. stern 사용
brew install stern

stern app=my-app --since 10m
stern app=my-app -c my-container --since 10m
  1. kubectl port-forward 사용

  2. kubectl get events 사용

kubectl get events -A --sort-by='.metadata.creationTimestamp'
kubectl get events --field-selector involvedObject.kind=Pod
  1. netshoot 사용
    netshoot은 netstat, ifconfig, iperf, mtr, curl, traceroute 등의 많은 네트워크 유틸리티가 포함되어 있어서 network이나 방화벽등의 문제를 check할 경우 유용하게 사용할 수 있음.
kubectl debug mypod -it --image=nicolaka/netshoot

Deployment등에 netshoot를 추가하여 debugging하는 방법 예.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-netshoot
  labels:
    app: nginx-netshoot
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx-netshoot
  template:
    metadata:
    labels:
      app: nginx-netshoot
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.2
        ports:
        - containerPort: 80
      - name: netshoot
        image: nicolaka/netshoot
        command: ["tail"]
        args: ["-f", "/dev/null"]
profile
클라우드쟁이

0개의 댓글

Powered by GraphCDN, the GraphQL CDN