Repository navigation
fix(cicd): add db-seed init container to backend deployments - #389
Merged
Merged
Conversation
Contributor
Author
|
추가 커밋 반영: AI 서비스 prod HPA `minReplicas`를 2 → 1로 낮췄습니다(`k8s/apps/ai-service/overlays/prod/hpa.yaml`). 온톨로지 시드 자동화와는 별개 변경이지만 이 PR에 함께 포함했습니다. |
jeongmin1999
self-requested a review
July 3, 2026 10:57
jeongmin1999
approved these changes
Jul 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
배경
프로덕션 인사이트맵(
research모드)에 개념이 하나도 표시되지 않는 문제가 있었습니다. 원인은ontology_concepts/ontology_edges테이블이alembic upgrade로 스키마만 생성되고, 데이터는UtterAI_BE/scripts/seed_ontology.py를 별도로 수동 실행해야 채워지는데, 이 단계가 배포 파이프라인 어디에도 없었기 때문입니다. 프로덕션은 실제로ontology_concepts0건이었습니다.임시 조치로 프로덕션 파드에 직접
kubectl exec로 시드 스크립트를 1회 실행해 데이터는 채워놓은 상태이며, 이 PR은 재발 방지를 위한 자동화입니다.변경 내용
db-migrateinit 컨테이너 바로 뒤에db-seedinit 컨테이너를 추가해 배포마다python scripts/seed_ontology.py를 자동 실행하도록 함k8s/apps/backend/overlays/dev/deployment.yamlk8s/apps/backend/overlays/prod/deployment-blue.yamlk8s/apps/backend/overlays/prod/deployment-green.yamlpod-security.kubernetes.io/enforce: restricted가 적용되어 있어,db-migrate와 동일한securityContext(non-root,capabilities.drop: [ALL],readOnlyRootFilesystem: true)를db-seed에도patch-deployment.yaml에 추가함영향 범위 / 검증
kubectl kustomize로 dev/prod overlay 렌더링 결과 확인 —db-seed컨테이너에 올바른 이미지 태그(kustomize image transformer가 기존utterai-backend-blue/-green이름으로 자동 주입)와 securityContext가 정상 반영됨seed_ontology.py는concept_key기준 upsert(존재하면 UPDATE, 없으면 INSERT)라 여러 번 실행해도 안전(idempotent)scripts/디렉토리를 포함하도록 Dockerfile 수정. 이 PR이 먼저 머지/배포되어야db-seed가 정상 동작함리뷰 포인트
db-seed가 동시에 시작되면concept_keyunique 제약으로 드물게 한쪽 init 컨테이너가 실패할 수 있습니다.seed_ontology.py가 원자적ON CONFLICTupsert가 아니라 조회 후 삽입/갱신 방식이기 때문입니다. 다만 Kubernetes가 실패한 init 컨테이너를 자동 재시도하고, 재시도 시점엔 다른 파드가 이미 커밋해놨을 것이므로 자동 회복됩니다. 필요시 추후seed_ontology.py를 원자적 upsert로 개선하는 것을 고려해볼 수 있습니다.