크게 4단계로 나눌 수 있다.
1. EKS Workshop 시작하기
1) Cloud9 Environment (EKS workshop) 생성
2) Kubernetes Tools 설치
3) IAM Role 생성
4) IAM Role 적용
5) IAM 설정 업데이트
2. Eksctl을 이용해 cluster 시작하기
1) eksctl 설치
2) EKS cluster 생성
3) EKS cluster 테스트
3. Helm CLI 설치
1) Helm CLI 설치 전
2) Helm CLI 설치
4. WordPress 설치
1) WordPress 설치
2) WordPress 접속
거듭 강조했듯이, AWS 가이드가 제일 자세하고 정확하기 때문에 글의 하단에 참고 사이트를 확인하자.
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
명령이 작동하는지 확인한다.
eksctl version
eksctl completion bash >> ~/.bash_completion
. /etc/profile.d/bash_completion.sh
. ~/.bash_completion
주의사항
- 1장 맨 마지막 단계인 IAM Role 유효성 검사를 한 후 이 단계를 진행한다.
- 왜? EKS cluster가 IAM Role을 사용해 구축되지 않으면 이후 모듈에 필요한 kubectl 명령 실행 불가
- EKS 1.17을 배포하려면 eksctl 버전 0.24.0 이상이어야 한다.
- 최신 버전 설치 : 링크 클릭
배포 파일(YAML파일) 구문에 대해서는 따로 포스팅을 할 것이다.
cat << EOF > eksworkshop.yaml
---
apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig
metadata:
name: eksworkshop-eksctl
region: ${AWS_REGION}
version: "1.17"
managedNodeGroups:
- name: nodegroup
desiredCapacity: 3
ssh:
allow: true
publicKeyName: eksworkshop
# To enable all of the control plane logs, uncomment below:
# cloudWatch:
# clusterLogging:
# enableTypes: ["*"]
secretsEncryption:
keyARN: ${MASTER_ARN}
EOF
eksworkshop.yaml
을 eksctl cluster
을 생성할 때 입력한다.
eksctl create cluster -f eksworkshop.yaml
EKS 및 모든 dependency를 시작하는데 약 15분이 소요된다.
kubectl get nodes # if we see our 3 nodes, we know we have authenticated correctly
이상이 없다면 아래와 같이 출력된다.
STACK_NAME=$(eksctl get nodegroup --cluster eksworkshop-eksctl -o json | jq -r '.[].StackName')
ROLE_NAME=$(aws cloudformation describe-stack-resources --stack-name $STACK_NAME | jq -r '.StackResources[] | select(.ResourceType=="AWS::IAM::Role") | .PhysicalResourceId')
echo "export ROLE_NAME=${ROLE_NAME}" | tee -a ~/.bash_profile
Helm CLI에 관해 이해하기 쉽게 정리한 글이 있어 하단에 링크를 남기겠다.
curl -sSL https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
helm version --short
첫번째로, Chart 리포지토리를 구성한다.
Chart 리포지토리는 Linux에서의 APT 또는 yum 리포지토리와 비슷하거나 macOS에서 Homebrew용 Taps와 유사하다.
stable 리포지토리를 다운로드한다.
helm repo add stable https://kubernetes-charts.storage.googleapis.com/
설치한 후엔 설치할 수 있는 charts 를 나열할 수 있다.
helm search repo stable
helm completion bash >> ~/.bash_completion
. /etc/profile.d/bash_completion.sh
. ~/.bash_completion
source <(helm completion bash)
bitnami charts 레포지토리를 사용해 WordPress를 EKS cluster에 설치한다.
Cloud9 Workspace 터미널에선 아래와 같은 명령을 실행해 WordPress 및 해당 데이터베이스를 배포하면 된다.
# Create a namespace wordpress
kubectl create namespace wordpress-cwi
# Add the bitnami Helm Charts Repository
helm repo add bitnami https://charts.bitnami.com/bitnami
# Deploy WordPress in its own namespace
helm -n wordpress-cwi install understood-zebu bitnami/wordpress
위의 chart가 생성한 것
- 2개의 persistent volumes
- 다수의 secrets
- MariaDB를 위한 1개의 StatefulSet
- WordPress를 위한 1개의 배포
kubectl -n wordpress-cwi rollout status deployment understood-zebu-wordpress
WordPress 사이트의 URL을 출력한다.
export SERVICE_URL=$(kubectl get svc -n wordpress-cwi understood-zebu-wordpress --template "{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}")
echo "Public URL: http://$SERVICE_URL/"
위에 출력된 URL로 들어가보면 샘플 템플릿이 적용된 WordPress 사이트가 나온다.
위의 상태로는 관리자 페이지로 들어갈 수 없다.
관리자 URL과 패스워드를 설정해준다.
export ADMIN_URL="http://$SERVICE_URL/admin"
export ADMIN_PASSWORD=$(kubectl get secret --namespace wordpress-cwi understood-zebu-wordpress -o jsonpath="{.data.wordpress-password}" | base64 --decode)
echo "Admin URL: http://$SERVICE_URL/admin
Username: user
Password: $ADMIN_PASSWORD
"
위에서 출력된 Admin URL을 들어가면 다음 화면이 표시된다.
Username or Email Address : user
Password : 위에 출력된 비밀번호
로그인 이후 아래와 같은 화면으로 이동됐다면 EKS cluster에서 MariaDB가 지원하는 Wordpress 설치를 성공적으로 실행한 것이다.
박수치자. 끝났다.🤣 피드백 환영합니다! 🚀