一个计算机技术爱好者与学习者

0%

好好学Sealos:Sealos制作imagepullsecret-patcher集群镜像

1. 前言

本文中,我们会基于sealos制作一个Milvus集群镜像。
使用这个集群镜像,我们能够在sealos拉起的K8S集群中,一键部署imagepullsecret-patcher。

参考文档:

2. 前置条件

安装sealos4.2.0,拉起K8S 1.24.8集群(同时安装helm),具体方法参考《sealos入门篇》

3. 制作imagepullsecret-patcher集群镜像

1、准备helm chart

1
2
3
4
5
6
mkdir imagepullsecret-patcher && cd imagepullsecret-patcher
git clone https://github.com/voidking/hexo-storage.git
cp -r hexo-storage/make-helm-chart/imagepullsecret-patcher .
tar -xzvf imagepullsecret-patcher-0.1.0.tgz imagepullsecret-patcher
rm hexo-storage -rf
rf imagepullsecret-patcher -rf

【TODO:共享Chart仓库】

资源清单内容参考文档:make-helm-chart/v2/imagepullsecret-patcher

2、添加镜像列表

1
2
3
cat manifests/* | grep image
mkdir -p images/shim/
vim images/shim/images-list.txt

images-list.txt 内容为:

1
quay.io/titansoft/imagepullsecret-patcher:v0.14

3、编写Dockerfile

1
2
3
4
FROM scratch
COPY ../imagepullsecret-patcher .
CMD ["helm install imagepullsecret-patcher imagepullsecret-patcher-0.1.0.tgz \
-n imagepullsecret-patcher --create-namespace"]

默认安装到 imagepullsecret-patcher 命名空间。

4、构建集群镜像

1
2
sealos build -f Dockerfile -t docker.io/voidking/imagepullsecret-patcher:v0.14 .
sealos inspect docker.io/voidking/imagepullsecret-patcher:v0.14

4. 使用imagepullsecret-patcher集群镜像

4.1. 自定义安装

1
2
3
4
5
6
7
sealos run docker.io/voidking/imagepullsecret-patcher:v0.14 --cmd="helm install imagepullsecret-patcher imagepullsecret-patcher-0.1.0.tgz \
-n imagepullsecret-patcher --create-namespace \
--set imageCredentials.registry=harbor.voidking.com \
--set imageCredentials.username=haojin \
--set imageCredentials.password=haojin123"

kubectl get all -n imagepullsecret-patcher

4.2. 上传集群镜像

上传到公共镜像仓库

1
2
3
4
sealos push docker.io/voidking/imagepullsecret-patcher:v0.14
sealos tag docker.io/voidking/imagepullsecret-patcher:v0.14 hub.sealos.cn/voidking/imagepullsecret-patcher:v0.14
sealos login -k config.yml hub.sealos.cn
sealos push hub.sealos.cn/voidking/imagepullsecret-patcher:v0.14

上传到私有镜像仓库

1
2
3
sealos tag docker.io/voidking/imagepullsecret-patcher:v0.14 harbor.voidking.com/sealos/imagepullsecret-patcher:v0.14
sealos login harbor.voidking.com
sealos push harbor.voidking.com/sealos/cert-manager:v0.14

4.3. 修改harbor账密

imagepullsecret-patcher helm安装包有些问题,源secret和目标secret名称都是harbor-secret,需要修一下。
想要修改harbor账密时,需要先把服务停掉,再修改harbor-secret,否则会被服务自动改回。