Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ HOSTNAME=localhost
GPR_USER=GitHub_ID
GPR_TOKEN=GitHub_Personal_Access_Token(PAT)

EUREKA_SERVER_URL=http://localhost:8761/eureka/
EUREKA_SERVER_URL=http://localhost:8761/eureka/
ZIPKIN_ENDPOINT=http://localhost:9411/api/v2/spans
16 changes: 14 additions & 2 deletions .github/actions/deploy-vm/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ runs:
--zone="${{ inputs.zone }}" \
--project="${{ inputs.gcp_project }}" \
--tunnel-through-iap

gcloud compute scp deploy/promtail-config.yml \
${{ inputs.vm }}:/tmp/promtail-config.yml \
--zone="${{ inputs.zone }}" \
--project="${{ inputs.gcp_project }}" \
--tunnel-through-iap

- name: Deploy and verify
id: deploy_run
Expand All @@ -94,7 +100,13 @@ runs:

sudo mkdir -p ${{ inputs.work_dir }}
sudo mv /tmp/docker-compose.prod.yaml ${{ inputs.work_dir }}/docker-compose.prod.yaml
sudo mv /tmp/promtail-config.yml ${{ inputs.work_dir }}/promtail-config.yml
cd ${{ inputs.work_dir }}

if ! sudo docker network inspect pgsg-network > /dev/null 2>&1; then
echo 'pgsg-network not found. Creating...'
sudo docker network create pgsg-network
fi

sudo env IMAGE_TAG=\"${{ inputs.image_tag }}\" AR_IMAGE_PATH=\"${{ inputs.ar_image_path }}\" \
docker compose -f docker-compose.prod.yaml pull
Expand Down Expand Up @@ -144,12 +156,12 @@ runs:
sudo env IMAGE_TAG=\"${{ steps.rollback.outputs.tag }}\" AR_IMAGE_PATH=\"${{ inputs.ar_image_path }}\" \
docker compose -f docker-compose.prod.yaml up -d

for i in \$(seq 1 18); do
for i in \$(seq 1 ${{ inputs.health_retries }}); do
if curl -sf http://localhost:8090/actuator/health | grep -q '\"status\":\"UP\"'; then
echo \"Rollback container UP (attempt \$i)\"
exit 0
fi
sleep 10
sleep ${{ inputs.health_interval }}
done

echo 'Rollback container did not become healthy.'
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ ext {

dependencies {

implementation('org.pgsg:common:0.2.5-SNAPSHOT') {
implementation('org.pgsg:common:0.3.2-SNAPSHOT') {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-data-jpa'
exclude group: 'com.querydsl', module: 'querydsl-jpa'
}
Expand Down
5 changes: 4 additions & 1 deletion deploy/.env.template
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ JWT_REFRESH_EXPIRATION=
HOSTNAME=

# Eureka 서버 주소
EUREKA_CLIENT_SERVICEURL_DEFAULTZONE=
EUREKA_SERVER_URL=

LOKI_URL=
ZIPKIN_ENDPOINT=
24 changes: 23 additions & 1 deletion deploy/docker-compose.prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,26 @@ services:
ports:
- "8090:8090"
env_file:
- .env
- .env
volumes:
- /opt/gateway/logs:/logs # 게이트웨이에서 생성한 로그 파일을 저장할 경로
networks:
- pgsg-network

promtail:
image: grafana/promtail:2.9.1
container_name: promtail
restart: always
volumes:
- /opt/gateway/promtail-config.yml:/etc/promtail/config.yml
- /opt/gateway/logs:/logs # 로그 파일을 저장한 경로와 동일하게 지정
# promtail 2.9.1 버전은 명시적으로 환경변수 플래그를 지정해야 promtail-config.yml에 설정한 환경변수값 적용 가능
command: -config.file=/etc/promtail/config.yml -config.expand-env=true
env_file:
- .env
networks:
- pgsg-network
Comment thread
coderabbitai[bot] marked this conversation as resolved.

networks:
pgsg-network:
external: true
14 changes: 14 additions & 0 deletions deploy/promtail-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
server:
http_listen_port: 9080

clients:
- url: ${LOKI_URL:-http://loki:3100/loki/api/v1/push}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

scrape_configs:
- job_name: gateway-server
static_configs:
- targets:
- localhost
labels:
job: gateway-server
__path__: /logs/*.log
Comment thread
coderabbitai[bot] marked this conversation as resolved.
6 changes: 5 additions & 1 deletion src/main/java/org/pgsg/gateway/filter/JwtGatewayFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ public class JwtGatewayFilter extends OncePerRequestFilter {
"/api/v1/auth/reissue",
"/actuator/health",
"/actuator/health/**",
"/actuator/info"
"/actuator/info",
"/actuator/prometheus",
"/actuator/prometheus/**",
"/actuator/metrics",
"/actuator/metrics/**"
);

private final Tracer tracer;
Expand Down
10 changes: 9 additions & 1 deletion src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,12 @@ eureka:
defaultZone: ${EUREKA_SERVER_URL:http://localhost:8761/eureka/}

server:
port: 8090
port: 8090

management:
tracing:
sampling:
probability: 0.1
zipkin:
tracing:
endpoint: ${ZIPKIN_ENDPOINT:http://localhost:9411/api/v2/spans}
Loading