☁️ 클라우드

EKS

Elastic Kubernetes Service

AWS 관리형 Kubernetes. 컨트롤 플레인 자동 관리. Fargate 통합.

상세 설명

Amazon EKS(Elastic Kubernetes Service)는 AWS에서 제공하는 완전 관리형 Kubernetes 서비스입니다. 컨트롤 플레인(API 서버, etcd, 스케줄러)을 AWS가 관리해주므로 운영 부담 없이 프로덕션 급 Kubernetes를 사용할 수 있습니다.

EKS의 핵심 구성 요소:

  • 컨트롤 플레인: AWS가 3개 AZ에 분산 배치하여 99.95% SLA 보장. 시간당 $0.10 과금
  • 데이터 플레인(워커 노드): EC2 관리형 노드 그룹, 자체 관리형, 또는 Fargate 선택 가능
  • EKS Addons: CoreDNS, kube-proxy, VPC CNI 등 AWS 관리형 애드온 제공
  • EKS Anywhere: 온프레미스에서도 동일한 EKS 경험 제공

노드 타입 비교:

  • 관리형 노드 그룹: AWS가 EC2 프로비저닝/업데이트 자동화. 가장 권장
  • Fargate: 서버리스, Pod 단위 과금. 운영 부담 최소화
  • 자체 관리형: EC2 직접 관리. GPU, 특수 AMI 필요 시 사용

코드 예제

# eksctl로 EKS 클러스터 생성 (가장 간단한 방법) eksctl create cluster \ --name my-cluster \ --version 1.29 \ --region ap-northeast-2 \ --nodegroup-name standard-workers \ --node-type t3.medium \ --nodes 3 \ --nodes-min 2 \ --nodes-max 5 \ --managed # Fargate 프로파일 추가 eksctl create fargateprofile \ --cluster my-cluster \ --name fp-default \ --namespace default # 스팟 인스턴스 노드 그룹 추가 (비용 절감) eksctl create nodegroup \ --cluster my-cluster \ --name spot-workers \ --node-type t3.large \ --nodes 3 \ --spot \ --instance-types t3.large,t3a.large,m5.large # AWS Load Balancer Controller 설치 eksctl create iamserviceaccount \ --cluster=my-cluster \ --namespace=kube-system \ --name=aws-load-balancer-controller \ --attach-policy-arn=arn:aws:iam::aws:policy/ElasticLoadBalancingFullAccess \ --override-existing-serviceaccounts \ --approve # 클러스터 삭제 eksctl delete cluster --name my-cluster --region ap-northeast-2
# Terraform EKS 클러스터 구성 module "eks" { source = "terraform-aws-modules/eks/aws" version = "~> 20.0" cluster_name = "my-cluster" cluster_version = "1.29" cluster_endpoint_public_access = true vpc_id = module.vpc.vpc_id subnet_ids = module.vpc.private_subnets # 클러스터 애드온 cluster_addons = { coredns = { most_recent = true } kube-proxy = { most_recent = true } vpc-cni = { most_recent = true } } # 관리형 노드 그룹 eks_managed_node_groups = { # 일반 워크로드용 general = { instance_types = ["t3.medium"] capacity_type = "ON_DEMAND" min_size = 2 max_size = 10 desired_size = 3 labels = { workload = "general" } } # 스팟 인스턴스 (비용 절감) spot = { instance_types = ["t3.large", "t3a.large", "m5.large"] capacity_type = "SPOT" min_size = 0 max_size = 10 desired_size = 2 labels = { workload = "spot" } taints = [{ key = "spot" value = "true" effect = "NO_SCHEDULE" }] } } # Fargate 프로파일 fargate_profiles = { kube_system = { name = "kube-system" selectors = [ { namespace = "kube-system" } ] } } tags = { Environment = "production" Terraform = "true" } } # IRSA (IAM Roles for Service Accounts) module "irsa_s3" { source = "terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks" version = "~> 5.0" role_name = "my-app-s3-role" oidc_providers = { main = { provider_arn = module.eks.oidc_provider_arn namespace_service_accounts = ["default:my-app"] } } role_policy_arns = { s3_read = "arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess" } }
# kubeconfig 업데이트 aws eks update-kubeconfig \ --region ap-northeast-2 \ --name my-cluster # 클러스터 정보 확인 kubectl cluster-info kubectl get nodes -o wide # EKS 네임스페이스별 Pod 배치 확인 kubectl get pods -A -o wide # EKS에서 ALB Ingress 사용 cat <<EOF | kubectl apply -f - apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: my-app-ingress annotations: kubernetes.io/ingress.class: alb alb.ingress.kubernetes.io/scheme: internet-facing alb.ingress.kubernetes.io/target-type: ip spec: rules: - http: paths: - path: / pathType: Prefix backend: service: name: my-app port: number: 80 EOF # IRSA로 Pod에 AWS 권한 부여 cat <<EOF | kubectl apply -f - apiVersion: v1 kind: ServiceAccount metadata: name: my-app annotations: eks.amazonaws.com/role-arn: arn:aws:iam::123456789:role/my-app-s3-role --- apiVersion: apps/v1 kind: Deployment metadata: name: my-app spec: replicas: 3 selector: matchLabels: app: my-app template: metadata: labels: app: my-app spec: serviceAccountName: my-app # IRSA 연결 containers: - name: app image: my-app:latest # AWS SDK가 자동으로 IRSA 자격 증명 사용 EOF # 노드 그룹 스케일링 kubectl scale deployment my-app --replicas=10

