Skip to content

Commit 6059429

Browse files
authored
Merge pull request #81 from YAPP-Github/feat/T3-205
[T3-205] 프로메테우스, 그라파나 관련 문서 수정
2 parents 6b4c617 + d378560 commit 6059429

File tree

3 files changed

+121
-4
lines changed

3 files changed

+121
-4
lines changed

.github/workflows/cicd-workflow.yml

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,27 @@ jobs:
160160
docker push ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.ap-northeast-2.amazonaws.com/${{ secrets.ECR_REPO_NAME_DEV }}:latest # 이미지를 ECR에 푸시합니다.
161161
echo "image=${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.ap-northeast-2.amazonaws.com/${{ secrets.ECR_REPO_NAME_DEV }}:latest" >> $GITHUB_OUTPUT
162162
163+
# 8-1. Prometheus Docker 이미지 빌드 및 푸시
164+
- name: Build Prometheus image - release
165+
if: github.ref == 'refs/heads/release'
166+
id: build-prom-image-release
167+
run: |
168+
cp config/prod/application-prometheus-prod.yml ./prometheus.yml
169+
docker build --platform linux/amd64 -t ${{ secrets.ECR_REPO_NAME_PROMETHEUS_PROD }} .
170+
docker tag ${{ secrets.ECR_REPO_NAME_PROMETHEUS_PROD }}:latest ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.ap-northeast-2.amazonaws.com/${{ secrets.ECR_REPO_NAME_PROMETHEUS_PROD }}:latest
171+
docker push ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.ap-northeast-2.amazonaws.com/${{ secrets.ECR_REPO_NAME_PROMETHEUS_PROD }}:latest
172+
echo "image=${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.ap-northeast-2.amazonaws.com/${{ secrets.ECR_REPO_NAME_PROMETHEUS_PROD }}:latest" >> $GITHUB_OUTPUT
173+
174+
- name: Build Prometheus image - develop
175+
if: github.ref == 'refs/heads/develop'
176+
id: build-prom-image-develop
177+
run: |
178+
cp config/dev/application-prometheus-dev.yml ./prometheus.yml
179+
docker build --platform linux/amd64 -t ${{ secrets.ECR_REPO_NAME_PROMETHEUS_DEV }} .
180+
docker tag ${{ secrets.ECR_REPO_NAME_PROMETHEUS_DEV }}:latest ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.ap-northeast-2.amazonaws.com/${{ secrets.ECR_REPO_NAME_PROMETHEUS_DEV }}:latest
181+
docker push ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.ap-northeast-2.amazonaws.com/${{ secrets.ECR_REPO_NAME_PROMETHEUS_DEV }}:latest
182+
echo "image=${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.ap-northeast-2.amazonaws.com/${{ secrets.ECR_REPO_NAME_PROMETHEUS_DEV }}:latest" >> $GITHUB_OUTPUT
183+
163184
# 9. Amazon ECS 태스크 정의에 새 이미지 ID 채우기
164185
- name: Fill in the new image ID in the Amazon ECS task definition - release
165186
if: github.ref == 'refs/heads/release'
@@ -170,6 +191,16 @@ jobs:
170191
container-name: ${{ secrets.ECS_CONTAINER_NAME_PROD }}
171192
image: ${{ steps.build-image-release.outputs.image }}
172193

194+
# ★ 추가: 프로메테우스 이미지 주입 (release)
195+
- name: Fill in Prometheus image - release
196+
if: github.ref == 'refs/heads/release'
197+
id: task-def-prom-release
198+
uses: aws-actions/amazon-ecs-render-task-definition@v1
199+
with:
200+
task-definition: ${{ steps.task-def-release.outputs.task-definition }} # 위 단계에서 만든 결과물을 입력으로 사용
201+
container-name: prometheus
202+
image: ${{ steps.build-prom-image-release.outputs.image }}
203+
173204
- name: Mask ECS container name secret - release
174205
if: github.ref == 'refs/heads/release'
175206
run: |
@@ -186,12 +217,22 @@ jobs:
186217
container-name: ${{ secrets.ECS_CONTAINER_NAME_DEV }}
187218
image: ${{ steps.build-image-develop.outputs.image }}
188219

