AWS

[AWS] EKS 접근 설정

비번변경 2023. 1. 9. 09:51

개요

이미 생성되어 있는 EKS에 접속할 수 있도록 설정해보려고 한다.

EKS에 접근하기 위해서는 다음과 같은 사항이 필요하다.

  • aws cli : eks는 버전 2에서만 지원한다.
  • EKS 클러스터 접근 권한이 부여된 IAM 사용자 또는 역할
  • kubectl

 

방법은 다음과 같다.

 

 

권한 설정 및 확인

aws profile을 등록하고, 접근할 EKS 클러스터의 정보를 조회할 수 있는지 확인한다.

# profile 등록
aws configure

# 클러스터 목록 확인
aws eks list-clusters \
    --profile <PROFILE_NAME> --region ap-northeast-2
    
# 클러스터 정보 확인
aws eks describe-cluster \
    --name <EKS_CLUSTER_NAME> \
    --profile <PROFILE_NAME> --region ap-northeast-2

 

describe-cluster 명령 실행 결과

{
    "cluster": {
        "name": "devel",
        "arn": "arn:aws:eks:us-west-2:012345678910:cluster/devel",
        "createdAt": 1527807879.988,
        "version": "1.10",
        "endpoint": "https://EXAMPLE0A04F01705DD065655C30CC3D.yl4.us-west-2.eks.amazonaws.com",
        "roleArn": "arn:aws:iam::012345678910:role/eks-service-role-AWSServiceRoleForAmazonEKS-J7ONKE3BQ4PI",
        "resourcesVpcConfig": {
            "subnetIds": [
                "subnet-6782e71e",
                "subnet-e7e761ac"
            ],
            "securityGroupIds": [
                "sg-6979fe18"
            ],
            "vpcId": "vpc-950809ec"
        },
        "status": "ACTIVE",
        "certificateAuthority": {
            "data": "EXAMPLES0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo="
        }
    }
}

 

 

kubeconfig 등록

aws eks update-kubeconfig는 Amazon EKS 클러스터에 연결할 수 있도록 kubectl을 구성한다. 명령어 실행 전에 이미 kubectl이 설치되어 있어야 한다.

aws eks update-kubeconfig \
    --name <EKS_CLUSTER_NAME> \
    --profile <PROFILE_NAME> --region ap-northeast-2
    
# 실행 결과
Added new context arn:aws:eks:us-west-2:012345678910:cluster/example to /Users/ericn/.kube/config

 

kubectl config를 이용해 context 설정이 추가되었는지 확인한다.

kubectl config get-contexts

 

클러스터 내 리소스 등을 조회해본다.

kubectl get all --all-namespaces

 

 

참고 문서

https://may9noy.tistory.com/671

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

 

728x90