STUDY/Data Engineering

[kodekloud] 02 Scheduling : Resource Limits 풀이

wonpick 2023. 1. 23. 17:00
Q1. A pod called rabbit is deployed. Identify the CPU requirements set on the Pod
k get pod rabbit

Q2. Delete the rabbit Pod.
k delete pod rabbit

Q3. Another pod called elephant has been deployed in the default namespace. It fails to get to a running state. Inspect this pod and identify the Reason why it is not running.

OOMKilled메모리가 부족하다는 얘기.

k describe pod elephant | grep -A5 State

Q4.  the status oomkilled indicates that it is failing because the pod ran out of memory. identify the memory limit set on the pod.

 >> Identify the memory limit set on the POD

Q5.The elephant pod runs a process that consumes 15Mi of memory. Increase the limit of the elephant pod to 20Mi. Delete and recreate the pod if required. Do not modify anything other than the required fields.

매니페스트를 작성하여 메모리 제한을 수정한다. 

k get pods elephant -o yaml > elephant.yaml 
#kubectl get pod -o yaml 로 확인한 Object의 내용을 yaml파일 생성
k replace -f elephant.yaml --force
'''replace kubectl replace -f FILENAME 리소스 재구성(새로 적용)'''
# 왜 여기서는 replace썼는지

 

[ kubectl run ]

  • command 형식 : kubectl run <NAME> --image <IMAGE>
  • 설명
    • 명령형 스타일의 단순 명령 / 1개의 단일 Pod를 생성
  • 단점
    • 1개의 단일 파드만 생성하는 사용의 제약이 존재
    • 실행중인 오브젝트의 설정을 변경하려면 ?
      • kubectl edit으로 설정 파일의 내용 변경 -> 실시간 반영?
      • kubectl replace로 컨테이너를 덮어씌우기 -> 중단되는 시간이 생김

[ kubectl create ]

  • command 형식 : kubectl create <Object 타입> [<서브 타입>] <NAME>
  • 설명
    • 명령형 스타일 / 선언형 스타일 모두 가능한 명령
    • <서브 타입> 은 Service Object의 ClusterIP / NodePort 같은 것을 의미
  • 단점
    • 명령형 커맨드 방식은 오브젝트 구성 manifest 파일을 기록하는 추가적인 수단이 필요 (관리)
    • 실행중인 오브젝트의 설정을 변경하려면 ?
      • kubectl edit으로 설정 파일의 내용 변경 -> 실시간 반영?
      • kubectl replace로 컨테이너를 덮어씌우기 -> 중단되는 시간이 생김

[ kubectl apply ]

  • command 형식 : kubectl apply -f <FILE_NAME>
  • 설명
    • 선언형 오브젝트 구성 / 정해진 manifest 파일의 규격으로 Pod 및 Object 생성
    • apply 선언형 명령 하나로 create / replace / scale 등의 명령형 명령의 역할을 수행 가능
      => 가장 선호되는 Object 관리 방식
    • apply로 실행된 Pod 및 오브젝트는 수정이 가능

[ 주의해야할 점 ]

  • kubectl apply 같은 선언형 명령어를 kubectl create / replace / edit / sacle 등의 명령형 명령어와 혼용하면 문제가 발생할 수 있다 (ref : https://seongjin.me/kubernetes-imparative-vs-declarative/)
    => 즉, 되도록이면 apply를 통해 오브젝트를 생성하고 관리하는 통일성을 가지는 것이 좋을 것 같다

 

Q6. Inspect the status of POD. Make sure it's running

 

Q7. Delete the elephant Pod. Once deleted, wait for the pod to fully terminate.


참고

1. 핵심만 콕 쿠버네티스 (3) - kubectl 기초 - Semantics