220+
# ★ 추가: 프로메테우스 이미지 주입 (develop)
221+
- name: Fill in Prometheus image - develop
222+
if: github.ref == 'refs/heads/develop'
223+
id: task-def-prom-develop
224+
uses: aws-actions/amazon-ecs-render-task-definition@v1
225+
with:
226+
task-definition: ${{ steps.task-def-develop.outputs.task-definition }} # 위 단계에서 만든 결과물을 입력으로 사용
227+
container-name: prometheus
228+
image: ${{ steps.build-prom-image-develop.outputs.image }}
229+
189230
# 10. ECS에 배포
190231
- name: Deploy to ECS - release
191232
if: github.ref == 'refs/heads/release'
192233
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
193234
with:
194-
task-definition: ${{ steps.task-def-release.outputs.task-definition }} # ECS 태스크 정의 파일을 지정합니다.
235+
task-definition: ${{ steps.task-def-prom-release.outputs.task-definition }} # ECS 태스크 정의 파일을 지정합니다.
195236
service: ${{ secrets.ECS_SERVICE_NAME_PROD }}
196237
cluster: ${{ secrets.ECS_CLUSTER_NAME }}
197238
wait-for-service-stability: true # 서비스가 안정화될 때까지 대기합니다.
@@ -200,7 +241,7 @@ jobs:
200241
if: github.ref == 'refs/heads/develop'
201242
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
202243
with:
203-
task-definition: ${{ steps.task-def-develop.outputs.task-definition }} # ECS 태스크 정의 파일을 지정합니다.
244+
task-definition: ${{ steps.task-def-prom-develop.outputs.task-definition }} # ECS 태스크 정의 파일을 지정합니다.
204245
service: ${{ secrets.ECS_SERVICE_NAME_DEV }}
205246
cluster: ${{ secrets.ECS_CLUSTER_NAME }}
206247
wait-for-service-stability: true # 서비스가 안정화될 때까지 대기합니다.

task-definition-dev.json

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"containerDefinitions": [
55
{
66
"name": "bitnagil-dev",
7-
"cpu": 1,
7+
"cpu": 1024,
88
"portMappings": [
99
{
1010
"containerPort": 8081,
@@ -48,7 +48,7 @@
4848
{
4949
"name": "redis-dev",
5050
"image": "redis:7-alpine",
51-
"cpu": 1,
51+
"cpu": 512,
5252
"portMappings": [
5353
{
5454
"name": "redis-dev-6379-tcp",
@@ -63,6 +63,44 @@
6363
"mountPoints": [],
6464
"volumesFrom": [],
6565
"systemControls": []
66+
},
67+
{
68+
"name": "prometheus",
69+
"image": "prometheus-image-placeholder",
70+
"cpu": 256,
71+
"memoryReservation": 256,
72+
"essential": false,
73+
"portMappings": [ { "containerPort": 9090, "protocol": "tcp" } ],
74+
"logConfiguration": {
75+
"logDriver": "awslogs",
76+
"options": {
77+
"awslogs-group": "/ecs/prometheus-dev",
78+
"awslogs-region": "ap-northeast-2",
79+
"awslogs-stream-prefix": "ecs"
80+
}
81+
}
82+
},
83+
{
84+
"name": "grafana",
85+
"image": "grafana/grafana:10.4.1",
86+
"cpu": 128,
87+
"memoryReservation": 256,
88+
"portMappings": [
89+
{
90+
"containerPort": 3000,
91+
"hostPort": 3000,
92+
"protocol": "tcp"
93+
}
94+
],
95+
"essential": false,
96+
"logConfiguration": {
97+
"logDriver": "awslogs",
98+
"options": {
99+
"awslogs-group": "/ecs/grafana-dev",
100+
"awslogs-region": "ap-northeast-2",
101+
"awslogs-stream-prefix": "ecs"
102+
}
103+
}
66104
}
67105
],
68106
"taskRoleArn": "arn:aws:iam::750819668269:role/ecsTaskExecutionRole",

task-definition-prod.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,44 @@
4141
"secretOptions": []
4242
},
4343
"systemControls": []
44+
},
45+
{
46+
"name": "prometheus",
47+
"image": "prometheus-image-placeholder",
48+
"cpu": 256,
49+
"memoryReservation": 256,
50+
"essential": false,
51+
"portMappings": [ { "containerPort": 9090, "protocol": "tcp" } ],
52+
"logConfiguration": {
53+
"logDriver": "awslogs",
54+
"options": {
55+
"awslogs-group": "/ecs/prometheus-dev",
56+
"awslogs-region": "ap-northeast-2",
57+
"awslogs-stream-prefix": "ecs"
58+
}
59+
}
60+
},
61+
{
62+
"name": "grafana",
63+
"image": "grafana/grafana:10.4.1",
64+
"cpu": 128,
65+
"memoryReservation": 256,
66+
"portMappings": [
67+
{
68+
"containerPort": 3000,
69+
"hostPort": 3000,
70+
"protocol": "tcp"
71+
}
72+
],
73+
"essential": false,
74+
"logConfiguration": {
75+
"logDriver": "awslogs",
76+
"options": {
77+
"awslogs-group": "/ecs/grafana-dev",
78+
"awslogs-region": "ap-northeast-2",
79+
"awslogs-stream-prefix": "ecs"
80+
}
81+
}
4482
}
4583
],
4684
"taskRoleArn": "arn:aws:iam::750819668269:role/ecsTaskExecutionRole",

0 commit comments

Comments
 (0)