<5> 시각화 유틸 Kubeops view 설치 1 wa 2 # 파드와 노드증가를 시각화 하여 확인하는 Kubeops view 설치 git clone https://codeberg.org/hjacobs/kube-ops-view.git cd kube-ops-view/ kubectl apply -k deploy # 외부에서 kube-ops-view를 접속하기 위해서 Service Type을 LoadBalancer 로 변경한다. kubectl edit svc kube-ops-view apiVersion: v1 kind: Service metadata: annotations: name: kube-ops-view spec: .... sessionAffinity: None type: LoadBalancer status: (3분 걸림) # type: ClusterIP => type: LoadBalancer 로 수정. 3 eksctl scale nodegroup --cluster=free-vpc-cluster --name=standard-nodes --nodes=3 --nodes-min=1 --nodes-max=10 --region ap-northeast-2 eksctl scale nodegroup --cluster=free-vpc-cluster --name=standard-nodes --nodes=7 --nodes-min=1 --nodes-max=10 --region ap-northeast-2 <6> GitHub Actions + ECR 실습 EKS에서 실습 # 터미널 1 watch -d kubectl get svc,hpa,deploy,rs,pods 2 # 터미널 2 mkdir 52 cd 52 k ns default # 쿠버네티스 명령서버 재 설정 필요시 # 2. kubeconfig 업데이트 aws eks update-kubeconfig --region ap-northeast-2 --name free-vpc-cluster 3 웹 소스 및 Dockerfile 생성 먼저 배포될 실제 애플리케이션 파일과 이를 이미지로 만드는 설계도를 만듭니다. # 1. 테스트용 인덱스 페이지 생성 cat < index.html CI/CD Test

🚀 GitHub Actions CI/CD 성공!

배포 버전: 1.0.0

커밋 해시: $(git rev-parse --short HEAD 2>/dev/null || echo "initial")

EOF # 2. Dockerfile 생성 cat < Dockerfile FROM nginx:latest COPY index.html /usr/share/nginx/html/index.html EXPOSE 80 EOF 2. GitHub Actions 워크플로우 생성 GitHub이 인식할 자동화 시나리오 파일입니다. .github/workflows 폴더를 먼저 만들고 생성해야 합니다. # 폴더 생성 mkdir -p .github/workflows # 워크플로우 파일 생성 cat < .github/workflows/deploy.yml name: Deploy to EKS on: push: branches: [ "main" ] jobs: build-and-deploy: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v3 # AWS 자격 증명 설정 (GitHub Secrets 사용) - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v1 with: aws-access-key-id: \${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: \${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-region: ap-northeast-2 # ECR 로그인 - name: Login to Amazon ECR id: login-ecr uses: aws-actions/amazon-ecr-login@v1 # 이미지 빌드 및 푸시 - name: Build and Push to ECR env: ECR_REGISTRY: \${{ steps.login-ecr.outputs.registry }} IMAGE_TAG: \${{ github.sha }} run: | docker build -t \$ECR_REGISTRY/web-demo-repo:\$IMAGE_TAG . docker push \$ECR_REGISTRY/web-demo-repo:\$IMAGE_TAG # EKS 접속 정보 업데이트 - name: Update Kubeconfig run: aws eks update-kubeconfig --name free-vpc-cluster --region ap-northeast-2 # Helm을 이용한 무중단 배포 - name: Helm Deploy run: | helm upgrade --install my-web ./web-demo-chart \\ --set image.repository=\${{ steps.login-ecr.outputs.registry }}/web-demo-repo \\ --set image.tag=\${{ github.sha }} EOF 3. 마무리 및 실행 순서 ECR 생성: 아까 만들지 않았다면 명령어로 먼저 만듭니다. aws ecr create-repository --repository-name web-demo-repo --region ap-northeast-2 4 GitHub Secrets 등록: 리포지토리 설정에서 AWS_ACCESS_KEY_ID와 AWS_SECRET_ACCESS_KEY를 꼭 등록해 주세요. https://github.com/ https://github.com/topasvga1 AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY 5 # 이메일 등록 git config --global user.email "your_email@example.com" # 이름 등록 git config --global user.name "your_name" # 1. 현재 폴더를 Git 저장소로 초기화 git init # 2. GitHub 리포지토리 연결 (본인의 리포지토리 주소로 수정하세요) # 예: git remote add origin https://github.com/사용자아이디/리포지토리이름.git git remote add origin <본인의_GitHub_리포지토리_주소> git remote add origin https://github.com/topasvga1/s1 # 3. 기본 브랜치 이름을 main으로 변경 git branch -M main git add . git commit -m "🚀 CI/CD 파이프라인 가동" git push origin main topasvga1 ghp_bGw7h 6 # git 트라블 슈팅 hint: Updates were rejected because the remote contains work that you do not hint: have locally. This is usually caused by another repository pushing to hint: the same ref. If you want to integrate the remote changes, use hint: 'git pull' before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details. git pull origin main --rebase git push -u origin main ---------- # 1. 최신 버전의 Argo CD CLI 다운로드 curl -sSL -o argocd-linux-amd64 https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64 # 2. 실행 권한 부여 및 경로 이동 sudo install -m 755 argocd-linux-amd64 /usr/local/bin/argocd # 3. 다운로드한 임시 파일 삭제 rm -rf argocd-linux-amd64 argocd --------------------------- 7. GitHub Actions + ECR 실습 동작 확인법 1 kubectl get pods -w 2 kubectl get ep web-demo-service 3 # 로드밸런서 주소(EXTERNAL-IP) 확인 kubectl get svc 4 CI/CD가 정말 잘 작동하는지 체감하고 싶다면 아래 과정을 한 번 더 해보세요. index.html 파일에서

배포 버전: 1.0.0

을 1.0.1로 수정합니다. git add, git commit, git push를 실행합니다. 약 2~3분 뒤 브라우저를 새로고침합니다. 버전 숫자가 자동으로 바뀌어 있다면 당신은 이제 진정한 데브옵스 환경을 구축하신 겁니다!