본문 바로가기
kubernetes

Resource 제한

by 목씨 2020. 2. 27.

1. CPU, Memory  제한

Memory resource 

$ kubectl create deployment stress --image vish/stress

deployment.apps/stress created

 

$ kubectl get deployment stress -o yaml

$ kubectl get deployment stress --export -o yaml > stress.yaml

 

stress.yaml 파일에서 resource에 memory 값을 추가해준다

resources: 

  limits:

    memory: "2Gi"

  requests:

    memory: "1000Mi"

 

$ kubectl replace -f stress.yaml 

deployment.extensions/stress replaced

 

pod 로그 확인

$ kubectl logs stress-6b6f677bd6-tbc2m

I0227 13:28:33.926373       1 main.go:26] Allocating "0" memory, in "4Ki" chunks, with a 1ms sleep between allocations

I0227 13:28:33.926450       1 main.go:29] Allocated "0" memory

 

CPU resource

resources:

  limits:

    cpu: "1"

    memory: "2Gi"

  requests:

    cpu: "0.5"

    memory: "1000Mi"

args:

- -cpus

- "2"

- -mem-total

- "950Mi"

- -mem-alloc-size

- "100Mi"

- -mem-alloc-sleep

- "1s"

 

args : entry should be spaces to the same indent as resources

$ kubectl delete deployment stress

deployment.extensions "stress" deleted

 

$ kubectl create -f stress.yaml 

deployment.extensions/stress created

 

$ kubectl logs stress-5d6cb465bb-4vjz6

I0227 13:34:46.317320       1 main.go:26] Allocating "950Mi" memory, in "100Mi" chunks, with a 1s sleep between allocations

I0227 13:34:46.317473       1 main.go:39] Spawning a thread to consume CPU

I0227 13:34:46.317494       1 main.go:39] Spawning a thread to consume CPU

I0227 13:35:01.087943       1 main.go:29] Allocated "950Mi" memory

 

2. Namespace 리소스 제한

'kubernetes' 카테고리의 다른 글

simple application 배포  (0) 2020.02.27
kubernetes cluster 구성  (0) 2020.02.27