From 8001e4559f290e8c7f42978535a7119b5a8fad89 Mon Sep 17 00:00:00 2001 From: jymin0 Date: Wed, 21 Jan 2026 15:59:25 +0900 Subject: [PATCH 1/6] =?UTF-8?q?deploy:=20CI/CD=20=EC=84=A4=EC=A0=95=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy-monitoring.yml | 58 +++++++++++++++++++++++++ deploy/monitoring/appspec.yml | 17 ++++++++ deploy/monitoring/scripts/starts.sh | 29 +++++++++++++ 3 files changed, 104 insertions(+) create mode 100644 .github/workflows/deploy-monitoring.yml create mode 100644 deploy/monitoring/appspec.yml create mode 100644 deploy/monitoring/scripts/starts.sh diff --git a/.github/workflows/deploy-monitoring.yml b/.github/workflows/deploy-monitoring.yml new file mode 100644 index 0000000..ea70397 --- /dev/null +++ b/.github/workflows/deploy-monitoring.yml @@ -0,0 +1,58 @@ +name: Deploy Monitoring To EC2 +on: + push: + branches: + - main + - deploy + paths: + - "docker-compose.yml" + - "prometheus/**" + - "grafana/**" + - ".github/workflows/deploy-monitoring.yml" + - "deploy/**" + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: GitHub Repository 가져오기 + uses: actions/checkout@v4 + + - name: AWS Resource에 접근할 수 있게 AWS credentials 설정 + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-region: ap-northeast-2 + aws-access-key-id: ${{secrets.AWS_ACCESS_KEY}} + aws-secret-access-key: ${{secrets.AWS_SECRET_KEY}} + + - name: .env 파일 생성 + run: | + cat > .env << EOF + RUN_UID=${{secrets.RUN_UID}} + RUN_GID=${{secrets.RUN_GID}} + GRAFANA_ADMIN_USER=${{secrets.GRAFANA_ADMIN_USER}} + GRAFANA_ADMIN_PASSWORD=${{secrets.GRAFANA_ADMIN_PASSWORD}} + EOF + + - name: 압축하기 + run: | + cp deploy/monitoring/appspec.yml ./appspec.yml + cp -r deploy/monitoring/scripts ./scripts + tar -czvf $GITHUB_SHA.tar.gz \ + appspec.yml \ + .env \ + scripts \ + docker-compose.yml \ + prometheus \ + grafana + + - name: S3에 프로젝트 폴더 업로드 하기 + run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.tar.gz s3://mopl-deploy-4/monitoring/$GITHUB_SHA.tar.gz + + - name: CodeDeploy 배포 트리거 + run: | + aws deploy create-deployment \ + --application-name mopl-monitoring \ + --deployment-config-name CodeDeployDefault.AllAtOnce \ + --deployment-group-name mopl-deploy-group-monitoring \ + --s3-location bucket=mopl-deploy-4,key=monitoring/$GITHUB_SHA.tar.gz,bundleType=tgz diff --git a/deploy/monitoring/appspec.yml b/deploy/monitoring/appspec.yml new file mode 100644 index 0000000..4083f55 --- /dev/null +++ b/deploy/monitoring/appspec.yml @@ -0,0 +1,17 @@ +version: 0.0 +os: linux +files: + - source: / + destination: /home/ubuntu/monitoring +file_exists_behavior: OVERWRITE + +permissions: + - object: / + owner: ubuntu + group: ubuntu + +hooks: + ApplicationStart: + - location: scripts/starts.sh + timeout: 120 + runas: ubuntu diff --git a/deploy/monitoring/scripts/starts.sh b/deploy/monitoring/scripts/starts.sh new file mode 100644 index 0000000..d3672f7 --- /dev/null +++ b/deploy/monitoring/scripts/starts.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +echo "--------------- monitoring 시작 -----------------" + +cd /home/ubuntu/monitoring + +# 기존 컨테이너 중지 및 삭제 +docker compose down --remove-orphans 2>/dev/null || true + +# data 디렉토리 생성 (소유권 설정) +mkdir -p data/prometheus data/grafana + +# 환경 변수에서 UID/GID 읽기 +source .env + +# prometheus 데이터 디렉토리 권한 설정 +chown -R ${RUN_UID}:${RUN_GID} data/prometheus + +# grafana 데이터 디렉토리 권한 설정 (grafana는 472:472 고정) +chown -R 472:472 data/grafana + +# docker-compose로 컨테이너 시작 +docker compose up -d + +echo "--------------- monitoring 끝 ------------------" + +# 컨테이너 상태 확인 +sleep 5 +docker ps | grep monitoring From c83614a69d6addf66a6dd2147442e641f00b9aba Mon Sep 17 00:00:00 2001 From: jymin0 Date: Wed, 21 Jan 2026 16:08:15 +0900 Subject: [PATCH 2/6] Retry deployment with IAM role From 4e71d9f603c42154b383903b6a0d57a912bc33a1 Mon Sep 17 00:00:00 2001 From: jymin0 Date: Wed, 21 Jan 2026 16:09:48 +0900 Subject: [PATCH 3/6] =?UTF-8?q?deploy:=20=EC=9B=8C=ED=81=AC=ED=94=8C?= =?UTF-8?q?=EB=A1=9C=EC=9A=B0=20=ED=99=95=EC=9D=B8=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ef946f8..3532551 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -# monitoring \ No newline at end of file +# monitoring From efb6c02cf257f8722665f8cb6988215ec4d3405e Mon Sep 17 00:00:00 2001 From: jymin0 Date: Wed, 21 Jan 2026 16:10:20 +0900 Subject: [PATCH 4/6] =?UTF-8?q?deploy:=20=EC=9B=8C=ED=81=AC=ED=94=8C?= =?UTF-8?q?=EB=A1=9C=EC=9A=B0=20=ED=99=95=EC=9D=B8=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy-monitoring.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/deploy-monitoring.yml b/.github/workflows/deploy-monitoring.yml index ea70397..a4a6107 100644 --- a/.github/workflows/deploy-monitoring.yml +++ b/.github/workflows/deploy-monitoring.yml @@ -4,12 +4,12 @@ on: branches: - main - deploy - paths: - - "docker-compose.yml" - - "prometheus/**" - - "grafana/**" - - ".github/workflows/deploy-monitoring.yml" - - "deploy/**" +# paths: +# - "docker-compose.yml" +# - "prometheus/**" +# - "grafana/**" +# - ".github/workflows/deploy-monitoring.yml" +# - "deploy/**" jobs: deploy: From c63c2075908fc10edaa4a599c96375f89160e6d1 Mon Sep 17 00:00:00 2001 From: jymin0 Date: Wed, 21 Jan 2026 16:12:56 +0900 Subject: [PATCH 5/6] =?UTF-8?q?deploy:=20=EC=9B=8C=ED=81=AC=ED=94=8C?= =?UTF-8?q?=EB=A1=9C=EC=9A=B0=20=ED=99=95=EC=9D=B8=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 3532551..005f556 100644 --- a/README.md +++ b/README.md @@ -1 +1,2 @@ # monitoring + From 2c9769e2142ea5e3803402af2baf72c0cdcd1916 Mon Sep 17 00:00:00 2001 From: jymin0 Date: Wed, 21 Jan 2026 16:54:53 +0900 Subject: [PATCH 6/6] =?UTF-8?q?deploy:=20=EC=9B=8C=ED=81=AC=ED=94=8C?= =?UTF-8?q?=EB=A1=9C=EC=9A=B0=20=ED=99=95=EC=9D=B8=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- prometheus/prometheus.yml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/prometheus/prometheus.yml b/prometheus/prometheus.yml index dccf57e..fd98c40 100644 --- a/prometheus/prometheus.yml +++ b/prometheus/prometheus.yml @@ -9,4 +9,19 @@ scrape_configs: - job_name: "pushgateway" honor_labels: true static_configs: - - targets: ["pushgateway:9091"] \ No newline at end of file + - targets: ["pushgateway:9091"] + + - job_name: "batch" + static_configs: + - targets: [ "10.0.0.176:8082" ] + metrics_path: "/actuator/prometheus" + + - job_name: "spring-core" + static_configs: + - targets: [ "10.0.0.84:8080" ] + metrics_path: "/actuator/prometheus" + + - job_name: "websocket" + static_configs: + - targets: [ "10.0.0.71:8080" ] + metrics_path: "/actuator/prometheus"