标签归档:helm

支持 helm 的 harbor 版本

Harbor在v1.6版本开始支持Helm Chart仓库功能,- 从v2.6.0 开始弃用Chartmuseum,并在v2.8.0中开始删除。更多详情,请参阅讨论:https://github.com/goharbor/harbor/discussions/15057 从 v2.6.0 开始弃用 Notary(签名者和服务器),并在 v2.8.0 中开始删除。更多详情,请参阅讨论:https://github.com/goharbor/harbor/discussions/16612

安装Chartmuseum组件

修改配置文件

  在absolute_url​参使用ChartMuseum​组件时,客户端获取到的Chart的index.yaml​中包含的URL是否为绝对路径。在不配置该项时,ChartMuseum组件会返回相对路径,默认为disabled。

$ vim  harbor.yml
chart:
  # Change the value of absolute_url to enabled can enable absolute url in chart
  absolute_url: enabled

enabled表示使用绝对路径!

停止Harbor

$ docker-compose stop

注入配置

  执行./prepare将新的配置注入到各个组件中。

$  ./prepare

安装chartmuseum

  在执行install.sh安装时,通过–with-chartmuseum参数安装chart插件,安装完后会自动启动Harbor。

$ ./install.sh  --with-notary --with-trivy --with-chartmuseum
✔ ----Harbor has been installed and started successfully.----  #输出该信息则表示安装成功

查看组件服务状态

  通过docker-compose ps命令可以看到harbor的组件中多了个chartmuseum的容器。

$ docker-compose ps

验证是否安装了chartmuseum组件

登录Harbor UI管理界面:【项目】==>【library】==> 【Helm Charts】

References

#Harbor #Docker

推送 helm 到 harbor

大致流程如下:

helm repo add harbor https://myharbor.mydomain.com/chartrepo/myproject --username myusername --password mypassword

helm plugin install https://github.com/chartmuseum/helm-push

helm repo add chartmuseum http://localhost:8080

helm cm-push mychart/ chartmuseum

References

使用脚本镜像 helm charts 仓库

#!/bin/bash  

# 源 Harbor 配置  
SOURCE_HARBOR="harbor.xxx.com"  
SOURCE_PROJECT="xx-xxx"  
#SOURCE_PROJECT="xxx"  
#SOURCE_USER="username"  
#SOURCE_PASS="password"  

# 目标 Harbor 配置  
DEST_HARBOR="192.168.25.8:10443"  
DEST_PROJECT="xxx-xxx"  
DEST_USER="admin"  
DEST_PASS="xxx@xxx"  
DEST_CA_FILE="/etc/docker/certs.d/192.168.25.8:10443/ca.crt"  

# 添加源和目标 Harbor 仓库/  
helm repo remove source-repo || true  
helm repo remove dest-repo || true  
helm repo add source-repo https://$SOURCE_HARBOR/chartrepo/$SOURCE_PROJECT #--username $SOURCE_USER --password $SOURCE_PASS  
helm repo add dest-repo https://$DEST_HARBOR/chartrepo/$DEST_PROJECT --username $DEST_USER --password $DEST_PASS --ca-file $DEST_CA_FILE  

# 更新 repo  
helm repo update  

# 获取所有 charts  
charts=$(helm search repo source-repo/ -o json | jq -r '.[].name')  

# 遍历并同步每个 chart  
for chart in $charts  
do  
   echo "sync with [$chart]"  
   # 获取所有版本t  
   versions=$(helm search repo $chart -l -o json | jq -r '.[].version')  
   chart_name=${chart#source-repo/}  
   # 遍历每个版本c  
   for version in $versions  
   do  
       echo "sync with [$chart] [$version]"  
       # 下载特定版本的 chart  
       helm pull $chart --version $version  

       # 推送到目标仓库t  
       helm cm-push ${chart_name}-${version}.tgz dest-repo --ca-file $DEST_CA_FILE  

       # 清理下载的文件c  
       rm ${chart_name}-${version}.tgz  
   done  
done