配置要求
硬件
资源 | 最低 | 推荐 |
---|---|---|
CPU | 2 CPU | 4 CPU |
Mem | 4 GB | 8 GB |
Disk | 40 GB | 160 GB |
软件
docker v17.06.0-ce+ Docker 引擎文档
docker-compose v1.18.0+ Docker Compose 文档
OpenSSL
网络端口
HTTPS 443/4443
HTTP 80
安装
仓库
https://github.com/goharbor/harbor/releases
文档
https://goharbor.io/docs/2.5.3/install-config/download-installer/
harbor
证书ca.key
https://goharbor.io/docs/2.5.3/install-config/configure-https/
生成CA私钥
1 | openssl genrsa -out ca.key 4096 |
生成CA证书
1 | openssl req -x509 -new -nodes -sha512 -days 3650 \ |
服务器证书
生成私钥
1 | openssl genrsa -out k8s.org.key 4096 |
生成证书签名请求(CSR)
1 | openssl req -sha512 -new \ |
生成一个x509 v3扩展文件
1 | cat > v3.ext <<-EOF |
使用该v3.ext文件为您的Harbor主机生成证书
1 | openssl x509 -req -sha512 -days 3650 \ |
Docker守护程序将.crt文件解释为CA证书,并将.cert文件解释为客户端证书
1 | openssl x509 -inform PEM -in k8s.org.crt -out k8s.org.cert |
harbor.yml
代理网址 https://ghproxy.com 下载
1 | cs@debian:~/下载/新建文件夹$ md5sum harbor-offline-installer-v2.5.3.tgz |
1 | sed -n '/hostname/s/reg.mydomain.com/192.168.56.1/'p ./harbor/harbor.yml.tmpl |
hostname
https port ,certificate,private_key
external_url
harbor_admin_password
data_volume
用外部数据库,redis时需要配置 external_database,external_redis
1 | sudo ./install.sh |
默认的 Harbor 安装不包括 Notary 或 Trivy 等服务
./install.sh –with-notary –with-trivy –with-chartmuseum
–with-notary 数据权限
–with-trivy 漏洞扫描
–with-chartmuseum helm
docker
certs.d
1 | tree -L 3 /etc/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/
daemon.json
1 | { |
insecure-registries 私库地址,非域名格式 ip:端口
login
登录密码会保存认证,下次push镜像就不需要输入密码了
1 | cs@debian:~$ docker login k8s.org |
nginx
/opt/nginx/conf/conf.d/http/harbor.conf
1 | upstream harbors{ |
error parsing HTTP 413 response body: ……
413 Request Entity Too Large client_max_body_size
推送
域名/目录/镜像名:版本号
1 | docker images | grep etcd |
项目
镜像
高可用
通过配置数据库(mysql ,redis集群),存储来实现
ERROR
pull Retrying in
https://github.com/vmware/harbor/issues/3062
/opt/nginx/conf/nginx.conf
1 | http { |
1 | http: |
harbor的helm里需要加上registry.relativeurls=true
参考:https://github.com/docker/distribution/issues/970#issuecomment-284227065
ImagePullBackOff
创建一个基于现有凭证的 Secret
1 | $ kubectl create secret generic login --from-file=.dockerconfigjson=/home/cs/.docker/config.json --type=kubernetes.io/dockerconfigjson |
在命令行上提供凭证来创建 Secret
1 | kubectl create secret docker-registry regcred \ |
在这里:
- 是你的私有 Docker 仓库全限定域名(FQDN)。 DockerHub 使用 https://index.docker.io/v1/。
- 是你的 Docker 用户名。
- 是你的 Docker 密码。
- 是你的 Docker 邮箱。
这样你就成功地将集群中的 Docker 凭证设置为名为 regcred 的 Secret
检查 Secret
1 | $ kubectl get secrets |
1 | $ kubectl get secret login --output="jsonpath={.data.\.dockerconfigjson}" | base64 --decode |
1 | echo "YWRtaW46Y3MxMjM0NTY=" | base64 --decode |
pod
创建一个使用你的 Secret 的 Pod
1 | apiVersion: v1 |
版本升级
2.1.0->2.8.3
❯ tar -xvf ./harbor-offline-installer-v2.8.3.tgz
harbor/harbor.v2.8.3.tar.gz
harbor/prepare
harbor/LICENSE
harbor/install.sh
harbor/common.sh
harbor/harbor.yml.tmpl
❯ docker image load -i harbor.v2.8.3.tar.gz
Loaded image: goharbor/registry-photon:v2.8.3
Loaded image: goharbor/notary-server-photon:v2.8.3
Loaded image: goharbor/notary-signer-photon:v2.8.3
Loaded image: goharbor/harbor-log:v2.8.3
Loaded image: goharbor/redis-photon:v2.8.3
Loaded image: goharbor/harbor-jobservice:v2.8.3
Loaded image: goharbor/prepare:v2.8.3
Loaded image: goharbor/harbor-core:v2.8.3
Loaded image: goharbor/harbor-registryctl:v2.8.3
Loaded image: goharbor/nginx-photon:v2.8.3
Loaded image: goharbor/trivy-adapter-photon:v2.8.3
Loaded image: goharbor/harbor-portal:v2.8.3
Loaded image: goharbor/harbor-db:v2.8.3
Loaded image: goharbor/harbor-exporter:v2.8.3
❯ docker run -it --rm -v /:/hostfs goharbor/prepare:v2.8.3 migrate -i /opt/kubernetes/harbor//harbor.yml
❯ docker run -it –rm -v /:/hostfs goharbor/prepare:v2.8.3 migrate -i /opt/kubernetes/harbor/harbor.yml
migrating to version 2.1.0
migrating to version 2.2.0
migrating to version 2.3.0
migrating to version 2.4.0
migrating to version 2.5.0
migrating to version 2.6.0
migrating to version 2.7.0
migrating to version 2.8.0
Written new values to /opt/kubernetes/harbor/harbor.yml
1 | ❯ docker rmi `docker images | grep goharbor | grep 2.1 | awk '{print $3}'` |
postgresql 数据版本升级利用 pg_upgrade
工具 –待实验
https://blog.csdn.net/heran36/article/details/131250813
1 | ❯ docker run -it --rm -v /:/hostfs goharbor/prepare:v2.9.0 migrate -i /opt/kubernetes/harbor/harbor.yml |
不支持mysql
docker run -it –rm -v /etc/harbor:/etc/harbor -v /data/database:/var/lib/mysql goharbor/harbor-db:v2.9.0 prepare -i /home/cs/oss/k8s-1.26/tar/harbor/harbor.yml
1 | MySQL root@localhost:(none)> create database harbor default character set utf8mb4; |