[EKS Study 1주차] EKS Cluster Yaml 배포 - eksctl
- -
CloudNet@ 팀의 가시다님께서 Leading 하시는 AEWS Study 1주차 도전과제 정리
이번 글에서는 EKS Cluster 설정을 YAML 파일로 만들어 eksctl 명령어를 통해 EKS Cluster 를 배포해보겠습니다.
EKS Cluster 를 생성하는 전체 YAML 파일과 해당 YAML 파일 구성 내용을 분리해서 살펴보도록 하겠습니다.
1. VPC 환경
- EKS Cluster 배포를 위한 VPC 환경은 다음과 같습니다.
2. Cluster Yaml 파일 생성
참고 문서
Creating and managing clusters - eksctl
Creating and managing clusters Creating a cluster Create a simple cluster with the following command: That will create an EKS cluster in your default region (as specified by your AWS CLI configuration) with one managed nodegroup containing two m5.large nod
eksctl.io
Config Yaml Schema 문서
Config file schema - eksctl
Config file schema Use eksctl utils schema to get the raw JSON schema.
eksctl.io
2.1. 구성 내용
- 기존 VPC 에 EKS Cluster 배포
- Managed On-Demand Node Group
- Managed Spot Node Group
- EKS Fargate 배포
- Public Subnet 에 EKS Cluster 배포
- Public EKS Endpoint 사용
2.2. 전체 cluster.yaml 내용
apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig
# General Cluster Information
metadata:
name: kimalarm-cluster
region: ap-northeast-2
version: "1.24"
# Use an Existing VPC
vpc:
id: vpc-0d81845169db439d4
subnets:
public:
ap-northeast-2a: { id: subnet-00eddf0c6a277c0de }
ap-northeast-2c: { id: subnet-0fb1c5ce04922724a }
private:
ap-northeast-2a: { id: subnet-0771bf66b3ed37ded }
ap-northeast-2c: { id: subnet-09c0da5808393597c }
clusterEndpoints:
publicAccess: true
# privateAccess: true
publicAccessCIDRs: ["0.0.0.0/0"]
managedNodeGroups:
# Ondemand Instance
- name: kimalarm-node-group
instanceType: t3.medium
desiredCapacity: 2
volumeSize: 20
ssh:
allow: true # will use ~/.ssh/id_rsa.pub as the default ssh key
# publicKeyPath: ~/.ssh/ec2_id_rsa.pub
# Spot Instance
- name: kimalarm-spot-node-group
instanceType: t3.medium
spot: true
desiredCapacity: 2
volumeSize: 20
# EKS Fargate Node
fargateProfiles:
- name: kimalarm-fargate-node
selectors:
- namespace: default
# labels:
# test: fargate-yes
# To enable all of the control plane logs, uncomment below:
# cloudWatch:
# clusterLogging:
# enableTypes: ["*"]
# KMS key used for envelope encryption of Kubernetes secrets
# secretsEncryption:
# keyARN: <KMS_CMK_ARN>
배포 명령어
eksctl create cluster -f cluster.yaml
2.3. cluster.yaml 분해 - Metadata
apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig
# General Cluster Information
metadata:
name: kimalarm-cluster
region: ap-northeast-2
version: "1.24"
- name : EKS Cluster Name
- region : EKS Cluster Region
- version : EKS Cluster Version
2.4. cluster.yaml 분해 - VPC
# Use an Existing VPC
vpc:
id: vpc-0d81845169db439d4
subnets:
public:
ap-northeast-2a: { id: subnet-00eddf0c6a277c0de }
ap-northeast-2c: { id: subnet-0fb1c5ce04922724a }
private:
ap-northeast-2a: { id: subnet-0771bf66b3ed37ded }
ap-northeast-2c: { id: subnet-09c0da5808393597c }
clusterEndpoints:
publicAccess: true
# privateAccess: true
publicAccessCIDRs: ["0.0.0.0/0"]
- id : EKS 를 배포할 기존 VPC ID
- subnets - public : EKS 를 배포할 Public Subnet
- subnets - private : EKS 를 배포할 Private Subnet
- clusterEndpoints : EKS API Server 의 엔드포인트 통신 방법 (Default : Public)
- publicAccess: 퍼블릭 통신 허용 (Default : true)
- privateAccess: 프라이빗 통신 허용 (Default : false)
- publicAccessCIDRs : 퍼블릭 엔드포인트를 사용할 경우, 접근 허용 CIDR
2.4. cluster.yaml 분해 - managedNodeGroups
managedNodeGroups:
# Ondemand Instance
- name: kimalarm-node-group
instanceType: t3.medium
desiredCapacity: 2
volumeSize: 20
ssh:
allow: true # will use ~/.ssh/id_rsa.pub as the default ssh key
# publicKeyPath: ~/.ssh/ec2_id_rsa.pub
# Spot Instance
- name: kimalarm-spot-node-group
instanceType: t3.medium
spot: true
desiredCapacity: 2
volumeSize: 20
- name : Node Group 이름
- instanceType : Node Instance 타입
- desiredCapacity : Node의 Auto Scaling Group Desired Capacity
- volumeSize : Node 볼륨 크기
- ssh : ssh 접속 허용 여부
- publicKeyPath : ssh 허용일 경우, 기본 경로가 아닌 곳에 ssh 키가 존재할 때 사용
- spot : Spot 인스턴스 사용 여부
On-Demand
Spot-Instance
2.5. cluster.yaml 분해 - fargateProfiles
# EKS Fargate Node
fargateProfiles:
- name: kimalarm-fargate-node
selectors:
- namespace: default
# labels:
# test: fargate-yes
- name : Fargate Profile 이름
- selectors : Fargate Pod 를 배포하기 위한 조건
- namespace : 특정 네임스페이스에 배포되는 Pod는 모두 Fargate 로 생성
- labels : 특정 Label 을 보유한 오브젝트는 모두 Fargate 로 생성
Namespace + labels 2개 모두 설정 시, 모든 조건이 충족하는 오브젝트만 Fargate 로 생성됩니다.
Fargate 배포 테스트
# Nginx Deployment 배포
kubectl create deployment nginx-deploy --image=nginx --replicas=10
# default namespace 확인
kubectl get pods -o wide
CLI 환경
AWS EKS 콘솔 > Resource
- 로그를 활성화 하지 않아 오류가 발생한 것을 확인할 수 있다.
- Fargate 는 Node 가 활성화 되어 있는 것이 아니기 때문에, 로깅이 굉장히 중요할 것으로 보인다.
2.6. cluster.yaml 분해 - secretsEncryption
# KMS key used for envelope encryption of Kubernetes secrets
secretsEncryption:
keyARN: <KMS_CMK_ARN>
- keyARN : EKS 암호화에 사용할 KMS Key ARN
3. Cluster 삭제
eksctl delete cluster -f cluster.yaml
이번에는 eksctl 명령어와 Cluster 구성 파일을 YAML 로 만들어 EKS 를 배포하는 법에 대해서 알아보았습니다.
다음 글에서는 EKS API Endpoint 에 대해서 좀 더 자세히 알아보겠습니다.
'AWS > EKS' 카테고리의 다른 글
[EKS Study 2주차] EKS Networking - Prefix Delegation (0) | 2023.05.07 |
---|---|
[EKS Study 1주차] EKS API 서버 Endpoint (0) | 2023.05.06 |
[EKS Study 1주차] EKS 설치 - eksctl (0) | 2023.04.30 |
[EKS Study 1주차] EKS 소개 (0) | 2023.04.30 |
[PKOS Study 5주차] k8s Security - RBAC (0) | 2023.04.07 |