Files
nginx-portal/GITOPS-GUIDE.md
qorgh529 5e7e245858
Some checks failed
Build and Push Images / build-backend (push) Has been cancelled
init: web portal
2026-04-06 21:16:17 +09:00

2.3 KiB
Executable File

GitOps 배포 가이드 (Gitea + ArgoCD)

📋 전체 흐름

git push (main)
  → Gitea Actions 실행
    → docker build & push → Gitea Registry
    → k8s yaml image 태그 자동 업데이트 & commit
  → ArgoCD 변경 감지
    → K8s 자동 배포

🔧 최초 1회 설정

1단계. Gitea Actions Secret 등록

Gitea 저장소 → Settings → Secrets → Actions 에서 아래 3개 추가:

Secret 이름 값 예시
REGISTRY_HOST 192.168.1.100:3000
REGISTRY_USER admin (Gitea 계정명)
REGISTRY_PASSWORD Gitea 패스워드

2단계. K8s에 Registry 인증 Secret 생성

kubectl create namespace web-portal

kubectl create secret docker-registry gitea-registry-secret \
  --namespace=web-portal \
  --docker-server=192.168.1.100:3000 \
  --docker-username=<gitea계정> \
  --docker-password=<gitea패스워드> \
  --docker-email=<이메일>

3단계. K8s yaml 파일 실제 주소로 수정

아래 파일에서 192.168.x.x:3000/username 부분을 실제 주소로 변경:

  • k8s/04-backend.yaml → image 경로
  • k8s/05-frontend.yaml → image 경로
  • k8s/06-argocd-app.yaml → repoURL
  • .gitea/workflows/build-and-push.yaml → secrets로 자동 처리됨

4단계. ArgoCD Application 등록

kubectl apply -f k8s/06-argocd-app.yaml

또는 ArgoCD UI에서 직접 추가:

  • Repository URL: http://192.168.1.100:3000/username/k8s-portal.git
  • Path: k8s
  • Namespace: web-portal
  • Auto-sync: ON

5단계. Gitea에 코드 push

git init
git remote add origin http://192.168.1.100:3000/username/k8s-portal.git
git add .
git commit -m "init: web portal"
git push -u origin main

→ Gitea Actions가 자동으로 이미지 빌드 & 배포까지 진행!

⚠️ HTTP Registry 허용 설정 (중요!)

Gitea Registry가 HTTP(비SSL)인 경우 Docker에서 insecure registry 허용 필요:

Docker Desktop → Settings → Docker Engine:

{
  "insecure-registries": ["192.168.1.100:3000"]
}

K8s 노드(docker-desktop)도 동일하게 적용 필요:

# docker-desktop VM 내부 /etc/docker/daemon.json 수정 필요
# Docker Desktop 재시작 후 적용됨

🔄 이후 배포 방법

# 코드 수정 후
git add .
git commit -m "feat: 변경내용"
git push
# → 자동으로 빌드 & 배포됨!