본문 바로가기
kubenetes

kubernetes 실행 중인 pod에 접속해 package 설치

by kyeongseo.oh 2022. 3. 30.

kubectl exec [pod-name] -it -- bash 혹은 kubectl exec [pod-name] -it -- sh 커맨드로 실행 중인 pod에

접속할 수 있다.

 

실행 중인 pod에 접속한다.

[root@kw1 ~]# kubectl exec ksimage-app -it -- bash
root@ksimage-app:/app# ls -al
total 12
drwxr-xr-x. 1 root root  20 Mar 29 08:51 .
drwxr-xr-x. 1 root root  84 Mar 29 08:59 ..
-rw-r--r--. 1 root root 268 Mar 29 06:17 Dockerfile
-rw-r--r--. 1 root root 204 Mar 29 08:50 ksFlask.py
-rw-r--r--. 1 root root 174 Mar 29 06:17 requirements.txt
drwxr-xr-x. 1 root root  21 Mar 30 13:34 static
drwxr-xr-x. 2 root root  24 Mar 29 06:17 templates

 

패키지를 설치한다. `E: Unable to locate package vim` 에러가 발생한다. 인터넷을 찾아보니 apt-get을 update 하라고 함

root@ksimage-app:/app# apt-get install vim
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package vim

 

apt-get update를 하니 resolve error가 발생함

root@ksimage-app:/app# apt-get update
Err:1 http://deb.debian.org/debian bullseye InRelease
  Temporary failure resolving 'deb.debian.org'
Err:2 http://security.debian.org/debian-security bullseye-security InRelease
  Temporary failure resolving 'security.debian.org'
Err:3 http://deb.debian.org/debian bullseye-updates InRelease
  Temporary failure resolving 'deb.debian.org'
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
All packages are up to date.
W: Failed to fetch http://deb.debian.org/debian/dists/bullseye/InRelease  Temporary failure resolving 'deb.debian.org'
W: Failed to fetch http://security.debian.org/debian-security/dists/bullseye-security/InRelease  Temporary failure resolving 'security.
W: Failed to fetch http://deb.debian.org/debian/dists/bullseye-updates/InRelease  Temporary failure resolving 'deb.debian.org'
W: Some index files failed to download. They have been ignored, or old ones used instead.

 

/etc/resolv.conf를 확인해봄

nameserver가 이상하게 세팅되어있음

root@ksimage-app:/app# cat /etc/resolv.conf
nameserver 10.96.0.10
search default.svc.cluster.local svc.cluster.local cluster.local dd.io
options ndots:5

 

vi가 없으니 echo로 /etc/resolv.conf를 수정한다.

root@ksimage-app:/app# echo nameserver 8.8.8.8 > /etc/resolv.conf
root@ksimage-app:/app# cat /etc/resolv.conf
nameserver 8.8.8.8

 

다시 apt-get update를 수행하니 정상적으로 수행된다.

root@ksimage-app:/app# apt-get update
Get:1 http://security.debian.org/debian-security bullseye-security InRelease [44                                                       .1 kB]
Get:2 http://deb.debian.org/debian bullseye InRelease [116 kB]
Get:3 http://deb.debian.org/debian bullseye-updates InRelease [39.4 kB]
Get:4 http://security.debian.org/debian-security bullseye-security/main amd64 Pa                                                       ckages [123 kB]
Get:5 http://deb.debian.org/debian bullseye/main amd64 Packages [8182 kB]
Get:6 http://deb.debian.org/debian bullseye-updates/main amd64 Packages [2596 B]
Fetched 8507 kB in 2s (4071 kB/s)
Reading package lists... Done

 

vim도 잘 설치된다.

root@ksimage-app:/app# apt-get install vim

'kubenetes' 카테고리의 다른 글

k8s flask web 수정하기  (0) 2022.04.04
ImagePullBackOff error 해결  (0) 2022.04.02
kubernetes pod에 파일 복사하고 다운로드 받기  (0) 2022.03.30
kubernetes python flask ingress 설정하기  (0) 2022.03.27
docker image 제거  (0) 2022.03.26

댓글