TheKoguryo's 기술 블로그

 Version 2024.04.01

1.2.5.2 Preemptible Capacity Node Pool 추가하기

Preemptible Node Pool 만들기

Node Pool 만들기

  1. OCI 콘솔에 로그인합니다.

  2. 대상 OKE 클러스터로 이동합니다.

  3. 클러스터 상세정보에서 Resources > Node Pools을 클릭합니다.

  4. Add node pool을 클릭합니다.

  5. 생성할 Node Pool의 기본 정보를 입력합니다.

    1. Name: pool-preemptible

    2. Node type: Managed

    3. Version: 예, v1.26.7

    4. Node Placement Configuration:

      • Worker Node가 위치할 서브넷 지정

      • Show advanced options > Capacity type에서 Preemptible capacity를 선택합니다.

        image-20240313165622065

    5. Shape and image: 기본 선택된 VM.Standard.E3.Flex를 선택합니다.

    6. Node count: 1

    7. Pod communication: Worker Node가 위치할 서브넷 지정

    8. 나머지 항목은 요건에 맞게 설정합니다.

    9. Add를 클릭하여 Node Pool을 추가합니다.

생성된 Node Pool 확인하기

  1. 생성된 Node를 조회해 봅니다.

    $ kubectl get nodes -L kubernetes.io/arch,name --sort-by='{.metadata.labels.name}'
    NAME          STATUS   ROLES   AGE   VERSION   ARCH    NAME
    10.0.10.158   Ready    node    18d   v1.26.7   amd64   oke-cluster-1
    10.0.10.42    Ready    node    10d   v1.26.7   amd64   oke-cluster-1
    10.0.10.43    Ready    node    10d   v1.26.7   amd64   oke-cluster-1
    10.0.10.248   Ready    node    8h    v1.26.7   arm64   pool-arm
    10.0.10.8     Ready    node    78m   v1.26.7   amd64   pool-preemptible
    
    • OKE 클러스터 상의 Node Pool 구성

      image-20240313171219031

  2. Preemptible 노드에는 생성시 기본적으로 taint가 걸려있습니다.

    $ kubectl describe node 10.0.10.8
    Name:               10.0.10.8
    Roles:              node
    Labels:             beta.kubernetes.io/arch=amd64
                        ...
                        oci.oraclecloud.com/oke-is-preemptible=true
                        ...
    ...
    Taints:             oci.oraclecloud.com/oke-is-preemptible:NoSchedule
    

Preemptible Node Pool에 우선하여 애플리케이션 배포하기

Preemptible 노드는 비용이 저렴한 대신, OCI가 필요한 경우, 임의로 종료하여, 자원을 회수해 갈 수 있습니다. 그래서 여기서는, Preemptible 노드에만 배포하게 설정하기보다는, Preemptible 노드에 우선하되, 다른 노드에도 배포될 수 있는 방법으로 설정하겠습니다.

  1. 앞선 배포 파일에 추가 설정을 합니다.

    • Preemptible 노드에도 배포될 수 있도록 taint에 대응하는 toleration을 설정합니다.

    • nodeAffinity중에서 perferered 옵션을 사용하여, preemptible 노드가 있는 경우 해당 노드에 우선 배포되고, preemptible 노드가 없는 경우 다른 노드에도 배포될 수 있도록 설정합니다.

    • 우선 배포외 다른 노드에도 배포되는 것을 확인하기 위해 Preemptible 노드의 CPU 자원을 초과하도록 resources.requests.cpu: 250m 추가합니다.

    # nginx.yaml
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: nginx-deployment
    spec:
      selector:
        matchLabels:
          app: nginx
      replicas: 10
      template:
        metadata:
          labels:
            app: nginx
        spec:
          containers:
          - name: nginx
            image: nginx:latest
            ports:
            - containerPort: 80
            resources:
              requests:
                cpu: 250m          
          tolerations:
          - key: "oci.oraclecloud.com/oke-is-preemptible"
            operator: "Exists"
            effect: "NoSchedule"                
          affinity:
            nodeAffinity:
              preferredDuringSchedulingIgnoredDuringExecution:
              - weight: 1
                preference:
                  matchExpressions:
                  - key: "oci.oraclecloud.com/oke-is-preemptible"
                    operator: In
                    values:
                    - "true"
    
  2. 다시 배포하고 배포된 Node를 확인합니다.

    • 대부분의 Pod가 우선 조건에 의해 Preemptible 노드인, 10.0.10.8 노드에서 실행중인 것을 볼 수 있습니다.
    $ kubectl get pod -o wide
    NAME                                READY   STATUS    RESTARTS   AGE   IP            NODE          NOMINATED NODE   READINESS GATES
    nginx-deployment-7bc559645f-2pzst   1/1     Running   0          15s   10.0.10.93    10.0.10.8     <none>           <none>
    nginx-deployment-7bc559645f-59zlg   1/1     Running   0          15s   10.0.10.174   10.0.10.8     <none>           <none>
    nginx-deployment-7bc559645f-7lpwb   1/1     Running   0          15s   10.0.10.224   10.0.10.8     <none>           <none>
    nginx-deployment-7bc559645f-8hd6n   1/1     Running   0          15s   10.0.10.231   10.0.10.8     <none>           <none>
    nginx-deployment-7bc559645f-bn2r4   1/1     Running   0          15s   10.0.10.14    10.0.10.43    <none>           <none>
    nginx-deployment-7bc559645f-czdg2   1/1     Running   0          15s   10.0.10.236   10.0.10.158   <none>           <none>
    nginx-deployment-7bc559645f-g792z   1/1     Running   0          15s   10.0.10.253   10.0.10.8     <none>           <none>
    nginx-deployment-7bc559645f-kh697   1/1     Running   0          15s   10.0.10.204   10.0.10.8     <none>           <none>
    nginx-deployment-7bc559645f-qrlv9   1/1     Running   0          15s   10.0.10.122   10.0.10.8     <none>           <none>
    nginx-deployment-7bc559645f-rbttb   1/1     Running   0          15s   10.0.10.29    10.0.10.42    <none>           <none>
    


이 글은 개인으로서, 개인의 시간을 할애하여 작성된 글입니다. 글의 내용에 오류가 있을 수 있으며, 글 속의 의견은 개인적인 의견입니다.

Last updated on 13 Mar 2024