Harbor在v1.6版本开始支持Helm Chart仓库功能,这样就可以利用 harbor 同时管理镜像和 helm charts 了,无需另外部署一套Helm Chart系统。在harbor中,chart仓库由chartmuseum以插件的方式提供,可以自己选择安装或者不安装。
ChartMuseum:提供了API管理非OCI规范的Helm Chart。在安装了ChartMuseum组件后,当用户使用“helm”命令向Harbor推送或拉取Chart时,Harbor的Core组件会首先收到请求,在校验后将请求转发给ChartMuseum进行Chart文件的读写。
1.修改配置文件
在absolute_url参使用ChartMuseum组件时,客户端获取到的Chart的index.yaml中包含的URL是否为绝对路径。在不配置该项时,ChartMuseum组件会返回相对路径,默认为disabled
[root@k8s-master2 harbor]# vi harbor.yml
chart:
# Change the value of absolute_url to enabled can enable absolute url in chart
absolute_url: enabled absolute_url配置由disable更成enabled
停止Harbor服务
[root@k8s-master2 harbor]# docker-compose stop
Stopping nginx ... done
Stopping harbor-jobservice ... done
Stopping harbor-core ... done
Stopping registry ... done
Stopping registryctl ... done
Stopping redis ... done
Stopping harbor-portal ... done
Stopping harbor-db ... done
Stopping harbor-log ... done
执行./prepare将新的配置注入到各个组件中。
[root@k8s-master2 harbor]# ./prepare
prepare base dir is set to /opt/harbor
WARNING:root:WARNING: HTTP protocol is insecure. Harbor will deprecate http protocol in the future. Please make sure to upgrade to https
Clearing the configuration file: /config/portal/nginx.conf
Clearing the configuration file: /config/log/logrotate.conf
Clearing the configuration file: /config/log/rsyslog_docker.conf
Clearing the configuration file: /config/nginx/nginx.conf
Clearing the configuration file: /config/core/env
Clearing the configuration file: /config/core/app.conf
Clearing the configuration file: /config/registry/passwd
Clearing the configuration file: /config/registry/config.yml
Clearing the configuration file: /config/registry/root.crt
Clearing the configuration file: /config/registryctl/env
Clearing the configuration file: /config/registryctl/config.yml
Clearing the configuration file: /config/db/env
Clearing the configuration file: /config/jobservice/env
Clearing the configuration file: /config/jobservice/config.yml
Generated configuration file: /config/portal/nginx.conf
Generated configuration file: /config/log/logrotate.conf
Generated configuration file: /config/log/rsyslog_docker.conf
Generated configuration file: /config/nginx/nginx.conf
Generated configuration file: /config/core/env
Generated configuration file: /config/core/app.conf
Generated configuration file: /config/registry/config.yml
Generated configuration file: /config/registryctl/env
Generated configuration file: /config/registryctl/config.yml
Generated configuration file: /config/db/env
Generated configuration file: /config/jobservice/env
Generated configuration file: /config/jobservice/config.yml
loaded secret from file: /data/secret/keys/secretkey
Generated configuration file: /compose_location/docker-compose.yml
Clean up the input dir
安装chartmuseum
在执行install.sh安装时,通过–with-chartmuseum参数安装chart插件,安装完后会自动启动Harbor
root@k8s-master2 harbor]# ./install.sh --with-trivy --with-chartmuseum
[Step 0]: checking if docker is installed ...
Note: docker version: 20.10.24
[Step 1]: checking docker-compose is installed ...
Note: docker-compose version: 1.22.0
[Step 2]: loading Harbor images ...
Loaded image: goharbor/harbor-portal:v2.3.4
Loaded image: goharbor/nginx-photon:v2.3.4
Loaded image: goharbor/notary-server-photon:v2.3.4
Loaded image: goharbor/trivy-adapter-photon:v2.3.4
Loaded image: goharbor/harbor-core:v2.3.4
Loaded image: goharbor/harbor-db:v2.3.4
Loaded image: goharbor/harbor-jobservice:v2.3.4
Loaded image: goharbor/registry-photon:v2.3.4
Loaded image: goharbor/prepare:v2.3.4
Loaded image: goharbor/harbor-registryctl:v2.3.4
Loaded image: goharbor/harbor-exporter:v2.3.4
Loaded image: goharbor/notary-signer-photon:v2.3.4
Loaded image: goharbor/harbor-log:v2.3.4
Loaded image: goharbor/redis-photon:v2.3.4
Loaded image: goharbor/chartmuseum-photon:v2.3.4
[Step 3]: preparing environment ...
[Step 4]: preparing harbor configs ...
prepare base dir is set to /opt/harbor
Clearing the configuration file: /config/portal/nginx.conf
Clearing the configuration file: /config/log/logrotate.conf
Clearing the configuration file: /config/log/rsyslog_docker.conf
Clearing the configuration file: /config/nginx/nginx.conf
Clearing the configuration file: /config/core/env
Clearing the configuration file: /config/core/app.conf
Clearing the configuration file: /config/registry/passwd
Clearing the configuration file: /config/registry/config.yml
Clearing the configuration file: /config/registryctl/env
Clearing the configuration file: /config/registryctl/config.yml
Clearing the configuration file: /config/db/env
Clearing the configuration file: /config/jobservice/env
Clearing the configuration file: /config/jobservice/config.yml
Error happened in config validation...
ERROR:root:Error: the protocol must be https when Harbor is deployed with Notary
#查看启动的服务
[root@k8s-master2 harbor]# docker-compose ps
Name Command State Ports
---------------------------------------------------------------------------------------------------------------------
chartmuseum ./docker-entrypoint.sh Up (health: starting)
harbor-core /harbor/entrypoint.sh Up (health: starting)
harbor-db /docker-entrypoint.sh 96 13 Up (health: starting)
harbor-jobservice /harbor/entrypoint.sh Up (health: starting)
harbor-log /bin/sh -c /usr/local/bin/ ... Up (health: starting) 127.0.0.1:1514->10514/tcp
harbor-portal nginx -g daemon off; Up (health: starting)
nginx nginx -g daemon off; Up (health: starting) 0.0.0.0:5000->8080/tcp,:::5000->8080/tcp
redis redis-server /etc/redis.conf Up (health: starting)
registry /home/harbor/entrypoint.sh Up (health: starting)
registryctl /home/harbor/start.sh Up (health: starting)
trivy-adapter /home/scanner/entrypoint.sh Up (health: starting)
验证是否安装了chartmuseum组件
登录Harbor UI管理界面:【项目】>【library】> 【Helm Charts】