Notice
Recent Posts
Recent Comments
Link
«   2025/05   »
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Archives
Today
Total
관리 메뉴

전공공부

Resource Requirements 본문

Study/K8S

Resource Requirements

monitor 2023. 3. 19. 20:19

Pod는 모두 리소스가 필요합니다.

 

쿠버네티스 스케줄러가 이를 결정해서 포드와 노드에 사용 가능한 리소스를 배정합니다.

 

그래서, 애플리케이션 개발자 관점에서 이 주제는 Pod 내부 Cpu 불충분 문제를 해결 할 수 있을 듯합니다.

 

대표적인 리소스 부족으로 인한 Pending Pod 중 일부는 Insufficient cpu를 일으키고 Pending 되어집니다.

 


기본적인 Pod의 자원으로는 CPU : 0.5 , Memory : 256Mi를 차지합니다.

 

이것을 수정하기 위해서 아래와 같이 변경할 수 있습니다.

 

pod-definition.yaml

 

apiVersion: v1
kind: Pod
metadata:
name: simple
    labels:
     name: simple
spec:
  containers:
    - name: simple
      image: simple
      ports: 
        - containerPort: 8080
      resources: #단순히 이것을 추가하는 것으로 CPU, memory 사용량를 설정 할 수 있다
        request:
          memory: "1Gi"
          cpu: 1

Resource Limits

 

pod-definition-limits.yaml

 

apiVersion: v1
kind: Pod
metadata:
name: simple
    labels:
     name: simple
spec:
  containers:
    - name: simple
      image: simple
      ports: 
        - containerPort: 8080
      resources: #단순히 이것을 추가하는 것으로 CPU, memory 사용량를 설정 할 수 있다
        request:
          memory: "1Gi"
          cpu: 1
        limits: #메모리 및 CPU의 제한을 걸 수 있다.
          memory: "2Gi"
          cpu: 2

 

 

Docker의 컨테이너는 리미트 없이 늘어 날 수 있기 때문에 리미트를 걸 수 있습니다.

 

CPU는 Throttle이 걸려서 k8s 내부적으로 최대 리미트를 넘길 수 없는 상태로 Running 되어질 수 있으나 메모리는 k8s이 리미트를 넘기는 것을 확인하면 Pod를 종료시킨다.

'Study > K8S' 카테고리의 다른 글

Node Selectors & Node Affinity  (0) 2023.03.22
Taints And Tolerations  (0) 2023.03.19
Service Account  (2) 2023.03.19
Docker Security  (0) 2023.03.19
Secret  (0) 2023.03.03