실무 대화 예시

클러스터 선택 회의
"EKS vs 자체 구축 Kubernetes 어떤 게 좋을까요?" "운영 인력이 3명 이하면 EKS 강력 추천합니다. 컨트롤 플레인 관리, 업그레이드, 보안 패치를 AWS가 다 해줘요. 시간당 $0.10(월 약 $72)이 비싸 보여도 SRE 인건비 생각하면 훨씬 저렴합니다. 대신 워커 노드 비용은 EC2 요금 그대로 나가요."
비용 최적화 논의
"EKS 노드 비용을 줄이고 싶은데 방법이 있나요?" "세 가지 전략이 있습니다. 첫째, 관리형 노드 그룹에 스팟 인스턴스 섞어 쓰면 최대 90% 절감됩니다. Karpenter 설치하면 자동으로 최적 스팟 타입 선택해줘요. 둘째, Fargate는 Pod 단위 과금이라 트래픽 변동 큰 서비스에 유리합니다. 셋째, Cluster Autoscaler로 야간/주말 노드 축소하세요."
보안 설계 리뷰
"EKS에서 AWS 서비스 접근 권한은 어떻게 주나요?" "IRSA(IAM Roles for Service Accounts)를 사용하세요. Pod에 직접 IAM Role을 연결하는 방식이라 Access Key 노출 위험이 없어요. ServiceAccount에 annotation으로 Role ARN 지정하면 SDK가 자동으로 토큰 교환합니다. 절대 Access Key를 Secret에 넣지 마세요."
면접 질문
"EKS와 ECS의 차이점은 뭔가요?" "ECS는 AWS 네이티브 컨테이너 오케스트레이터라 AWS 서비스와 통합이 더 쉽고 학습 곡선이 낮아요. EKS는 표준 Kubernetes라 멀티 클라우드/하이브리드에 유리하고, Helm, Istio 같은 CNCF 생태계를 그대로 쓸 수 있습니다. 팀이 이미 K8s 경험 있으면 EKS, 없으면 ECS로 시작하는 게 일반적이에요."

주의사항

⚠️
클러스터 업그레이드: EKS는 K8s 마이너 버전을 14개월만 지원합니다. 업그레이드 계획 없이 방치하면 지원 종료됩니다. 분기별 업그레이드 일정을 수립하세요.
⚠️
VPC CNI IP 고갈: EKS의 VPC CNI는 Pod마다 ENI Secondary IP를 할당합니다. /24 서브넷(254개 IP)은 금방 고갈되니 /20 이상으로 설계하거나 Prefix Delegation 활성화하세요.
⚠️
aws-auth ConfigMap: 노드 IAM Role과 사용자 접근 권한은 kube-system/aws-auth ConfigMap에서 관리됩니다. 실수로 삭제하면 클러스터 접근이 차단될 수 있으니 백업 필수입니다.
⚠️
Fargate 제약사항: Fargate는 DaemonSet 불가, GPU 미지원, 최대 4 vCPU/30GB 메모리 제한이 있습니다. 모니터링 에이전트는 사이드카로 배포하세요.

관련 용어

더 배우기