Skip to content

Commit 134504d

Browse files
authored
Merge pull request #294 from hangscer8/add_doc_airgap_patch_usage
Add Doc For Airgap Patch
2 parents 936d304 + b42c3c1 commit 134504d

File tree

3 files changed

+105
-56
lines changed

3 files changed

+105
-56
lines changed

build/images/airgap-patch/Dockerfile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,23 @@ WORKDIR /kubean
77

88
COPY artifacts /kubean/artifacts
99

10+
COPY charts /kubean/charts
11+
1012
RUN ARCH="$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/')" \
1113
&& apt-get update \
1214
&& apt-get install -y wget curl \
1315
&& wget https://github.com/lework/skopeo-binary/releases/download/v1.9.3/skopeo-linux-$ARCH \
1416
&& chmod +x skopeo-linux-$ARCH \
1517
&& mv skopeo-linux-$ARCH /usr/bin/skopeo \
18+
&& wget https://github.com/mikefarah/yq/releases/download/v4.29.2/yq_linux_$ARCH \
19+
&& chmod +x yq_linux_$ARCH \
20+
&& mv yq_linux_$ARCH /usr/bin/yq \
1621
&& ln -s /kubespray /kubean/kubespray
1722

18-
CMD echo "starting generating airgap patch files" \
23+
CMD echo "printing supporting versions" \
24+
&& bash artifacts/manage_version_cr.sh create_manifest \
25+
&& echo $(yq -o=json '.spec.components' charts/kubean/templates/manifest.cr.yaml) \
26+
&& echo "starting generating airgap patch files" \
1927
&& MANIFEST_CONF=/manifest.yml python3 artifacts/offline_patch.py \
2028
&& echo "copying data" \
2129
&& mv v_* /data \

docs/airgap_patch_usage.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# 增量离线包的生成和使用
2+
3+
为了满足用户对于某些软件特定版本的需要,kubean提供脚本`artifacts/offline_patch.py`用来根据配置文件`manifest.yml`
4+
来生成对应版本的离线包。
5+
6+
## 生成增量离线包:
7+
8+
1. 在当前文件夹新建`manifest.yml`文件,内容举例如下:
9+
10+
```yaml
11+
image_arch:
12+
- "amd64"
13+
- "arm64"
14+
kube_version:
15+
- "v1.24.6"
16+
- "v1.24.4"
17+
calico_version:
18+
- "v3.23.3"
19+
cni_version:
20+
- "v1.1.1"
21+
containerd_version:
22+
- "1.6.8"
23+
cilium_version:
24+
- "v1.12.1"
25+
etcd_version:
26+
- "v3.5.3"
27+
```
28+
29+
2. 在当前文件夹新建`data`文件夹
30+
31+
3. 使用镜像,等待运行退出后,`data`文件夹中生成增量离线包
32+
33+
```bash
34+
docker run -v $(pwd)/manifest.yml:/manifest.yml -v $(pwd)/data:/data ghcr.io/hangscer8/airgap-patch:v0.2.0
35+
```
36+
37+
## 使用增量离线包:
38+
39+
增量包的目录结构如下:
40+
41+
```
42+
data
43+
└── v_offline_patch
44+
├── amd64
45+
│   ├── files
46+
│   │   ├── import_files.sh
47+
│   │   └── offline-files.tar.gz
48+
│   └── images
49+
│   ├── import_images.sh
50+
│   └── offline-images.tar.gz
51+
├── arm64
52+
│   ├── files
53+
│   │   ├── import_files.sh
54+
│   │   └── offline-files.tar.gz
55+
│   └── images
56+
│   ├── import_images.sh
57+
│   └── offline-images.tar.gz
58+
└── kubeanofflineversion.cr.patch.yaml
59+
```
60+
61+
1. 向 minio 中写入文件数据
62+
63+
``` bash
64+
$ cd data/v_offline_patch/amd64/files
65+
66+
$ MINIO_USER=${username} MINIO_PASS=${password} ./import_files.sh ${minio_address}
67+
```
68+
69+
* `minio_address` 是 `minio API Server`地址,端口一般为9000,比如 `http://1.2.3.4:9000`
70+
71+
2. 向 docker registry (版本推荐使用2.6.2) 或者 harbor 写入镜像数据
72+
73+
``` bash
74+
$ cd data/v_offline_patch/amd64/images
75+
76+
# 1. 非安全免密模式
77+
$ DEST_TLS_VERIFY=false ./import_images.sh ${registry_address}
78+
79+
# 2. 用户名口令模式
80+
$ DEST_USER=${username} DEST_PASS=${password} ./import_images.sh ${registry_address}
81+
```
82+
83+
* 当 `DEST_TLS_VERIFY=false`, 此时采用非安全 HTTP 模式上传镜像
84+
* 当镜像仓库存在用户名密码验证时,需要设置 `DEST_USER` 和 `DEST_PASS`
85+
* `registry_address` 是镜像仓库的地址,比如`1.2.3.4:5000`
86+
87+
3. 将 `kubeanofflineversion.cr.patch.yaml` 写入到 k8s 集群
88+
89+
```bash
90+
$ cd data/v_offline_patch
91+
$ kubectl apply -f kubeanofflineversion.cr.patch.yaml
92+
```
93+
94+
* 该步骤是为了将新的可离线使用的软件版本信息告知 kubean-operator

