hello

Setup VM 구성

VM 설계 목표

  1. 완전 오프라인 운영: 외부 네트워크 차단 환경에서 모든 GitOps 작업 수행 가능
  2. 자체 인증서 관리: Self-Signed 인증서 생성/관리 자동화
  3. 종속성 미러링: 모든 패키지/이미지/차트의 로컬 저장소 보유
  4. 30분 내 클러스터 재구성: 재해 복구 시 빠른 환경 복원

VM 구성 상세 설계

핵심 컴포넌트 구성

도구 역할 라이선스 오프라인 대응 방안
Gitea 로컬 Git 저장소 MIT 모든 코드/설정 파일 보유, 웹훅 트리거 내부 네트워크 연동
Harbor 컨테이너 이미지 & Helm 차트 저장소 Apache 2.0 필수 이미지 미리 패키징, air-gapped 배포 지원
ArgoCD GitOps 배포 관리자 Apache 2.0 Gitea와 직접 연동, 배포 현황 로컬 모니터링
Nexus3 바이너리 미러 저장소 Eclipse Public License RKE2 패키지, Helm 차트, OS 패키지 미러링

하드웨어 요구사항

VM Specifications:
  CPU: 4 Core (최소) / 8 Core (권장)
  Memory: 16GB (최소) / 32GB (권장)
  Storage:
    - OS 볼륨: 50GB (ext4)
    - Docker 볼륨: 100GB (xfs)
    - 데이터 볼륨: 200GB (미러 저장용, lvm)
  Network: 
    - 내부 관리망: 1Gbps
    - 클러스터 통신망: 10Gbps (권장)

구성 방식

1. 오프라인 환경 준비

Nexus3 미러링 구성

# RKE2 패키지 미러링
nexus3 repository create rke2-rpm --type=apt
nexus3 mirror add https://releases.rancher.com/rke2/

# Helm 차트 미러링
helm repo add local http://nexus3:8081/repository/helm-charts/
helm repo mirror https://charts.bitnami.com/bitnami local

2. Docker Compose 기반 서비스 배포

version: '3'
services:
  gitea:
    image: gitea/gitea:1.21
    volumes:
      - ./gitea:/data
    networks:
      - gitops-net

  harbor:
    image: goharbor/harbor:v2.10
    depends_on:
      - postgresql
    environment:
      - HARBOR_ADMIN_PASSWORD=admin123
    networks:
      - gitops-net

  nexus3:
    image: sonatype/nexus3:3.58.1
    ports:
      - "8081:8081"
    volumes:
      - ./nexus-data:/nexus-data

GitOps 워크플로우

  1. 개발자 → Gitea (코드 커밋)
  2. ArgoCD → Gitea 변경 감지
  3. ArgoCD → Harbor (이미지 풀)
  4. ArgoCD → Kubernetes (매니페스트 배포)
  5. Nexus3 ↔ 모든 외부 패키지 요청 처리

주기적 미러 업데이트

nexus3 mirror update --repo=rke2-rpm --url=https://releases.rancher.com

이 구성을 통해 인터넷 연결 없이도 완전한 GitOps 사이클을 구현할 수 있으며, AI 기반 자동화를 통해 단일 운영자가 효율적으로 관리할 수 있는 환경이 조성됩니다. 모든 구성 요소의 라이선스는 상용 사용이 가능한 오픈소스로 선정되어 법적 리스크 없이 운영 가능합니다.

Vagrant + VirtualBox 기반 IaC 구축 가이드

Vagrant 소개 및 사용법
Vagrant는 개발 환경을 코드로 관리할 수 있도록 도와주는 오픈 소스 도구
Vagrant.configure("2") do |config|
  config.vm.box = "generic/ubuntu2404"
  config.vm.hostname = "gitops-server"
  
  # 리소스 할당
  config.vm.provider "virtualbox" do |vb|
    vb.cpus = 4
    vb.memory = 16384 # 16GB
    vb.customize ["modifyvm", :id, "--ioapic", "on"]
  end

  # 포트 포워딩
  config.vm.network "forwarded_port", guest: 8081, host: 8081 # Nexus3
  config.vm.network "forwarded_port", guest: 80, host: 8080 # Harbor
  config.vm.network "forwarded_port", guest: 3000, host: 3000 # Gitea

  # 프로비저닝 스크립트
  config.vm.provision "shell", inline: <<-SHELL
    #!/bin/bash

    # Docker 설치
    apt-get update
    apt-get install -y docker.io
    systemctl enable --now docker
    usermod -aG docker vagrant

    # Docker Compose 설치
    curl -L "https://github.com/docker/compose/releases/download/v2.26.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
    chmod +x /usr/local/bin/docker-compose

    # Nexus3 설치
    apt-get install -y openjdk-17-jdk
    useradd -m nexus
    cd /opt
    wget https://download.sonatype.com/nexus/3/latest-unix.tar.gz
    tar -xzf latest-unix.tar.gz
    ln -s nexus-3* nexus
    chown -R nexus:nexus /opt/nexus /opt/sonatype-work
    cat <<EOF > /etc/systemd/system/nexus.service
    [Unit]
    Description=Nexus Service
    After=network.target

    [Service]
    Type=forking
    User=nexus
    ExecStart=/opt/nexus/bin/nexus start
    ExecStop=/opt/nexus/bin/nexus stop
    Restart=on-abort

    [Install]
    WantedBy=multi-user.target
    EOF
    systemctl enable --now nexus.service

    # Harbor 설치
    curl -s https://api.github.com/repos/goharbor/harbor/releases/latest | grep browser_download_url | cut -d '"' -f 4 | grep '\\.tgz$' | wget -i -
    tar -xzvf harbor-offline-installer-*.tgz
    cd harbor
    cp harbor.yml.tmpl harbor.yml
    sed -i 's/hostname:.*/hostname: localhost/' harbor.yml
    sed -i 's/port: 80/port: 8080/' harbor.yml
    ./install.sh --with-trivy --with-chartmuseum

    # Gitea 설치
    apt-get install -y git sqlite3
    adduser --system --shell /bin/bash --gecos 'Git Version Control' --group --disabled-password --home /home/git git
    wget -O /usr/local/bin/gitea https://dl.gitea.com/gitea/1.21.5/gitea-1.21.5-linux-amd64
    chmod +x /usr/local/bin/gitea
    mkdir -p /var/lib/gitea/{custom,data,log}
    chown -R git:git /var/lib/gitea
    cat <<EOF > /etc/systemd/system/gitea.service
    [Unit]
    Description=Gitea
    After=network.target

    [Service]
    User=git
    WorkingDirectory=/var/lib/gitea/
    ExecStart=/usr/local/bin/gitea web --config /etc/gitea/app.ini
    Restart=always

    [Install]
    WantedBy=multi-user.target
    EOF
    systemctl enable --now gitea.service
  SHELL
end

초기 접속 방법