[export] 使用easyctl导出harbor中镜像tag列表

背景说明

一些场景需要获取镜像tag列表(比如:批量导出镜像时)

安装easyctl

  1. 编译安装最新版
git clone https://github.com/weiliang-ms/easyctl.git
cd easyctl
go build -ldflags "-w -s" -o /usr/local/bin/easyctl
  1. 下载编译好的文件

easyctl-v0.7.5-alpha

chmod +x easyctl
mv easyctl /usr/local/bin

使用方式

  1. 生成默认配置文件
[root@localhost ~]# easyctl export harbor-image-list
I0928 21:19:46.803428   10628 export.go:41] 检测到配置文件参数为空,生成配置文件样例 -> config.yaml
  1. 修改配置文件

vi config.yaml

harbor-repo:
  schema: http                      # 不可修改(暂不支持https harbor)
  address: 192.168.1.1:80           # harbor连接地址
  domain: harbor.wl.io              # harbor域
  user: admin                       # harbor用户
  password: Harbor-12345            # harbor用户密码
  preserve-dir: harbor-image-list   # 不建议修改,持久化tag
  projects:                         # 导出哪些项目下的镜像tag(如果为空表示全库导出)
    - apache                        # project名称
    - weaveworks
  excludes:                         # 配置'projects'空值使用,过滤某些project
    - ddd
  1. 导出
easyctl export harbor-image-list -c config.yaml --debug

单项目导出

导出单项目镜像列表

  1. 配置信息(部分内容已脱敏)
harbor:
  schema: http
  address: *.*.*.*
  domain: harbor.wl.io
  user: admin
  password: ******
  preserve-dir: harbor-image-list
  projects:
    - apache
  1. 导出语句,--debug输出debug日志,可选参数
easyctl export harbor-image-list -c config.yaml --debug
  • 目录文件结构如下:
/work                               # 执行命令的目录
├── config.yaml                     # 配置文件
└── harbor-image-list               # 存放镜像列表文件的目录(内部按项目建立文件夹进行隔离)
    ├── apache                      # apache项目目录,存放apache下镜像列表文件
    │   └── image-list.txt    # apache下镜像列表文件
    └── images-list.txt             # 导出项目下的所有镜像列表(x/image-list.txt xx/image-list.txt等内容合集)
  • images/images-list.txt内容
[root@localhost work]# cat images/images-list.txt
harbor.wl.io/apache/skywalking-java-agent:8.6.0-alpine
harbor.wl.io/apache/skywalking-oap-server:8.6.0-es7
harbor.wl.io/apache/skywalking-ui:8.6.0
  • images/apache/image-list.txt内容
[root@localhost work]# cat images/apache/image-list.txt
harbor.wl.io/apache/skywalking-java-agent:8.6.0-alpine
harbor.wl.io/apache/skywalking-oap-server:8.6.0-es7
harbor.wl.io/apache/skywalking-ui:8.6.0

多项目导出

导出一个以上项目下镜像列表

  1. 配置信息(部分内容已脱敏)
harbor:
  schema: http
  address: *.*.*.*
  domain: harbor.wl.io
  user: admin
  password: ******
  preserve-dir: harbor-image-list
  projects:
    - apache
    - b2i
  1. 导出语句,--debug输出debug日志,可选参数
easyctl export harbor-image-list -c config.yaml --debug
  • 目录文件结构如下:
/work/                              # 执行命令的目录
├── config.yaml                     # 配置文件
└── harbor-image-list               # 存放镜像列表文件的目录(内部按项目建立文件夹进行隔离)
    ├── apache                      # apache项目目录,存放apache下镜像列表文件
    │   └── image-list.txt    # apache下镜像列表文件
    ├── b2i                         # b2i项目目录,存放b2i下镜像列表文件
    │   └── image-list.txt    # b2下镜像列表文件
    └── images-list.txt             # 导出项目下的所有镜像列表(x/image-list.txt xx/image-list.txt等内容合集)
  • images/images-list.txt内容
[root@localhost work]# cat images/images-list.txt
harbor.wl.io/apache/skywalking-java-agent:8.6.0-alpine
harbor.wl.io/apache/skywalking-oap-server:8.6.0-es7
harbor.wl.io/apache/skywalking-ui:8.6.0
harbor.wl.io/b2i/binary-nginx-builder:latest
harbor.wl.io/b2i/nginx-centos7-s2ibuilder:latest
harbor.wl.io/b2i/java-8-runtime:base-alpha
harbor.wl.io/b2i/java-8-runtime:base
harbor.wl.io/b2i/java-8-runtime:advance
harbor.wl.io/b2i/java-8-centos7:base
harbor.wl.io/b2i/java-8-centos7:advance
harbor.wl.io/b2i/tomcat9-java8-runtime:latest
harbor.wl.io/b2i/tomcat8-java8-runtime:latest
harbor.wl.io/b2i/tomcat8-java8-centos7:latest
harbor.wl.io/b2i/tomcat9-java8-centos7:latest
  • images/apache/image-list.txt内容
