Technical architectural analysis, practical configuration manifests, and deployment instructions for Harbor Container Registry on Docker with.
Closed network
Ready
ubuntu 20.04
> ๐ก
docker
โ containerd.io/now 1.6.6-1 amd64 \[installed,local\]
โ docker-ce-cli/now 5:19.03.15\~3-0\~ubuntu-focal amd64 \[installed,local\]
โ docker-ce/now 5:19.03.15\~3-0\~ubuntu-focal amd64 \[installed,local\]
โ docker-compose-plugin/now 2.6.0\~ubuntu-focal amd64 \[installed,local\]
โ libseccomp2/now 2.5.1-1ubuntu1\~20.04.2 amd64 \[installed,local\]
docker-compose
โ docker-compose version 1.21.2, build a133471
nfs-common
โ nfs-common/now 1:1.3.4-2.5ubuntu3.4 amd64 \[installed,local\]
pool
> ๐ก
[https://download.docker.com/linux/ubuntu/dists/focal/pool/stable/amd64/](https://download.docker.com/linux/ubuntu/dists/focal/pool/stable/amd64/)
https://download.docker.com/linux/\{\{os\}\}/dist/\{\{os-ver\}\}/pool/stable/\{\{architecture\}\}/
โ Download the items below
โ containerd.io\_1.6.6-1\_amd64.deb
โ docker-ce-cli\_19.03.15\~3-0\~ubuntu-focal\_amd64.deb
โ docker-ce\_19.03.15\~3-0\~ubuntu-focal\_amd64.deb
โ docker-compose-plugin\_2.6.0\~ubuntu-focal\_amd64.deb
[http://archive.ubuntu.com/ubuntu/pool/main/libs/libseccomp/libseccomp2\_2.5.1-1ubuntu1\~20.04.2\_amd64.deb ](http://archive.ubuntu.com/ubuntu/pool/main/libs/libseccomp/libseccomp2_2.5.1-1ubuntu1~20.04.2_amd64.deb)
โ Download containerd dependencies
[http://archive.ubuntu.com/ubuntu/pool/universe/d/docker-compose/](http://archive.ubuntu.com/ubuntu/pool/universe/d/docker-compose/)
โ Download docker-compose
Installation
# docker.io package ์ค์น
dpkg -i *.deb
# nfs-common package ์ค์น
dpkg -i *.deb
# docker-compose ์ค์น
cp ./docker-compose /usr/bin/
# ๋ฐ์ดํฐ๊ฒฝ๋ก ์ง์
mkdir /${TARGET_PATH} # /data
# NFS ๋ง์ดํธ
mount -t nfs ${NFS_SERVER_IP}:/${TARGET_NFS_VOLUME} /${TARGET_PATH}
mount -l | grep data
# ๊ฐ์๋จธ์ ์ฌ๊ธฐ๋ ํด๋ NFS ์๋ ๋ง์ดํธ
sudo vi /etc/fstab
--- # ์๋ ๋ด์ฉ ์ถ๊ฐ
${NFS_SERVER_IP}:/${TARGET_NFS_VOLUME} /${TARGET_PATH} nfs defaults 0
---
# harbor ์์ถํด์
tar xzvf harbor-offline-installer-v2.1.0.tgz
# harbor.yml ์์ฑ
cp harbor.yml.tmpl harbor.yml
vi harbor.yml
<--- # ์๋ ๋ด์ฉ ๋ณ๊ฒฝ
hostname: $harbor_domain
#https
# https port for harbor, default is 443
# port: 443
# The path of cert and key files for nginx
# certificate: /your/certificate/path
# private_key: /your/private/key/path
harbor_admin_password: $password
# Harbor DB configuration
database:
# The password for the root user of Harbor DB. Change this before any production use.
password: $password
# The default data volume
data_volume: /data
...
externalHost ๋ณ๊ฒฝ( ํ๋ก์ ์ฌ์ฉ์ )
--->
# harbor ์ค์น
chmod +x install.sh
./install.sh
# insecure ์ง์
vi /etc/docker/daemon.json
<---
{
"insecure-registries" : ["$domain"]
}
--->
# docker ์ฌ์์
systemctl restart docker
docker info | grep insecure
# host ๋ฑ๋ก -- haproxy ๋ฑ๋ก ํ์
vi /etc/hosts
{ haproxy host } $harbor_domain
# login
docker login $harbor_domain -u admin -p $password
# ์ ์์ ์ธ ๊ฒฝ์ฐ
systemctl status docker
>>>
โ docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2023-01-11 11:16:41 UTC; 1min 3s ago
TriggeredBy: โ docker.socket
Docs: https://docs.docker.com
Main PID: 19273 (dockerd)
Tasks: 44
Memory: 53.8M
CGroup: /system.slice/docker.service
โโ19273 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
โโ19428 /usr/bin/docker-proxy -proto tcp -host-ip 127.0.0.1 -host-port 1514 -container-ip 172.18.0.2 -container-port 10514
โโ19642 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 80 -container-ip 172.18.0.10 -container-port 8080
<<<
https settings
Create certification authority certificate
# CA ์ธ์ฆ์ ๊ฐ์ธํค ์์ฑ
openssl genrsa -out ca.key 4096
# CA ์ธ์ฆ์ ์์ฑ
# -subj์กฐ์ง์ ๋ฐ์ ํ๋๋ก ์ต์
์ ๊ฐ์ ์กฐ์ ํ์ญ์์ค. FQDN์ ์ฌ์ฉํ์ฌ ํ๋ฒ ํธ์คํธ๋ฅผ ์ฐ๊ฒฐํ๋ ๊ฒฝ์ฐ ์ผ๋ฐ ์ด๋ฆ( CN) ํน์ฑ์ผ๋ก ์ง์ ํด์ผ ํฉ๋๋ค.
openssl req -x509 -new -nodes -sha512 -days 3650 \
-subj "/C=CN/ST=Beijing/L=Beijing/O=example/OU=Personal/CN=$domain" \
-key ca.key \
-out ca.crt
Generate server certificate
# ๊ฐ์ธ ํค ์์ฑ
openssl genrsa -out yourdomain.com.key 4096
# ์ธ์ฆ์ ์๋ช
์์ฒญ(CSR) ์์ฑ
# -subj์กฐ์ง์ ๋ฐ์ ํ๋๋ก ์ต์
์ ๊ฐ์ ์กฐ์ ํ์ญ์์ค. FQDN์ ์ฌ์ฉํ์ฌ Harbor ํธ์คํธ๋ฅผ ์ฐ๊ฒฐํ๋ ๊ฒฝ์ฐ FQDN์ ์ผ๋ฐ ์ด๋ฆ( CN) ์์ฑ์ผ๋ก ์ง์ ํ๊ณ ํค ๋ฐ CSR ํ์ผ ์ด๋ฆ์ ์ฌ์ฉํด์ผ ํฉ๋๋ค.
openssl req -sha512 -new \
-subj "/C=CN/ST=Beijing/L=Beijing/O=example/OU=Personal/CN=$domain" \
-key yourdomain.com.key \
-out yourdomain.com.csr
# x509 v3 ํ์ฅ ํ์ผ์ ์์ฑ
# FQDN ๋๋ IP ์ฃผ์๋ฅผ ์ฌ์ฉํ์ฌ Harbor ํธ์คํธ์ ์ฐ๊ฒฐํ๋์ง ์ฌ๋ถ์ ๊ด๊ณ์์ด SAN(์ฃผ์ฒด ๋์ฒด ์ด๋ฆ) ๋ฐ x509 v3์ ์ค์ํ๋ Harbor ํธ์คํธ์ ๋ํ ์ธ์ฆ์๋ฅผ ์์ฑํ ์ ์๋๋ก ์ด ํ์ผ์ ๋ง๋ค์ด์ผ ํฉ๋๋ค. ํ์ฅ ์๊ตฌ ์ฌํญ. DNS๋๋ฉ์ธ์ ๋ฐ์ ํ๋๋ก ํญ๋ชฉ์ ๋ฐ๊ฟ๋๋ค .
cat > v3.ext <<-EOF
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
extendedKeyUsage = serverAuth
subjectAltName = @alt_names
[alt_names]
DNS.1=yourdomain.com
DNS.2=yourdomain
DNS.3=hostname
EOF
# ํ์ผ์ ์ฌ์ฉ v3.extํ์ฌ Harbor ํธ์คํธ์ ๋ํ ์ธ์ฆ์๋ฅผ ์์ฑํ์ญ์์ค.
# yourdomain.comCRS ๋ฐ CRT ํ์ผ ์ด๋ฆ์ Harbor ํธ์คํธ ์ด๋ฆ์ผ๋ก ๋ฐ๊ฟ๋๋ค .
openssl x509 -req -sha512 -days 3650 \
-extfile v3.ext \
-CA ca.crt -CAkey ca.key -CAcreateserial \
-in yourdomain.com.csr \
-out yourdomain.com.crt
Provide certificates to Harbor and Docker
# ์๋ฒ ์ธ์ฆ์์ ํค๋ฅผ Harbor ํธ์คํธ์ ์ธ์ฆ์ ํด๋์ ๋ณต์ฌ
cp yourdomain.com.crt /data/cert/
cp yourdomain.com.key /data/cert/
# Docker์์ ์ฌ์ฉํ ์ ์๋๋ก ๋ก ๋ณํ
# Docker ๋ฐ๋ชฌ์ .crtํ์ผ์ CA ์ธ์ฆ์๋ก, .certํ์ผ์ ํด๋ผ์ด์ธํธ ์ธ์ฆ์๋ก ํด์ํฉ๋๋ค.
openssl x509 -inform PEM -in yourdomain.com.crt -out yourdomain.com.cert
# ์๋ฒ ์ธ์ฆ์, ํค ๋ฐ CA ํ์ผ์ Harbor ํธ์คํธ์ Docker ์ธ์ฆ์ ํด๋์ ๋ณต์ฌํฉ๋๋ค. ๋จผ์ ์ ์ ํ ํด๋๋ฅผ ๋ง๋ค์ด์ผ ํฉ๋๋ค.
cp yourdomain.com.cert /etc/docker/certs.d/yourdomain.com/
cp yourdomain.com.key /etc/docker/certs.d/yourdomain.com/
cp ca.crt /etc/docker/certs.d/yourdomain.com/
# nginx๊ธฐ๋ณธ ํฌํธ 443์ ๋ค๋ฅธ ํฌํธ์ ๋งคํํ ๊ฒฝ์ฐ ํด๋ /etc/docker/certs.d/yourdomain.com:port๋๋ /etc/docker/certs.d/harbor_IP:port.
# Docker ์์ง์ ๋ค์ ์์
systemctl restart docker
#์ฌ์ฉ์ ์ง์ ์ธ์ฆ์ ์ฌ์ฉ ๊ตฌ์ฑ
/etc/docker/certs.d/
โโโ yourdomain.com:port
โโโ yourdomain.com.cert <-- Server certificate signed by CA
โโโ yourdomain.com.key <-- Server key signed by CA
โโโ ca.crt <-- Certificate authority that signed the registry certificate
Harbor Reorganization
# ์ด๋ฏธ HTTP๋ก Harbor๋ฅผ ๋ฐฐํฌํ์ผ๋ฉฐ HTTPS๋ฅผ ์ฌ์ฉํ๋๋ก ์ฌ๊ตฌ์ฑํ๋ ค๋ ๊ฒฝ์ฐ ๋ค์ ๋จ๊ณ๋ฅผ ์ํํ์ญ์์ค.
# prepare์คํฌ๋ฆฝํธ๋ฅผ ์คํํ์ฌ HTTPS๋ฅผ ํ์ฑํํ์ญ์์ค.
# Harbor๋ nginx์ธ์คํด์ค๋ฅผ ๋ชจ๋ ์๋น์ค์ ๋ํ ๋ฆฌ๋ฒ์ค ํ๋ก์๋ก ์ฌ์ฉํฉ๋๋ค. prepare์คํฌ๋ฆฝํธ๋ฅผ ์ฌ์ฉํ์ฌ HTTPS๋ฅผ ์ฌ์ฉํ๋๋ก ๊ตฌ์ฑ ํฉ๋๋ค nginx. ์คํฌ๋ฆฝํธ prepare์ ๋์ผํ ์์ค์ Harbour ์ค์น ํ๋ก๊ทธ๋จ ๋ฒ๋ค์ ์์ต๋๋ค .install.sh
./prepare
# Harbor๊ฐ ์คํ ์ค์ธ ๊ฒฝ์ฐ ๊ธฐ์กด ์ธ์คํด์ค๋ฅผ ์ค์งํ๊ณ ์ ๊ฑฐํ์ญ์์ค.
# ์ด๋ฏธ์ง ๋ฐ์ดํฐ๋ ํ์ผ ์์คํ
์ ๋จ์ ์์ผ๋ฏ๋ก ๋ฐ์ดํฐ๊ฐ ์์ค๋์ง ์์ต๋๋ค.
docker-compose down -v
# ํ๋ฒ ์ฌ์์
docker-compose up -d
Check HTTPS connection
After you set up HTTPS for Harbor, you can verify HTTPS connectivity by performing the following steps:
-
Open your browser and type https://yourdomain.com.ย You should see the Harbor interface.
Some browsers may display a warning that the Certificate Authority (CA) is unknown.ย This happens when you use a self-signed CA rather than a trusted third-party CA.ย You can remove the warning by importing the CA into your browser.
-
Check the
/etc/docker/daemon.jsonfile on the system running the Docker daemon to ensure that the option for https://yourdomain.cominsecure-registryis not set. - Log in to Harbor from your Docker client.
docker login yourdomain.com
If you have mapped port 443 to another port, add the port to the command nginx.login
docker login yourdomain.com:port




Leave a Reply