docs/offline.zh.md

Lines changed: 2 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -288,59 +288,6 @@ nerdctl_download_url: "{{ files_repo }}/github.com/containerd/nerdctl/releases/d
288288

289289
最终, 通过 `kubectl apply -f artifacts/offlineDemo` 启动 ClusterOperation 任务来安装 k8s 集群.
290290

291-
## 增量离线包
292-
293-
为了满足用户对于某些软件特定版本的需要,kubean提供脚本`artifacts/offline_patch.py`用来根据配置文件`manifest.yml`来生成对应版本的离线包。
294-
295-
### 脚本使用前提:
296-
TODO: 后续提供docker镜像
297-
298-
* python3 + ansible环境
299-
* skopeo wget git vim 命令行工具
300-
301-
### 使用步骤:
302-
303-
1. 下载kubean代码 `git clone https://github.com/kubean-io/kubean.git`
304-
2. `cd kubean`,`git clone https://github.com/kubernetes-sigs/kubespray.git`
305-
3. 编写`manifest.yml`文件,内容如下:
306-
307-
```yaml
308-
image_arch:
309-
- "amd64"
310-
- "arm64"
311-
kube_version:
312-
- "v1.24.6"
313-
- "v1.24.4"
314-
calico_version:
315-
- "v3.23.3"
316-
cni_version:
317-
- "v1.1.1"
318-
containerd_version:
319-
- "1.6.8"
320-
cilium_version:
321-
- "v1.12.1"
322-
etcd_version:
323-
- "v3.5.3"
324-
```
291+
## 增量离线包的生成和使用
325292

326-
4. 使用`artifacts/offline_patch.py`脚本,执行 `MANIFEST_CONF=manifest.yml python3 artifacts/offline_patch.py`
327-
5. 查看增量离线包`v_offline_patch`
328-
329-
```yaml
330-
v_offline_patch
331-
├── amd64
332-
│   ├── files
333-
│   │   ├── import_files.sh
334-
│   │   └── offline-files.tar.gz
335-
│   ├── images
336-
│   │   ├── import_images.sh
337-
│   │   └── offline-images.tar.gz
338-
├── arm64
339-
│   ├── files
340-
│   │   ├── import_files.sh
341-
│   │   └── offline-files.tar.gz
342-
│   ├── images
343-
│   │   ├── import_images.sh
344-
│   │   └── offline-images.tar.gz
345-
└── kubeanofflineversion.cr.patch.yaml
346-
```
293+
详细文档见[airgap_patch_usage](airgap_patch_usage.md)

0 commit comments

Comments
 (0)