brunch

You can make anything
by writing

C.S.Lewis

by Master Seo Feb 22. 2023

15. 오라클 클라우드 - 쿠버네티스 - limit

<1>  최대 용량 제한 limit

<2> 하한선 보장  Request

<3> 삭제



<1>  최대 용량 제한 limit


1

topasvga@cloudshell:~ (ap-seoul-1)$ cat << EOF > limit-pod.yaml

> apiVersion: v1

> kind: Pod

> metadata:

>   name: limit-pod

> spec:

>   containers:

>   - name: ubuntu

>     image: ubuntu

>     command: ["tail"]

>     args: ["-f", "/dev/null"]

>     resources:

>       limits:

>         memory: "256Mi"

>         cpu: "250m"

> EOF



2

topasvga@cloudshell:~ (ap-seoul-1)$ kubectl apply -f limit-pod.yaml

pod/limit-pod created


3

topasvga@cloudshell:~ (ap-seoul-1)$ kubectl describe pod limit-pod | grep Limits -A 5

    Limits:

      cpu:     250m

      memory:  256Mi

    Requests:

      cpu:        250m

      memory:     256Mi


4

topasvga@cloudshell:~ (ap-seoul-1)$ kubectl get nodes

NAME          STATUS   ROLES   AGE     VERSION

10.0.10.141   Ready    node    7d21h   v1.25.4

10.0.10.80    Ready    node    7d21h   v1.25.4



5

topasvga@cloudshell:~ (ap-seoul-1)$ alias k=kubectl

topasvga@cloudshell:~ (ap-seoul-1)$ complete -F __start_kubectl k

topasvga@cloudshell:~ (ap-seoul-1)$ k get pod -o wide

NAME        READY   STATUS    RESTARTS   AGE     IP            NODE         NOMINATED NODE   READINESS GATES

limit-pod   1/1     Running   0          2m34s   10.244.0.75   10.0.10.80   <none>           <none>



6

topasvga@cloudshell:~ (ap-seoul-1)$ kubectl describe nodes 10.0.10.80

Name:               10.0.10.80

Roles:              node

Labels:             beta.kubernetes.io/arch=amd64

                    beta.kubernetes.io/instance-type=VM.Standard.E3.Flex

                    :

Non-terminated Pods:          (6 in total)

  Namespace Name    CPU Requests  CPU Limits  Memory Requests  Memory Limits  Age

  ---------    ----                  ------------  ----------  ---------------  -------------  ---

  default   limit-pod    250m (12%)    250m (12%)  256Mi (1%)       256Mi (1%)     3m10s

  kube-system   coredns-d95cc75c9-qkdt7  100m (5%)  0 (0%)   70Mi (0%) 170Mi (1%)     21h


Allocated resources:

  (Total limits may be over 100 percent, i.e., overcommitted.)

  Resource           Requests    Limits

  --------           --------    ------

  cpu                530m (26%)  2250m (112%)

  memory         510Mi (3%)    1482Mi (9%)

  ephemeral-storage  0 (0%)      0 (0%)

  hugepages-1Gi      0 (0%)      0 (0%)

  hugepages-2Mi      0 (0%)      0 (0%)

Events:              <none>



7

topasvga@cloudshell:~ (ap-seoul-1)$ kubectl delete -f limit-pod.yaml

pod "limit-pod" deleted




<2> 하한선 보장  Request


1

최소 사용량(하한선) 보장


topasvga@cloudshell:~ (ap-seoul-1)$ cat << EOF > request-limit-pod.yaml

> apiVersion: v1

> kind: Pod

> metadata:

>   name: request-limit-pod

> spec:

>   containers:

>   - name: ubuntu

>     image: ubuntu

>     command: ["tail"]

>     args: ["-f", "/dev/null"]

>     resources:

>       limits:

>         memory: "256Mi"

>         cpu: "250m"

>       requests:

>         memory: "128Mi"

>         cpu: "125m"

> EOF




2

topasvga@cloudshell:~ (ap-seoul-1)$ kubectl apply -f request-limit-pod.yaml

pod/request-limit-pod created


3

topasvga@cloudshell:~ (ap-seoul-1)$ kubectl describe pod request-limit-pod | grep Limits -A 5

    Limits:

      cpu:     250m

      memory:  256Mi

    Requests:

      cpu:        125m

      memory:     128Mi


4

파드가 생성된 노드가 어디인지 보자

topasvga@cloudshell:~ (ap-seoul-1)$ k get pod -o wide

NAME  READY  STATUS  RESTARTS AGE   IP NODE     NOMINATED NODE   READINESS GATES

request-limit-pod   1/1  Running   0    26s   10.244.0.76   10.0.10.80   <none>           <none>


5

node  상세 내용 보자

topasvga@cloudshell:~ (ap-seoul-1)$ k describe nodes 10.0.10.80

Name:               10.0.10.80

Roles:              node

Labels:             beta.kubernetes.io/arch=amd64

                    beta.kubernetes.io/instance-type=VM.Standard.E3.Flex

                   

:

  OS Image:                   Oracle Linux Server 8.6

  Operating System:           linux

  Architecture:               amd64

  Container Runtime Version:  cri-o://1.25.1-111.el8

  Kubelet Version:            v1.25.4

  Kube-Proxy Version:         v1.25.4

PodCIDR:                      10.244.0.0/25

PodCIDRs:                     10.244.0.0/25

ProviderID:                   ocid1.instance.oc1.ap-seoul-1.anuwgljr5srof4icr7w3nbsco4dl7pdbe6mkhgqdpgwv25pfxkfx6lrrhfjq

Non-terminated Pods:          (6 in total)

  Namespace  Name   CPU Requests  CPU Limits  Memory Requests  Memory Limits  Age

  ---------         ----                       ------------  ----------  ---------------  -------------  ---

  default    request-limit-pod   125m (6%)     250m (12%)  128Mi (0%)       256Mi (1%)     51s

  kube-system                 coredns-d95cc75c9-qkdt7    100m (5%)     0 (0%)      70Mi (0%)        170Mi (1%)     21h


Allocated resources:

  (Total limits may be over 100 percent, i.e., overcommitted.)

  Resource           Requests    Limits

  --------           --------    ------

  cpu                405m (20%)  2250m (112%)

  memory             382Mi (2%)  1482Mi (9%)

  ephemeral-storage  0 (0%)      0 (0%)

  hugepages-1Gi      0 (0%)      0 (0%)

  hugepages-2Mi      0 (0%)      0 (0%)

Events:              <none>



<4> 삭제


topasvga@cloudshell:~ (ap-seoul-1)$ kubectl delete -f request-limit-pod.yaml

pod "request-limit-pod" deleted

                    




감사합니다.


브런치는 최신 브라우저에 최적화 되어있습니다. IE chrome safari