Skip to content

[S14P31B106-363] k8s 자원 수정#192

Merged
sojaeheon merged 3 commits into
developfrom
fix/be/S14P31B106-363_ErrorFix
May 20, 2026
Merged

[S14P31B106-363] k8s 자원 수정#192
sojaeheon merged 3 commits into
developfrom
fix/be/S14P31B106-363_ErrorFix

Conversation

@sojaeheon
Copy link
Copy Markdown
Contributor

📌 개요

런타임에서 발생하던 오류들을 수정하고, 로컬 개발 환경을 운영(K8s)과 동일한
KIS 실시간 게이트웨이 구조로 정렬했습니다. 더불어 그 과정에서 발견한 KIS 승인키
무효화 storm 을 자동 복구하도록 보강하고, 단일 노드 K3s 의 빌드/자원 비효율을
개선했습니다.

✨ 주요 변경 사항

[BE]

  • 종목 뉴스 조회 500 수정published_atT/공백 구분자 혼재로 인한
    DateTimeParseException 방어 (NewsResponse 가 두 포맷 모두 허용)
  • KIS 승인키 invalid approval 자동 복구 (게이트웨이 경로) — 무효 승인키를
    만료 전까지 재사용해 1초 간격 reconnect storm 이 나던 문제. 거부 감지 시 승인키
    evict + 세션 재생성(새 키), per-user 60초 쿨다운으로 권한/충돌 시 storm 차단

[FE]

  • 차트 평단가 로드 실패(ReferenceError) 수정 — TradingChart 의 누락된
    getPortfolio import 추가

[INFRA]

  • 로컬 docker-compose → K8s 게이트웨이 구조 전환 — kis-gateway 서비스 추가
    (gateway 프로파일) + backend MARKET_FEED_CLIENT_MODE=REMOTE
  • CI 빌드 시간 단축 — infra 변경 시 전체 재빌드(forceAll) 제거 + 4개 docker
    build 에 레지스트리 레이어 캐시(--cache-from :latest + BUILDKIT_INLINE_CACHE=1)
  • 단일 노드 K3s 자원 효율화 — backend 부팅 CPU request 150m→400m + JVM
    옵션(MaxRAMPercentage/SerialGC) + startupProbe 30→40, candle-collector CPU 감축,
    kafka heap 고정·mem 다이어트, postgres mem request 축소 (replicas/브로커 개수 유지)

🔍 관련 이슈

🙏 To Reviewers

  • 승인키 자동 복구는 시세용 KisRealtimeUpstreamClient 의 evict+복구 패턴을
    사용자별 경로(UserKisSession/UserKisSessionPool)에 이식한 것입니다.
    이번 패치는 게이트웨이 경로 한정(LOCAL 모드 KisExecutionWebSocketClient
    현 REMOTE 환경에서 비활성이라 후속 분리).
  • 자원 효율화는 backend replicas=2 / kafka 브로커=3 개수를 유지한 채 per-pod
    right-sizing 으로만 메모리 요청 82%→~70% 확보 + backend 부팅 CPU 보장입니다.
  • (별건) RestClientConfig[KIS-WIRE] 디버그 인터셉터가 /oauth2/Approval 요청의
    appkey/secretkey 를 평문 로깅 중 — 제거/마스킹 후속 필요.

🔗 문서

  • 해당 없음 (의도는 코드/매니페스트 주석으로 명시)

🧪 테스트 방법

  1. docker compose up -d --build backend kis-gateway
  2. 게이트웨이 로그: session started / execution cipher initialized(체결통보 구독 성공)
    / invalid approval·subscribe rejected 0건 확인
  3. 프론트에서 실시간 시세·호가 + 장중 주문 체결 알림 수신
  4. (뉴스) GET /api/v1/markets/stocks/016880/news → 500 없이 200
  5. (차트) 차트 진입 시 콘솔에 getPortfolio is not defined 없음
  6. (CI) infra-only 커밋 push 시 analysis_server 가 재빌드되지 않는지 확인

📸 스크린샷/동작 확인

  • (필요 시 게이트웨이 정상 로그 / 실시간 3종 / 뉴스 200 캡처 첨부)

✅ 체크리스트

  • 코드가 정상적으로 동작하는지 확인 (compileJava 통과 + 게이트웨이 헬시 부팅 검증)
  • 관련 테스트를 작성/통과했는지 확인 (단위 테스트 별도 미작성)
  • 문서화가 필요한 경우 업데이트 (코드/매니페스트 주석)

⚠️ 추가 고려 사항

  • 배포 시 재시작 범위: 자원 효율화 매니페스트 적용 시 변경된 워크로드만 재시작됩니다
    (backend=RollingUpdate 무중단, candle-collector/kafka=순차, postgres=Recreate 로
    잠깐 DB 다운
    ). DB 다운이 부담이면 backend+analysis 먼저, kafka/postgres 는 한가한
    시간에 분리 적용 권장.
  • CI 캐시 1회차: 기존 :latest 이미지에 inline cache 가 없어, 이 변경 머지 직후
    첫 빌드는 캐시 미스로 여전히 느리고 2회차부터 빨라집니다.
  • 호환성: 뉴스 파서·승인키 복구 모두 기존 정상 흐름 유지. appkey 개수(2/3) 변경 없음.

🤖 Generated with Claude Code

@sojaeheon sojaeheon self-assigned this May 20, 2026
@sojaeheon sojaeheon requested a review from minjeongkimm May 20, 2026 04:18
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 20, 2026

Warning

Rate limit exceeded

@sojaeheon has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 12 minutes and 25 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: a25670ae-30ac-4669-b859-c80be23063f1

📥 Commits

Reviewing files that changed from the base of the PR and between 29a3029 and 4495619.

📒 Files selected for processing (17)
  • backend/.dockerignore
  • backend/Dockerfile
  • backend/src/main/java/com/modu/backend/domain/market/dto/NewsResponse.java
  • backend/src/main/java/com/modu/backend/domain/market/feed/UserKisSession.java
  • backend/src/main/java/com/modu/backend/domain/market/feed/UserKisSessionFactory.java
  • backend/src/main/java/com/modu/backend/domain/market/feed/UserKisSessionPool.java
  • backend/src/main/java/com/modu/backend/domain/user/repository/KisTokenRepository.java
  • backend/src/main/java/com/modu/backend/domain/user/service/KisTokenService.java
  • docker-compose.yml
  • frontend/.dockerignore
  • frontend/Dockerfile
  • frontend/src/components/TradingChart.jsx
  • infra/Jenkinsfile
  • infra/k8s/analysis-server.yaml
  • infra/k8s/backend.yaml
  • infra/k8s/kafka.yaml
  • infra/k8s/postgres.yaml
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/be/S14P31B106-363_ErrorFix

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sojaeheon sojaeheon merged commit 6de53c3 into develop May 20, 2026
7 checks passed
@sojaeheon sojaeheon deleted the fix/be/S14P31B106-363_ErrorFix branch May 20, 2026 05:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants