Harbor 是一个开源的可信云原生仓库项目,用于对内容进行存储、签名和扫描。通过增加用户经常需要的功能,例如安全、身份验证和管理,Harbor 扩展了开源的 Docker Distribution。Harbor 使用 HTTP 和 HTTPS 为仓库请求提供服务。

KubeSphere 是在 Kubernetes 之上构建的以应用为中心的多租户容器平台,提供全栈的 IT 自动化运维的能力,简化企业的 DevOps 工作流。KubeSphere 提供了运维友好的向导式操作界面,帮助企业快速构建一个强大和功能丰富的容器云平台。


Harbor安装:Harbor私有仓库的部署

k8s可视化管理平台KubeSphere及k8s的安装: kubesphere安装k8s

目标

使用k8s拉取Harbor的镜像

准备工作

harbor服务器与k8s集群是一个内网段

您需要在KubeSphere创建一个企业空间、一个项目和一个用户(例如 project-regular)。该用户必须已邀请至该项目,并具有 operator 角色。有关更多信息,请参阅创建企业空间、项目、用户和角色

设置保密字典

以 project-regular 用户登录 KubeSphere Web 控制台并进入项目,在左侧导航栏中选择配置下的保密字典,然后点击创建

 设置名称,选择镜像服务信息

填写相关信息 (如需使用 Harbor 域名而非 IP 地址,您需要在集群中配置 CoreDNS 和 nodelocaldns。)

仓库地址:镜像仓库的地址

用户名:登录镜像仓库所需的用户名。

密码:登录镜像仓库所需的密码。

邮箱(可选):您的邮箱地址。

如果你在安装Harbor配置了Https可选择https,否则用http

点击验证,看是否成功 

添加 Harbor 镜像仓库

HTTP

①你需要修改k8s集群中所有节点的 Docker 配置。

如果外部 Harbor 仓库的 IP 地址为 http://192.168.0.99,您需要在 /etc/systemd/system/docker.service.d/docker-options.conf 文件中增加 --insecure-registry=192.168.0.99 标签。(记得修改成你的harbor的ip,harbor和k8s在一个内网,推荐用内网ip)

[Service] Environment="DOCKER_OPTS=--registry-mirror=https://registry.docker-cn.com --insecure-registry=10.233.0.0/18 --data-root=/var/lib/docker --log-opt max-size=50m --log-opt max-file=5 \ --insecure-registry=192.168.0.99"

我在修改时发现一个问题,很多版本只有/etc/systemd/system/docker.service配置文件了,那么久直接修改/etc/systemd/system/docker.service文件就行了。在ExecStart的末尾加上      --insecure-registry=192.168.0.99 标签

[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
#ExecStart=/usr/bin/dockerd
ExecStart=/usr/bin/dockerd --insecure-registry=xx.xx.xx.xx
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always

重新加载配置文件并重启 Docker。

sudo systemctl daemon-reload


sudo systemctl restart docker

如需使用 Harbor 域名而非 IP 地址,您需要在集群中配置 CoreDNS 和 nodelocaldns。

HTTPS

有关如何集成基于 HTTPS 的 Harbor 仓库,请参阅 Harbor 官方文档。请确保您已使用 docker login 命令连接到您的 Harbor 仓库。

使用镜像仓库

在Kubernetes 点击工作负载,点击创建

在容器组设置选择你的仓库(前面--insecure-registry用的内网,这里也要用内网)

填写你私有仓库镜像的名称以及标签

注意名称和标签中间的  :   符号需要用英文字符格式。

等后续,我对其KubeSphere更加了解,如果有更好的方式,我会持续更新的

如果文章对您有用的话,记得点赞关注噢

GitHub 加速计划 / ha / harbor
10
3
下载
Harbor 是一个开源的容器镜像仓库,用于存储和管理 Docker 镜像和其他容器镜像。 * 容器镜像仓库、存储和管理 Docker 镜像和其他容器镜像 * 有什么特点:支持多种镜像格式、易于使用、安全性和访问控制
最近提交(Master分支:6 个月前 )
45659070 Fix integration issue with UI Signed-off-by: stonezdj <stone.zhang@broadcom.com> 1 天前
add0b600 chore(deps): bump go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp Bumps [go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp](https://github.com/open-telemetry/opentelemetry-go) from 1.31.0 to 1.34.0. - [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md) - [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.31.0...v1.34.0) --- updated-dependencies: - dependency-name: go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> 3 天前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