brunch

You can make anything
by writing

C.S.Lewis

by Master Seo Sep 07. 2021

EKS 5탄-2. Cloud9생성과 EKS 생성

5탄 - 2/3


<1>  Cloud9 생성

<2>  Amazon EKS 클러스터 설치

<3>  대시보드 설치  - 선택

<4>  다음 과정

<20> (몰아보기) EKS 실습5




<1> Cloud9 생성



1

aws 웹콘솔 로그인

Cloud9 가서  생성

vpc가 있어야 cloud9 설치가능

cloud9 ec2 설치한 네트워크를 선택해야 하므로


or


Cloud Formation으로 EC2 한번에 설치 - Tools 까지 한번에 설치

https://brunch.co.kr/@topasvga/1814



2

ec2 keypair 생성



ec2 키페어  리전에 업로드

aws ec2 import-key-pair --key-name "eksworkshop" --public-key-material file://~/.ssh/id_rsa.pub



3

관련 툴 설치


eks에 명령내릴 kubectl  설치

mkdir -p ~/.kube

sudo curl --silent --location -o /usr/local/bin/kubectl "https://amazon-eks.s3-us-west-2.amazonaws.com/1.11.5/2018-12-06/bin/linux/amd64/kubectl"

sudo chmod +x /usr/local/bin/kubectl


IAM authenticator를 사용

https://docs.aws.amazon.com/ko_kr/eks/latest/userguide/install-aws-iam-authenticator.html

Amazon EKS는 IAM을 사용하여 Kubernetes 클러스터에 인증을 제공

Amazon EKS와 함께 사용할 수 있도록AWSKubernetes용 IAM authenticator를 사용


jq

sudo yum -y install jq



4

소스 준비

cd ~/environment

git clone https://github.com/brentley/ecsdemo-frontend.git

git clone https://github.com/brentley/ecsdemo-nodejs.git

git clone https://github.com/brentley/ecsdemo-crystal.git



5

admin role 생성

ec2에 admin role 부여



6

cloud9 사용시는

cloud9 에 임시 자격증명  off로 변경


기존 자격증명 파일 삭제

rm -vf ${HOME}/.aws/credentials



7

현재리전 변수로 저장

export AWS_REGION=$(curl -s 169.254.169.254/latest/dynamic/instance-identity/document | jq -r '.region')

echo "export AWS_REGION=${AWS_REGION}" >> ~/.bash_profile

aws configure set default.region ${AWS_REGION}

aws configure get default.region



8

iam 역할 확인

지정된 role로 들어가 있는가?

aws sts get-caller-identity



9

쿠버네티스 클러스터 설치를 위한 eksctl 설치

curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp

sudo mv -v /tmp/eksctl /usr/local/bin


eksctl version






<2>  Amazon EKS 클러스터 설치



1

설치

서버를 지정하지 않으면 m5.large로 설치 된다.


eksctl create cluster --name=eksworkshop-eksctl --nodes=3 --region=${AWS_REGION}


(20분 소요)



2

역할이름을 환경 변수로 저장


INSTANCE_PROFILE_PREFIX=$(aws cloudformation describe-stacks | jq -r '.Stacks[].StackName' | grep eksctl-eksworkshop-eksctl-nodegroup)


INSTANCE_PROFILE_NAME=$(aws iam list-instance-profiles | jq -r '.InstanceProfiles[].InstanceProfileName' | grep $INSTANCE_PROFILE_PREFIX)


ROLE_NAME=$(aws iam get-instance-profile --instance-profile-name $INSTANCE_PROFILE_NAME | jq -r '.InstanceProfile.Roles[] | .RoleName')


echo "export ROLE_NAME=${ROLE_NAME}" >> ~/.bash_profile




<3>  대시보드 설치  - 선택


kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/recommended/kubernetes-dashboard.yaml


개인 클러스터에 배포되기 때문에 프록시를 통해 접속

kubectl proxy --port=8080 --address='0.0.0.0' --disable-filter=true &



cloud9

Tools / Preview / Preview Running Application 을 클릭

url에 추가

/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/


터미널 실행

aws-iam-authenticator token -i eksworkshop-eksctl --token-only



이 명령의 출력을 복사하고 Token 옆에 라디오버튼을 클릭 하고, 아래 텍스트 필드에 복사한 마지막 명령의 출력을 붙여넣습니다.


Sign In 버튼




<4> 다음 과정


https://brunch.co.kr/@topasvga/1979





<20> (몰아보기) EKS 실습5탄


https://brunch.co.kr/@topasvga/1884


https://brunch.co.kr/@topasvga/1679



감사합니다.

매거진의 이전글 EKS 5탄-1. EKS 생성법

작품 선택

키워드 선택 0 / 3 0

댓글여부

afliean
브런치는 최신 브라우저에 최적화 되어있습니다. IE chrome safari