# EKS 설치 밒 마스터, 워커 노드 구성
https://aws.amazon.com/ko/cli/
https://gitforwindows.org/ git for windows (bash) // checkout as-is, commit as-is
host PC에서 win+R ->sysdm.cpl->고급->환경 변수->시스템 변수->path선택 편집->%USERPROFILE%\k8s\bin 추가
cmd에서 path에 %USERPROFILE%\k8s\bin 경로가 보이는지 확인
https://github.com/weaveworks/eksctl/releases/tag/v0.145.0-rc.0 // eksctl.exe 설치 후 bin 폴더로 복사
https://www.downloadkubernetes.com/ // kubectl.exe 설치 후 bin 폴더로 복사
https://www.docker.com/products/docker-desktop/ // Docker Desktop GUI 설치 후 Use WSL 2 해제
aws IAM 계정 생성 // 마스터 노드를 관리할 수 있는 권한을 가진 계성을 생성
IAM ->사용자 계정 생성->administratorAccess 체크 후 생성
CLI 체크
액세스 키 .CSV 파일로 다운로드 or 액세스키, 비밀 액세스 키 따로 복사하여 저장
pwd
cd /c/Users/keduit/k8s/bin
ls // 설치한 eksctl.exe, kubectl.exe 두개 확인
ekctl version // 0.145.0 확인
kubectl version // v5.0.1 확인
docker login // docker hub계정
aws configure // shell 에서 aws configure 설정
xxxxxxx // aws access key id
xxxxxxxxxxxxxxxxxxxxxxxxxxxx // aws secret access key
ap-northeast-2 // default region name
json // default output format
=> 이제부터 eks-kchl1216 을 master node의 권한 계정으로 사용가능 하다.
EC2 등 서비스를 YAML 파일로 정의 한것을 스택이라한다.
CloudFormation으로 스택을 생성할 수 있다. 리소스 관리 등
스택 생성을 위해 k8s_code.zip 압축 푼 후 k8s 폴더에 복사
01_base_resources_cfn.yaml 파일 선택
가용영역 3개와 3개의 subnet 대역 확인할 수 있음. 불러온 yaml파일에 정의되어있는 내용이다.
출력->Workersubnets 값으로 node 와의 연결 네트워크로 사용
eksctl create cluster --vpc-public-subnets [WorkSubnets값] --name eks-work-cluster --region ap-northeast-2 --version 1.27 --nodegroup-name eks-work-nodegroup --node-type t2.small --nodes 2 --nodes-min 2 --nodes-max 5
kubectl get nodes // node 2개 확인
cd k8s/k8s-aws-eks
cd eks-env
ls -ltr
vi 02_nginx_k8s.yaml // docker desktop이 실행중이지 않으면 image에 nginx를 설치할 수 없음
kubectl apply -f 02_nginx_k8s.yaml
kubectl get pods // 0/1의 nginx-pod 확인
kubectl port-forward nginx-pod 8080:80 // service 없이 port-forward로 접근하는 방법이다.
pod는 container가 1개이상이므로 '-' 로 시작하면 배열을 의미한다. 그래서 contrainers 라고 복수개로 지칭한다.
cd ..
cd ..
cd k8s_cod2/wordpress
vi wordpress.yaml
kubectl create secret generic mysql-pass --from-file=./password.txt
kubectl get secret
kubectl describe secret mysql-pass
kubectl create -f local-volume.yaml
kubectl get pv
vi mysql.yaml
aws_account_id.dkr.ecr.<region>.amazonaws.com/<imagename:tag> // 사설 레지스트리에 해당 image가 존재해야한다.
605114111217 .dkr.ecr.ap-northeast-2.amazonaws.com/mysql:5.6 //
# AWS 사설레지스트리에 이미지 올리기
docker login
docker push(pull) 605114111217.dkr.ecr.ap-
northeast-2.amazonaws.com/mysql:5.6
# 컨테이너 여러 개를 포함한 파드의 특징
- 로컬 호스트로 서로 통신 가능
- 스토리지(볼륨) 공유 기능
- 사이트 카
#AWS ECR로 프라이빗 이미지 저장소 생성하기
AWS ECR은 컨테이너 이미지를 저장, 관리, 공유 및 배포할 수 있는 완전관리형 컨테이너 레지스트리이다.
이는 Docker Hub 역할을 한다.
aws iam->사용자->계정클릭->권한 추가->AmazonEC2containerRegistryFullAccess // 사설 레지스트리에 풀 액세스할 수 있는 권한
* ECR에 Docker CLI을 인증하는 과정을 거쳐야 Docker ECR에 이미지를 Push할 수 있다.
aws_account_id.dkr.ecr.ap-northeast-2.amazonaws.com/ 은 ECR의 URL이다.
aws ecr get-login-password --region ap-northeast-2 | docker login --username AWS --password-stdin xxxxxxxxxxxx.dkr.ecr.ap-northeast-2.amazonaws.com
# 프라이빗 레포지토리 생성하기
aws container registy->repositories 생성
docker login
docker pull mysql:5.6
docker pull wordpress:latest
docker images // wordpress와 mysql 확인, 내 프라이빗 레포에 저장할 두 이미지를 생성함
docker tag mysql:5.6 605114111217.dkr.ecr.ap-northeast-2.amazonaws.com/kchl1216:mysql56
docker tag wordpress:latest 605114111217.dkr.ecr.ap-northeast-2.amazonaws.com/kchl1216:wordpress.latest
댓글남기기