[root@localhost work]# cat images/apache/image-list.txt
harbor.wl.io/apache/skywalking-java-agent:8.6.0-alpine
harbor.wl.io/apache/skywalking-oap-server:8.6.0-es7
harbor.wl.io/apache/skywalking-ui:8.6.0
  • images/b2i/image-list.txt内容
[root@localhost work]# cat images/apache/image-list.txt
harbor.wl.io/b2i/binary-nginx-builder:latest
harbor.wl.io/b2i/nginx-centos7-s2ibuilder:latest
harbor.wl.io/b2i/java-8-runtime:base-alpha
harbor.wl.io/b2i/java-8-runtime:base
harbor.wl.io/b2i/java-8-runtime:advance
harbor.wl.io/b2i/java-8-centos7:base
harbor.wl.io/b2i/java-8-centos7:advance
harbor.wl.io/b2i/tomcat9-java8-runtime:latest
harbor.wl.io/b2i/tomcat8-java8-runtime:latest
harbor.wl.io/b2i/tomcat8-java8-centos7:latest
harbor.wl.io/b2i/tomcat9-java8-centos7:latest

全项目导出

导出全部项目下镜像列表

  1. 配置信息(部分内容已脱敏)
harbor:
  schema: http
  address: *.*.*.*
  domain: harbor.wl.io
  user: admin
  password: ******
  export-all: true
  preserve-dir: harbor-image-list
  projects:
  • 导出语句
easyctl export harbor-image-list -c config.yaml --debug
  • 目录文件结构如下:
/work/                              # 执行命令的目录
├── config.yaml                     # 配置文件
└── harbor-image-list               # 存放镜像列表文件的目录(内部按项目建立文件夹进行隔离)
    ├── apache                      # apache项目目录,存放apache下镜像列表文件
    │   └── image-list.txt    # apache下镜像列表文件
    ├── b2i                         # b2i项目目录,存放b2i下镜像列表文件
    │   └── image-list.txt    # b2下镜像列表文件
    └── images-list.txt             # 导出项目下的所有镜像列表(x/image-list.txt xx/image-list.txt等内容合集)
    ├── ceph-csi
    │   └── image-list.txt
    ├── champ
    │   └── image-list.txt
    ├── charts
    │   └── image-list.txt
    ├── csiplugin
    │   └── image-list.txt
    ├── elastic
    │   └── image-list.txt
    ├── elasticsearch
    │   └── image-list.txt
    ├── grafana
    │   └── image-list.txt
    ├── hsa-cep
    │   └── image-list.txt
    ├── hsa-k8s-public
    │   └── image-list.txt
    ├── images-list.txt
    ├── istio
    │   └── image-list.txt
    ├── jaegertracing
    │   └── image-list.txt
    ├── jenkins
    │   └── image-list.txt
    ├── jimmidyson
    │   └── image-list.txt
    ├── kubernetes
    │   └── image-list.txt
    ├── kubesphere
    │   └── image-list.txt
    ├── library
    │   └── image-list.txt
    ├── minio
    │   └── image-list.txt
    ├── openebs
    │   └── image-list.txt
    ├── openpitrix
    │   └── image-list.txt
    ├── osixia
    │   └── image-list.txt
    ├── paas
    │   └── image-list.txt
    ├── prom
    │   └── image-list.txt
    └── weaveworks
        └── image-list.txt
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
镜像push到Harbor后,如果镜像丢失,可能有几个原因。首先,可能是在推送镜像的过程出现了错误,导致镜像没有成功上传到Harbor。其次,可能是在推送镜像后,Harbor的存储空间不足,导致镜像被删除以释放空间。最后,可能是在Harbor的配置设置了自动清理策略,导致镜像被自动删除。 为了解决这个问题,可以按照以下步骤进行排查和处理: 1. 首先,检查推送镜像的过程是否有任何错误信息。可以查看推送镜像的命令输出或者Harbor的日志文件,以确定是否有任何错误发生。 2. 确保Harbor的存储空间足够,可以通过查看Harbor的存储配置或者联系系统管理员来确认。 3. 检查Harbor的配置,查看是否设置了自动清理策略。如果设置了自动清理策略,可以调整策略或者禁用自动清理来避免镜像被删除。 4. 如果以上步骤都没有解决问题,可以尝试重新推送镜像Harbor,并确保推送过程没有任何错误。 通过以上步骤,您应该能够解决镜像push到Harbor后丢失的问题。如果问题仍然存在,建议您联系Harbor的技术支持或者咨询相关专业人士以获取进一步的帮助。 #### 引用[.reference_title] - *1* *2* *3* [如何正确推送镜像到私有仓库Harbor(http方式)](https://blog.csdn.net/Xin_101/article/details/124422018)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值