# GitHub Actions 사용 1 # Cloudformation으로 명령 EC2 1대 생성 # role 부여 aws s3 ls 2 mkdir 2 cd 2 # 쿠버네티스 생성하기 # cluster.yaml 파일 생성 cat < cluster.yaml apiVersion: eksctl.io/v1alpha5 kind: ClusterConfig metadata: name: my-eks-cluster region: ap-northeast-2 managedNodeGroups: - name: standard-nodes instanceType: t3.small desiredCapacity: 3 volumeSize: 20 EOF # 클러스터 생성 (약 15분 소요) eksctl create cluster -f cluster.yaml 3 # EC2 재 로그인 k get no -bash: k: command not found [root@mgmt-server 2]# k get no -bash: k: command not found k get no NAME STATUS ROLES AGE VERSION ip-192-168-23-166.ap-northeast-2.compute.internal Ready 2m v1.34.4-eks-f69f56f ip-192-168-42-111.ap-northeast-2.compute.internal Ready 2m4s v1.34.4-eks-f69f56f ip-192-168-80-229.ap-northeast-2.compute.internal Ready 2m2s v1.34.4-eks-f69f56f watch -d kubectl get no,svc,pods,deploy,rs 4 # 터미널2 1. IAM 사용자 및 권한 설정 (로컬 실행) GitHub Actions가 AWS에 접근할 수 있도록 권한이 있는 IAM User의 자격 증명이 필요합니다. # GitHub Actions용 IAM 사용자 생성 (이미 있다면 생략 가능) aws iam create-user --user-name github-action-user # 관리자 권한 부여 (실습용이며, 운영 시에는 최소 권한 원칙 권장) aws iam attach-user-policy --user-name github-action-user --policy-arn arn:aws:iam::aws:policy/AdministratorAccess # 액세스 키 생성 (출력되는 AccessKeyId와 SecretAccessKey를 따로 저장하세요) aws iam create-access-key --user-name github-action-user "AccessKey": { "UserName": "github-action-user", "AccessKeyId": "AKIA2ESLMQMH4ZNMPPUF", "Status": "Active", "SecretAccessKey": "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", "CreateDate": "2026-04-10T02:44:33+00:00" } AKIA2ESLMQMH4ZNMPPUF 8MvW78kcE7yckdpqsp7lTbzKjPwyqKoA7/TJBv9p -------- 2. GitHub Secrets 설정 # GitHub 사이트 접속 # GitHub 저장소(Settings ->왼쪽 Secrets and variables -> Actions)에 다음 항목을 등록합니다. New repository secret 버튼을 누릅니다. Name과 Secret을 입력합니다. (보통 아래와 같이 저장합니다.) AWS_ACCESS_KEY_ID : 위에서 생성한 ID AWS_SECRET_ACCESS_KEY : 위에서 생성한 Secret Key 3. GitHub Actions 워크플로우 파일 생성 이 명령어를 복사해서 터미널에 붙여넣으면 로컬 디렉토리에 .github/workflows/deploy.yaml 파일이 생성됩니다. cd cd 2 mkdir -p .github/workflows cat < .github/workflows/deploy.yaml name: EKS Connection Test on: push: branches: [ main ] jobs: test-connection: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v3 - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v2 with: aws-access-key-id: \${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: \${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-region: ap-northeast-2 - name: Update Kubeconfig run: | aws eks update-kubeconfig --region ap-northeast-2 --name my-eks-cluster - name: Check EKS Nodes run: | kubectl get nodes EOF 참고: \${{ ... }} 부분의 백슬래시(\)는 cat 명령어 실행 시 변수가 로컬 터미널에서 해석되지 않도록 방지하기 위함입니다. 파일이 생성된 후에는 정상적인 ${{ }} 형태로 저장됩니다. 4. EKS 권한 업데이트 (RBAC) EKS는 IAM User가 클러스터를 만들었더라도, 다른 IAM Identity(GitHub Actions용 User)가 접근하려면 aws-auth ConfigMap에 등록해주어야 합니다. # GitHub Action 유저에게 EKS 접근 권한 부여 eksctl create iamidentitymapping \ --cluster my-eks-cluster \ --region ap-northeast-2 \ --arn arn:aws:iam::$(aws sts get-caller-identity --query Account --output text):user/github-action-user \ --group system:masters \ --username github-action-user ------------------ 5. 실행 및 확인 이제 코드를 GitHub에 푸시하면 끝입니다! # 1. 현재 폴더를 Git 저장소로 초기화 (.git 폴더 생성) git init # 2. 브랜치 이름을 main으로 설정 (GitHub 기본값) git branch -M main # 3. 원격 저장소 주소 다시 등록 git remote add origin https://github.com/topasvga1/s1.git # 4. 등록 확인 (주소가 보이면 성공) git remote -v git add . git commit -m "Change site color to yellow" git push origin main 오른위 계정 > Setting > developer > pat > tockers (classic) > seo # 강제 입력 topasvga1 ghp_VivqDhB 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 -------------- # 트러블 슈팅 # 용량이 큰 경우 안된다. 줄여서 올리자.2 Step 1: 기존 Git 설정 초기화 # 1. 기존 Git 설정 삭제 rm -rf .git # 2. Git 다시 초기화 git init # 3. 브랜치 이름을 main으로 변경 git branch -M main 2 # Step 2: .gitignore 확인 및 파일 추가 # .terraform 폴더가 제외되는지 다시 한번 확인합니다. # .gitignore 파일 생성 (없을 경우) cat < .gitignore .terraform/ *.tfstate *.tfstate.backup .terraform.lock.hcl EOF # 파일 추가 (이제 .gitignore 덕분에 대용량 폴더는 제외됩니다) git add . # 상태 확인 (목록에 terraform-provider-aws... 가 없어야 합니다) git status 3 # Step 3: 커밋 및 강제 푸시 git commit -m "Initial commit: EKS workflow without large binaries" # 원격 저장소 다시 연결 git remote add origin https://github.com/topasvga1/s1.git 4 # 푸시 실행 git push origin main --force 3. 인증 처리 (토큰 사용) # 푸시할 때 Password를 물어보면 아까 생성하신 **Personal Access Token(ghp_...)**을 입력하세요. 4. 작업 결과 확인 성공적으로 완료되면 GitHub 레포지토리에는 다음 파일들만 올라가게 됩니다: .github/workflows/ (배포 자동화 스크립트) cluster.yaml (EKS 클러스터 설정) index.html, Dockerfile (웹 앱 소스) .gitignore (관리 제외 목록) 이제 용량이 몇 KB 수준으로 줄어들어 순식간에 푸시가 완료될 것입니다. 푸시가 끝나면 GitHub Actions 탭에서 무중단 배포 워크플로우가 돌아가는지 확인해 보세요 GitHub 저장소의 Actions 탭으로 가서 Check EKS Nodes 단계에서 클러스터의 노드 3개가 정상적으로 출력되는지 확인하세요. 요약 흐름도 GitHub Actions: AWS 자격 증명 주입 → kubeconfig 생성 → kubectl 명령 실행. EKS Cluster: aws-auth를 통해 해당 IAM User의 요청을 승인. ---------- <2:> 아고 롤아웃 설치 1 # 1. 전용 네임스페이스 생성 kubectl create namespace argo-rollouts # 2. Argo Rollouts 최신 버전 설치 (CRD 포함) kubectl apply -n argo-rollouts -f https://github.com/argoproj/argo-rollouts/releases/latest/download/install.yaml kubectl get pods -n argo-rollouts # 1/1 확인 2 # kind: Rollout 으로 배포 cat < Argo Rollouts 플러그인 설치 (Linux 기준) - 진행 사항을 확인 하는 유틸 1 # 새 터미널 # 1. 플러그인 바이너리 다운로드 curl -LO https://github.com/argoproj/argo-rollouts/releases/latest/download/kubectl-argo-rollouts-linux-amd64 # 2. 실행 권한 부여 chmod +x ./kubectl-argo-rollouts-linux-amd64 # 3. 경로 이동 (kubectl이 인식할 수 있는 위치로) sudo mv ./kubectl-argo-rollouts-linux-amd64 /usr/local/bin/kubectl-argo-rollouts # 4. 설치 확인 (버전 정보가 출력되면 성공) kubectl argo rollouts version 2 모니터링 kubectl argo rollouts get rollout guestbook-rollout --watch 3 # 블루는 옐로로 변경 kubectl argo rollouts set image guestbook-rollout guestbook=argoproj/rollouts-demo:yellow 사이트가 변경되는 이미지 확인 이제 브라우저로 돌아가 새로고침을 여러 번 해보세요. 이미지 변화: 파란색 배경 사이에 가끔씩 노란색(Yellow) 배경의 사이트가 보이기 시작할 것입니다. 이유: 전체 트래픽 중 **20%**만 새 버전으로 흐르도록 설정되어 있기 때문입니다. 이것이 바로 '무중단 Canary 배포'의 핵심입니다. 4 승인 kubectl argo rollouts promote guestbook-rollout 5 삭제 # 1. 배포 중인 Rollout 및 서비스 삭제 kubectl delete rollout guestbook-rollout kubectl delete svc guestbook-service # 2. Argo Rollouts 컨트롤러 삭제 kubectl delete -f https://github.com/argoproj/argo-rollouts/releases/latest/download/install.yaml kubectl delete namespace argo-rollouts # 클러스터 삭제 명령 eksctl delete cluster --name my-eks-cluster --region ap-northeast-2 eksctl get cluster aws s3 ls # 클라우드 포메이션 삭제 명령 EC2 삭제 학인 # S3 바로 삭제 됩니다. 주의하세요! #모든 S3 버킷을 강제로 비우고 삭제하기 터미널에서 아래 명령어를 복사하여 붙여넣으세요. 이 명령어는 aws s3 ls 결과에서 버킷 이름만 추출하여 각각 aws s3 rb --force를 실행합니다. for bucket in $(aws s3 ls | awk '{print $3}'); do echo "Deleting bucket: $bucket" aws s3 rb s3://$bucket --force done 감사합니다.