Codepipeline

이제 AWS CloudFormation을 사용하여 AWS CodePipeline을 생성하겠습니다. 이 파이프라인은 GitHub Source repo(eks-example)에서 도커 이미지를 구축하는 데 사용됩니다. 이렇게 해도 이미지가 배포되지 않으며 Weave Flux 에서 이를 처리합니다.

CloudFormation은 클라우드 환경의 모든 인프라 리소스를 설명하고 프로비저닝할 수 있는 공통 언어를 제공하는 IaC(infrastructure as code) 툴입니다. CloudFormation을 사용하면 간단한 텍스트 파일을 사용하여 모든 region과 account에 걸쳐 애플리케이션에 필요한 모든 리소스를 자동화되고 안전하게 모델링하고 프로비저닝할 수 있습니다.

각 EKS 배포/서비스는 자체 CodePipeline이 있어야 하며 분리된 소스 저장소에 있어야 합니다.

아래 파일을 클릭하여 다운 로드 후 AWS Management Console에 CloudFormation 스택을 생성합니다.

  • 스택 이름 : image-codepipeline

  • Username : git username

  • Access token : git access key

  • Repository : eks-example

  • Branch : main

Stack이 완료(CREATE_COMPLETE)될때 까지 기다립니다.

CodePipeline in the Management Console 에 접속하여 image-codepipeline 으로 codepipeline이 시작된 것을 볼 수 있습니다. 현재 저장소에 코드가 없기 때문에 이미지 빌드에 실패가 됩니다.

GitHub repo에 샘플 애플리케이션을 추가할 것입니다. 아래 ${YOURUSER}를 GitHub 사용자 이름을 대체합니다.

git clone git@github.com:${YOURUSER}/eks-example.git
cd eks-example

그런 다음 기본 README 파일, 원본 디렉터리를 만들고 샘플 nginx 구성(hello.conf), 홈 페이지(index.html) 및 도커 파일을 다운로드합니다.

echo "# eks-example" > README.md
mkdir src
wget -O src/hello.conf https://raw.githubusercontent.com/aws-samples/eks-workshop/main/content/intermediate/260_weave_flux/app.files/hello.conf
wget -O src/index.html https://raw.githubusercontent.com/aws-samples/eks-workshop/main/content/intermediate/260_weave_flux/app.files/index.html
wget https://raw.githubusercontent.com/aws-samples/eks-workshop/main/content/intermediate/260_weave_flux/app.files/Dockerfile

이제 간단한 hello world app를 commit하여 codepipeline 을 시작시킵니다.

git add .
git commit -am "Initial commit"
git push 

빌드 이미지를 확인하여 위하여 Amazon ECR console 접속하여 eks-example image repository를 확인합니다.

Last updated