티스토리 뷰

728x90

Harbor는 오픈 소스 컨테이너 이미지 레지스트리로, 보안 및 관리 기능을 강화한 솔루션입니다. 


1. 사전 준비

  • 운영체제: Ubuntu, CentOS 등 주요 리눅스 배포판
  • 필수 소프트웨어:
    • Docker
    • Docker Compose

2. Docker 및 Docker Compose 설치

Harbor는 Docker 컨테이너로 구성되므로, 먼저 Docker와 Docker Compose를 설치해야 합니다.

  • Docker 설치:
  • Ubuntu의 경우:
  sudo apt update
  sudo apt install -y docker.io
  • Docker Compose 설치:
  sudo curl -L "https://github.com/docker/compose/releases/download/v2.3.3/docker-compose-linux-x86_64" -o /usr/local/bin/docker-compose
  sudo chmod +x /usr/local/bin/docker-compose

설치 후 버전을 확인합니다:

  docker-compose --version

3. Harbor 설치 파일 다운로드

Harbor의 최신 버전을 GitHub에서 다운로드합니다.

wget https://github.com/goharbor/harbor/releases/download/v2.6.0/harbor-offline-installer-v2.6.0.tgz

다운로드한 파일의 압축을 해제합니다:

tar xvf harbor-offline-installer-v2.6.0.tgz
cd harbor

4. SSL 인증서 생성 (선택 사항)

보안을 위해 자체 서명된 SSL 인증서를 생성할 수 있습니다.

mkdir -p /data/cert
cd /data/cert
openssl genrsa -out ca.key 4096
openssl req -x509 -new -nodes -sha512 -days 3650 -key ca.key -out ca.crt
openssl genrsa -out harbor.key 4096
openssl req -sha512 -new -key harbor.key -out harbor.csr
openssl x509 -req -sha512 -days 3650 -in harbor.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out harbor.crt

생성된 harbor.crt와 harbor.key 파일은 이후 설정에서 사용됩니다.


5. Harbor 설정 파일 구성

Harbor 설치 디렉토리에서 기본 설정 파일을 복사하고 수정합니다:

cp harbor.yml.tmpl harbor.yml
vim harbor.yml

설정 파일에서 다음 항목을 수정합니다:

  • hostname: Harbor 서버의 도메인 또는 IP 주소
  • https:
    • port: 443 (또는 원하는 포트)
    • certificate: SSL 인증서 경로 (예: /data/cert/harbor.crt)
    • private_key: SSL 개인 키 경로 (예: /data/cert/harbor.key)
  • harbor_admin_password: 관리자 비밀번호 설정

6. Harbor 설치 및 실행

설정이 완료되면, 설치 스크립트를 실행하여 Harbor를 배포합니다:

sudo ./install.sh

설치가 완료되면, 웹 브라우저에서 https://<hostname>으로 접속하여 Harbor UI에 접근할 수 있습니다.


7. Docker 클라이언트 설정

로컬 Docker 클라이언트에서 Harbor에 접근하려면, Harbor의 인증서를 신뢰하도록 설정해야 합니다.

sudo mkdir -p /etc/docker/certs.d/<hostname>
sudo cp /data/cert/harbor.crt /etc/docker/certs.d/<hostname>/
sudo systemctl restart docker

이제 Docker 클라이언트에서 Harbor 레지스트리에 로그인할 수 있습니다:

docker login <hostname>

 

 

 

Harbor를 쿠버네티스 클러스터 상에서 설치하려면 일반적인 설치 방식과는 달리 Helm을 사용하는 방식이 가장 널리 쓰입니다. 


✅ 전제 조건

  • Kubernetes 클러스터 (Minikube, k3s, 클라우드 등)
  • kubectl CLI
  • Helm 3.x 설치
  • Ingress Controller (예: nginx-ingress) 설치 권장

🧱 1. Harbor를 위한 네임스페이스 생성

kubectl create namespace harbor

🚀 2. Harbor Helm 저장소 추가

helm repo add harbor https://helm.goharbor.io
helm repo update

⚙️ 3. 커스텀 설정 파일 작성 (values.yaml)

Helm 차트를 그대로 설치하는 것도 가능하지만, 설정을 커스터마이징하려면 values.yaml 파일을 작성하는 것이 좋습니다.

# values.yaml 예시
expose:
  type: ingress
  tls:
    enabled: true
    secretName: harbor-tls
  ingress:
    hosts:
      core: harbor.example.com
    controller: default

externalURL: https://harbor.example.com

harborAdminPassword: "Harbor12345"

persistence:
  persistentVolumeClaim:
    registry:
      storageClass: "standard"
      accessMode: ReadWriteOnce
      size: 5Gi
    jobservice:
      storageClass: "standard"
      accessMode: ReadWriteOnce
      size: 1Gi
    database:
      storageClass: "standard"
      accessMode: ReadWriteOnce
      size: 1Gi

# TLS 설정 시 미리 Secret을 만들어야 합니다.

📌 인증서가 없다면 tls.enabled: false로 설정하거나 self-signed 인증서로 secret을 만들어야 합니다.


🔐 4. TLS 인증서 Secret 만들기 (선택)

kubectl create secret tls harbor-tls \
  --cert=./harbor.crt \
  --key=./harbor.key \
  -n harbor

📦 5. Helm으로 Harbor 설치

helm install harbor harbor/harbor \
  -n harbor \
  -f values.yaml

⏱ 6. 설치 확인

kubectl get pods -n harbor

모든 Pod가 Running 상태가 될 때까지 기다립니다.


🌐 7. 접속

Ingress 주소(harbor.example.com)를 DNS에 등록했거나 /etc/hosts에 추가해야 웹으로 접속할 수 있습니다:

echo "<Ingress_IP> harbor.example.com" | sudo tee -a /etc/hosts

웹 브라우저에서 접속:

https://harbor.example.com

🎯 참고

  • 기본 관리자 계정:
    • ID: admin
    • 비밀번호: values.yaml에서 지정한 값 (예: Harbor12345)

 

728x90
250x250
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
more
«   2025/04   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
글 보관함