본문 바로가기
ERR 해결할레나

[에러] "RemovePodSandbox from runtime service failed"

by LENA-cfg 2024. 8. 8.

문제

상황은 도커 빌드된 이미지를 crictl 명령어을 통해 실행시키려고 하는데 이미 생성된 파드 이름과 겹치면서 

아래 명령어를 진행했을때 생긴 문제였다.

 

왜 ctr 명령어를 안사용했냐면 내 이미지는 단순 실행만하면 안되고 이미지 내부 포트랑 로컬이랑 포트포워딩을 해야하는데 ctr은 저수준 도구라 포트포워딩을 지원하지 않음

sudo crictl rmp PodId

 

에러명

E0808 14:38:57.010093   48678 remote_runtime.go:241]

"RemovePodSandbox from runtime service failed"

err="rpc error: code = Unknown desc = failed to forcibly stop sandbox failed to destroy network for sandbox

cni plugin not initialized" podSandboxID="숫자들"

 

removing the pod sandbox "숫자들":

rpc error: code = Unknown desc = failed to forcibly stop sandbox  failed to destroy network for sandbox

cni plugin not initialized

 

해결

우선, cni plugin not initialized를 작업을 해줘야 한다

cni 컨테이너 네트워크 인터페이스인데 쿠버네티스 같은 컨테이너 오케스트레이션 시스템에서 네트워크 플러그인과 통합되어 컨테이너 간의 네트워킹을 설정하고 관리 할 수 있게 해준다.

 

근데 이게 지금 초기화가 안됬다는것

 

1. cd /etc/cni/ 들어감

2. mkdir net.d

3. cd net.d

4. sudo nano 99-loopback.conf

nano로 파일열어서 아래의 내용 복붙하고 control S, control X 눌러서 저장하고 나옴

{
  "cniVersion": "0.3.1",
  "type": "loopback"
}

5. sudo nano 10-bridge.conf

nano로 파일열어서 아래의 내용 복붙하고 control S, control X 눌러서 저장하고 나옴

{
  "cniVersion": "0.3.1",
  "name": "bridge",
  "type": "bridge",
  "bridge": "cni0",
  "isGateway": true,
  "ipMasq": true,
  "ipam": {
    "type": "host-local",
    "subnet": "10.22.0.0/16",
    "routes": [
      { "dst": "0.0.0.0/0" }
    ]
  }
}

6. kubectl delete -f https://docs.projectcalico.org/manifests/calico.yaml

나는 calico(쿠버네티스와 같은 컨테이너 오케스트레이션 시스템에서 네트워크와 네트워크 보안을 제공하는 오픈소스 프로젝트)를 사용해서 calico.yaml로 설정함, Flannel, Weave, Cilium, Contiv, Multus도 있음 애는 공식문서 보면서 다르게 써야함

 

7. kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml

8. sudo systemctl restart kubelet
9. sudo systemctl restart containerd
10. sudo crictl rmp PodId
11. sudo crictl pods

위의 명령어 순서대로 작업하면 포드 원활하게 삭제된거 확인할 수 있음