본문 바로가기

⭐ Kubernetes & EKS/pod (파드)

pod 재시작

# kubernetes Pod 재시작
사용법 : kubectl get pod <pod_name> -n <namespace> -o yaml | kubectl replace --force -f-

kubectl get pod <pod_name> -n <namespace> -o yaml | kubectl replace --force -f-

 

문법을 보면 알겠지만 파드(Pod)를 재시작한다라기 보다 삭제하고 다시 만든다고 보는게 맞을것 같다.

예시) web Pod 재시작

shell> kubectl get svc 
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)    AGE 
kubernetes   ClusterIP   10.96.0.11                443/TCP    10d 
web          ClusterIP   10.105.13.151            8080/TCP   40h 
web2         ClusterIP   10.105.146.101           8080/TCP   40h 

shell> kubectl get pod 
NAME   READY   STATUS    RESTARTS   AGE 
web    1/1     Running   0          20s 
web2   1/1     Running   4          40h 

shell> curl 10.105.13.151:8080 
Hello, world! 
Version: 1.0.0 
Hostname: web 

shell> kubectl get pod web -o yaml | kubectl replace --force -f- 
pod "web" deleted 
pod/web replaced 

shell> kubectl get pod 
NAME   READY   STATUS    RESTARTS   AGE 
web    1/1     Running   0          102s 
web2   1/1     Running   4          40h 

shell> curl 10.105.13.151:8080 
Hello, world! 
Version: 1.0.0 
Hostname: web