Skip to content

fix(infra): add annotation(auto-enabled)#24

Open
doyoon323 wants to merge 7 commits intomainfrom
feat/rds-to-onpremise
Open

fix(infra): add annotation(auto-enabled)#24
doyoon323 wants to merge 7 commits intomainfrom
feat/rds-to-onpremise

Conversation

@doyoon323
Copy link
Contributor

@doyoon323 doyoon323 commented Mar 21, 2026

변경 사항

  • infra/k8s/postgres/db-credentials.yaml

    • auto-enabled: true 설정을 통해 송신 측에서 수신 측으로 secret을 push합니다.
  • infra/k8s/api/deployment.yaml

    • initContainer를 통해, image를 pull하고 migrate 실행
  • lab cluster

    • too many open file 로그가 발생하여 아래와 같이 수정했습니다.
      • fs.inotify.max_user_instances=128 -> 512
      • fs.inotify.max_user_watches= 65536-> 524288

*참고사항

  • initContianer 방식은 replica가 2개 이상이 되면 동시성 위험이 있다고 합니다. 마이그레이션은 추후 ci/cd로 빼두면 좋을 것 같습니다.

@doyoon323 doyoon323 requested a review from manamana32321 March 21, 2026 01:36
@doyoon323 doyoon323 self-assigned this Mar 21, 2026
Copy link
Member

@manamana32321 manamana32321 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

전체

PR 제목이 fix(infra): add annotation(auto-enabled)인데, 실제로는 RDS 제거 + on-premise PostgreSQL 전환 + initContainer migration 추가 등 범위가 훨씬 큽니다. database.tf 삭제, ExternalSecret 제거, IAM 변경 등 주요 변경사항이 description에 빠져있어서 리뷰할 때 전체 그림을 파악하기 어려웠습니다.

제목을 feat(infra): migrate from AWS RDS to on-premise PostgreSQL 같이 바꾸고, description에 삭제된 리소스 목록도 포함하면 좋겠습니다.

labels:
app: api
spec:
initContainers:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

initContainer 방식도 replica 1개에서는 동작하지만, ArgoCD 환경이니까 PreSync Hook Job으로 분리하는 방향은 어떨까요?

apiVersion: batch/v1
kind: Job
metadata:
  name: prisma-migrate
  annotations:
    argocd.argoproj.io/hook: PreSync
    argocd.argoproj.io/hook-delete-policy: BeforeHookCreation

initContainer 대비 장점:

  • migration은 "배포 시 1회 실행"이 맞는 시맨틱인데, Job이 이걸 정확히 표현합니다
  • replica 수와 완전히 무관해서, 다중 replica 확장 시에도 변경이 필요 없습니다
  • rollout restart나 node drain 같은 변경 없는 재시작에서 불필요한 migration 재실행이 없습니다
  • Job 실패 시 ArgoCD sync 자체가 실패하므로 broken deployment 방지도 자동입니다
  • CI/CD 파이프라인 수정 없이 kustomization에 Job manifest만 추가하면 됩니다

npx prisma@6.19.2 네트워크 의존성 문제도 있는데, Job이든 initContainer든 Dockerfile에 prisma binary를 포함하는 게 더 안정적일 것 같습니다.

어떻게 생각하시나요?

readinessProbe:
exec:
command: ['pg_isready', '-U', '$(POSTGRES_USER)']
command: ['sh', '-c', 'pg_isready -U $POSTGRES_USER']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API deployment에는 resource limits가 설정되어 있는데 PostgreSQL에는 없습니다. heavy query나 메모리 누수 시 노드 전체에 영향을 줄 수 있으니 최소한 limits는 설정해주면 좋겠습니다.

resources:
  requests:
    cpu: 0.5
    memory: 512Mi
  limits:
    cpu: 2
    memory: 2Gi

namespace: proseed-postgres
annotations:
reflector.v1.k8s.emberstack.com/reflection-allowed: 'true'
reflector.v1.k8s.emberstack.com/reflection-auto-enabled: 'true'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

현재 reflection-auto-enabled: 'true'만 있고 reflection-auto-namespaces가 없는데, 이 경우 Reflector는 모든 네임스페이스에 미러를 시도합니다 (allowed-namespaces로 최종 필터링되긴 합니다). 의도를 명확히 하려면 reflection-auto-namespaces: 'proseed'도 추가하는 게 좋겠습니다.

reflector.v1.k8s.emberstack.com/reflection-auto-namespaces: 'proseed'

Copy link
Member

@manamana32321 manamana32321 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨어요~ 몇 가지 사항만 점검 부탁드립니다!

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