安装 helm
snap install helm --classic
下载harbor chart
helm repo add harbor https://helm.goharbor.io
helm fetch harbor/harbor --untar
创建harbor证书
# 生成key
mkdir ./harbor-ca
cd ./harbor-ca
openssl genrsa -out tls.key
# 生成crt
openssl req -x509 -new -nodes -key tls.key -subj "/CN=harbor.server.com" -days 7120 -out tls.crt -keyout tls.pem
# 复制(如用的K8s,需复制到其他Node)
mkdir -pv /etc/docker/certs.d/harbor.server.com/
cp tls.crt /etc/docker/certs.d/harbor.server.com/
cd ..
创建harbor证书
# 生成key
mkdir ./notary-ca
cd ./notary-ca
openssl genrsa -out tls.key
# 生成crt
openssl req -x509 -new -nodes -key tls.key -subj "/CN=notary.server.com" -days 7120 -out tls.crt -keyout tls.pem
# 复制(如用的K8s,需复制到其他Node)
mkdir -pv /etc/docker/certs.d/notary.server.com/
cp tls.crt /etc/docker/certs.d/notary.server.com/
cd ..
配置
cd harbor
vi ./values.yaml
expose.type: nodePort
expose.tls.auto.commonName: "harbor.server.com"
expose.tls.secret.secretName: "<harbor证书文件夹路径>"
expose.tls.secret.notarySecretName: "<notary证书文件夹路径>"
externalURL: https://harbor.server.com
persistence.enabled: false # 关闭持久化功能
harborAdminPassword: "<admin登录密码>"
# arm64需要替换掉所有镜像
*.image.repository: cocl666/*
*.image.tag: v2.2.2
# arm64需要替换掉所有镜像,redis-photon镜像配置
*.image.repository: harborarm/redis-photon
*.image.tag: dev
安装kube-flannel(x86_64)
# x86_64
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
安装kube-flannel(arm64)
# arm64
wget https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
vi kube-flannel.yml
所有image后面标签加上"-arm64"
kubectl apply -f ./kube-flannel.yml
安装harbor
# 安装
kubectl create namespace harbor-helm
helm install my-release . -n harbor-helm
# 查看是否正常启动
kubectl get pods -n harbor-helm
kubectl describe pods -n harbor-helm
修改/etc/hosts文件,添加:
<127.0.0.1或IP地址> harbor.server.com notary.server.com
访问Harbor页面,并新增用户
# 浏览器打开IP
https://127.0.0.1:30003
用新用户登录Docker
# 输入账号与密码
docker login harbor.server.com:30003
修改镜像名称
docker tag <镜像原名称>:<tag> harbor.server.com:30003/<镜像名称>:<tag>
推送镜像
docker push harbor.server.com:30003/<镜像名称>:<tag>
拉取镜像
docker pull harbor.server.com:30003/<镜像名称>:<tag>
卸载(可选)
helm uninstall my-release -n harbor-helm