kubeSphere使用应用商店安装部署Harbor
从应用商店中部署 Harbor
-
查看是否已安装应用商店。
若未安装,则可以阅读 Linux安装部署KubeSphere基于k8s集群 的启用可插拔功能组件
-
找到 Harbor,设置名称并选择应用版本,点击下一步。
-
在应用配置页面,编辑 Harbor 的配置文件,请注意以下字段。
type:访问 Harbor 服务的方式。本示例使用 nodePort。
tls:指定是否启用 HTTPS。多数情况下设置为 false。
commonName:192.168.18.111 #填写自己的IP地址,用于访问的地址,这里我填写k8s-master1的IP地址。
externalURL:暴露给租户的 URL。tls 设置为 false 使用http://192.168.18.111:30002。
若 tls 设置为 true 使用https://192.168.18.111:30003。
访问 Harbor
基于配置文件中 expose.type 字段的设置,访问方式可能会不同。本示例使用 nodePort 访问 Harbor,按照先前步骤中的设置,访问http://nodeIP:30002。

若 tls 设置为 true,访问https://nodeIP:30003。

使用默认帐户和密码 (admin/Harbor12345) 登录 Harbor。密码由配置文件中的 harborAdminPassword 字段定义。

所有节点添加 Harbor 镜像仓库
Harbor根据 tls 设置使用 HTTP 和 HTTPS 为仓库请求提供服务。
-
HTTP
您需要修改集群中所有节点的 Docker 配置,如果外部 Harbor 仓库的 IP 地址为http://192.168.18.111:30002,您需要在 /etc/docker/daemon.json 文件中增加 insecure-registries 标签。
1
2
3
4
5
6
7
8vi /etc/docker/daemon.json
{
"registry-mirrors": ["https://0nth4654.mirror.aliyuncs.com"],
"insecure-registries": ["http://192.168.18.111:30002"]
}
# 重启docker
systemctl daemon-reload && systemctl restart docker若为低版本docker。
1
2
3
4
5
6vi /usr/lib/systemd/system/docker.service
#修改
ExecStart=/usr/bin/docker daemon -H fd:// --insecure-registry 192.168.18.111:30002
#重启服务
systemctl daemon-reload && systemctl restart docker进入配置中心密钥页面,创建密钥。
-
HTTPS
您需要修改集群中所有节点的 Docker 配置,如果外部 Harbor 仓库的 IP 地址为https://192.168.18.111:30003,您需要在 /etc/docker/daemon.json 文件中增加 insecure-registries 标签。
1
2
3
4
5
6
7
8vi /etc/docker/daemon.json
{
"registry-mirrors": ["https://0nth4654.mirror.aliyuncs.com"],
"insecure-registries": ["https://192.168.18.111:30003"]
}
# 重启docker
systemctl daemon-reload && systemctl restart docker若为低版本docker。
1
2
3
4
5
6vi /usr/lib/systemd/system/docker.service
#修改
ExecStart=/usr/bin/docker daemon -H fd:// --insecure-registry 192.168.18.111:30003
#重启服务
systemctl daemon-reload && systemctl restart docker进入配置中心密钥页面,创建密钥。
Harbor 镜像仓库域名设置
因为 KubeSphere 无法直接解析 harbor 域名,需要在 coredns 添加解析记录
将nodelocaldns解析都转发给coredns

1 | forward . 10.233.0.3 { |

在coredns中添加主机记录

1 | hosts { |

通过 configmap 加载 CA 证书
进入 harbor-core 工作负载。

进入终端查看CA证书的位置及值,复制值。


界面进入工作台>企业空间>System-workspace>项目>kubesphere-system>配置中心>配置,新建harbor4shl-ca


挂载 configmap harbor4shl-ca
进入 ks-apiserve 工作负载。





验证
进入配置中心的密钥,创建密钥。