📂
Amazon EKS
  • Amazon EKS
  • 워크스페이스 생성하기
    • Cloud9 IDE 환경 구성
    • IAM 역할 생성
    • SSH & CMK Key 생성하기
  • EKS 클러스터 구축
    • EKS 클러스터 만들기
  • 쿠버네티스 대시보드 배포
    • Kubernetes 공식 대시보드 배포
  • 마이크로서비스 배포
    • 예제 애플리케이션 배포
    • 서비스 스케일(Scaling)
    • 애플리케이션 정리하기
  • 애플리케이션 배포 - Helm
    • HELM 설치
    • Helm으로 Nginx 배포
    • Helm을 사용하여 마이크로서비스 배포
    • 정리하기
  • 리소스 관리 - POD 배치
    • NodeSelector
    • Affinity and Anti-affinity
    • 더 실용적인 사용 사례
    • 정리하기
  • 리소스 관리 - Health Checks
    • Liveness 프로브 구성
    • Readiness 프로브 구성
    • 정리하기
  • 리소스 관리 - AutoScaling
    • HPA 구성하기
    • CA 구성하기
    • 정리하기
  • 네트워킹 - 서비스 노출
    • 서비스와 애플리케이션 연결
    • 서비스에 접근하기
    • 서비스 노출
    • Ingress
    • Ingress Controller
    • 정리하기
  • 네트워크 - Calico 정책
    • Calico 설치하기
    • Stars Policy Demo
    • 정리하기
  • Updating 권한설정 - RBAC
    • 테스트 POD 설치
    • 사용자 생성 및 맵핑
    • 역할과 바인딩
    • 정리하기
  • Updating 권한설정 - IAM 그룹
    • IAM Role, Group & User 생성하기
    • RBAC 설정하기
    • EKS 엑세스 테스트
    • 정리하기
  • Updating 권한설정 - Service account
    • OIDC 자격 증명 공급자 생성하기
    • IAM 역할 생성 및 지정
    • 샘플 POD 배포
    • 정리하기
  • Updating - 네트워크 - POD Security Group
    • SG 생성하기
    • RDS 생성하기
    • CNI 구성하기
    • SG 정책
    • Pod 배포하기
    • 정리하기
  • Updating - 모니터링 - Prometheus and Grafana
    • Prometheus 배포하기
    • Grafana 배포하기
    • 정리하기(Optional)
  • Updating 모니터링 - X-Ray
    • X-Ray DaemonSet 배포하기
    • 샘플 마이크로서비스 배포
    • X-Ray console 확인
    • 정리하기(Optional)
  • Updating 모니터링 - Container Insights
    • 사전 준비
    • Container Insights 구성하기
    • 부하 테스트
    • Container Insights 확인하기
    • 정리하기(Optional)
  • Updating CD - Gitops with Flux
    • 사전 준비
    • Codepipeline
    • EKS에 배포
    • 정리하기
  • Updating Argo Rollouts
  • Updating Service Mesh - AWS App Mesh
    • Fargate 및 OBSERVABILITY 구성
    • Product Catalog App 배포
    • APP MESH 설치
    • Porting to APP MESH
    • Virtual Gateway 구성
    • Canary
    • Observability
  • Updating 버전 업그레이드 - EKS Cluster
    • Upgrade EKS control Plane
    • Upgrade EKS CORE ADD-ONs
    • Upgrade Managed Node Group
Powered by GitBook
On this page

Was this helpful?

  1. 리소스 관리 - POD 배치

더 실용적인 사용 사례

더 실용적인 사용 사례인 AntiAffinity는 ReplicaSets,StatefulSets,Deployments 등과 같이 더 높은 수준의 컬렉션과 함께 사용할 때 훨씬 더 유용 할 수 있습니다. 워크로드 세트가 함께 사용 되도록 쉽게 구성 할 수 있습니다. 파드는 동일하게 정의된 토폴로지(예 : 동일한 노드)에 위치 합니다.

1. 동일 노드에 배포

3개의 노드 클러스터에서 한개의 웹 애플리케이션에는 redis와 같은 인 메모리 캐시가 있습니다. 우리는 웹 서버가 가능한 한 캐시와 함께 배치 되기를 원합니다.

다음은 3개의 Replicaset과 app=store selector 레이블이 있는 간단한 redis 배포의 YAML 스니펫 입니다. 배포에는 스케줄러가 단일 노드에서 복제본을 함께 배치하지 않도록 구성된 ‘PodAntiAffinity’가 있습니다.

cat <<EoF > ~/environment/redis-with-node-affinity.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: redis-cache
spec:
  selector:
    matchLabels:
      app: store
  replicas: 3
  template:
    metadata:
      labels:
        app: store
    spec:
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
          - labelSelector:
              matchExpressions:
              - key: app
                operator: In
                values:
                - store
            topologyKey: "kubernetes.io/hostname"
      containers:
      - name: redis-server
        image: redis:3.2-alpine
EoF

아래의 웹 서버 배포의 YAML 에는 podAntiAffinity 및 podAffinity가 구성되어 있습니다. 이렇게 하면 스케줄러에 모든 복제본이 selector 레이블 app=store가 있는 파드와 같은 위치에 있음을 알립니다. 이렇게 하면 각 웹 서버 replica가 단일 노드에 함께 배치 되지 않습니다.

cat <<EoF > ~/environment/web-with-node-affinity.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: web-server
spec:
  selector:
    matchLabels:
      app: web-store
  replicas: 3
  template:
    metadata:
      labels:
        app: web-store
    spec:
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
          - labelSelector:
              matchExpressions:
              - key: app
                operator: In
                values:
                - web-store
            topologyKey: "kubernetes.io/hostname"
        podAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
          - labelSelector:
              matchExpressions:
              - key: app
                operator: In
                values:
                - store
            topologyKey: "kubernetes.io/hostname"
      containers:
      - name: web-app
        image: nginx:1.12-alpine
EoF

이 배포를 적용 해 보겠습니다.

kubectl apply -f ~/environment/redis-with-node-affinity.yaml
kubectl apply -f ~/environment/web-with-node-affinity.yaml

위의 두 배포를 생성하면 3개의 노드 클러스터가 아래와 같이 보일 것입니다.

node-1 - webserver-1 - cache-1

node-2 - webserver-2 - cache-2

node-3 - webserver-3 - cache-3

보는 것 처럼 웹 서버의 3개 복제본은 모두 예상대로 캐시와 함께 자동으로 배치 됩니다.

# We will use --sort-by to filter by nodes name
 kubectl get pods -o wide --sort-by='.spec.nodeName'

PreviousAffinity and Anti-affinityNext정리하기

Last updated 3 years ago

Was this helpful?