create-cluster.yaml 파일 생성

mkdir k8s-repo
cd k8s-repo
cat <<EOF > create-cluster.yaml
apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig

metadata:
  name: <cluster-name>
  region: ap-northeast-2
  version: "1.29"

vpc:
  subnets:
    private:
      ap-northeast-2a: { id: <private-subnet-id> }
      ap-northeast-2c: { id: <private-subnet-id> }

managedNodeGroups:
  - name: <nodegroup-name>
    instanceType: t3.medium
    instanceName: <nodegroup-ec2-name>
    volumeSize: 20
    ssh:
      allow: true
      sourceSecurityGroupIds: ["<nodegroup-sg-id>"]
    minSize: 2
    desiredCapacity: 2
    maxSize: 3
    labels: { type: eks-node }
    privateNetworking: true
    iam:
      withAddonPolicies:
        albIngress: true
        cloudWatch: true
iam:
  withOIDC: true
EOF

❗notepad 또는 메모장에 yaml 파일 붙여넣고 수정하기

Untitled

Untitled

내꺼

apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig

metadata:
  name: etech-eks
  region: ap-northeast-2
  version: "1.29"

vpc:
  subnets:
    private:
      ap-northeast-2a: { id: subnet-0133f64ee42239924 }
      ap-northeast-2c: { id: subnet-0e93a25ca7d34ae47 }

managedNodeGroups:
  - name: etech-eks-ng
    instanceType: t3.medium
    instanceName: etech-eks-ng-ec2
    volumeSize: 20
    ssh:
      allow: true
      sourceSecurityGroupIds: ["sg-02462fd637fdc1515"]
    minSize: 2
    desiredCapacity: 2
    maxSize: 3
    labels: { type: eks-node }
    privateNetworking: true
    iam:
      withAddonPolicies:
        albIngress: true
        cloudWatch: true
iam:
  withOIDC: true

클러스터 배포 및 확인

eksctl create cluster -f create-cluster.yaml

Untitled

❗key pair를 찾을 수 없다라는 에러가 보이면 아래 명령어를 활용 (ng key-pair 없어서 생긴 에러)

ssh-keygen 
# enter 세번 (default 값 생성)
# (참고) 만들어진 key-pair를 AWS console로 옮기고 싶다면...
aws ec2 import-key-pair --public-key-material fileb://~/.ssh/id_rsa.pub  --key-name <nodegrp-key-name>
# 키 생성 후 재시도
eksctl create cluster -f create-cluster.yaml
# 생성된 클러스터 노드 그룹 확인
kubectl get node

Untitled

AWS console

AWS console