본문 바로가기
AWS

AWS EKS NodeSelector 설정하기

by parkjp 2024. 2. 19.

서론

Kubernetes에는 특정 노드에 특정 pod를 띄울 수 있도록 설정할 수 있습니다.

taint와 tolerations, nodeAffinitiy, podAffinity등이 있지만 이번에는 NodeSelector를 사용하여 특정 노드에 pod를 배포하는 방법을 알아보도록 하겠습니다.

 

반응형

Node Label 설정하기

우선 노드 or 노드 그룹에 label을 설정해야합니다.

 

EKS 노드그룹에 label을 설정하는 방법은 콘솔에서 노드그룹을 클릭하여 편집으로 들어가서 설정할수도 있고,

아래 cli로도 설정이 가능합니다.

 

https://docs.aws.amazon.com/cli/latest/reference/eks/update-nodegroup-config.html

 

update-nodegroup-config — AWS CLI 1.32.44 Command Reference

Note: You are viewing the documentation for an older major version of the AWS CLI (version 1). AWS CLI version 2, the latest major version of AWS CLI, is now stable and recommended for general use. To view this page for the AWS CLI version 2, click here. F

docs.aws.amazon.com

 

 

NodeSelector 설정하기

Deployment로 예를 들어보겠습니다.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: test-app
  labels:
    app: test-app
spec:
  replicas: 1
  selector:
    matchLabels:
      app: test-app
  template:
    metadata:
      labels:
        app: test-app
    spec:
      containers:
       - name: test-app
         image: test-image:latest
         imagePullPolicy: Always
         ports:
          - containerPort: 8080
      nodeSelector:
        test: testValue

 

NodeSelector에 test라는 키와 testValue라는 값을 설정했습니다.

위 label에서 똑같이 키가 test이고 값이 testValue라는 label을 설정했다면 해당 노드 or 노드그룹에 test-app pod가 배포될 것 입니다.

 

 

반응형