Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Provide an offline installation method for Helm. (#7729) #7730

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ KubeBlocks 是基于 Kubernetes 的原生应用,你可以使用 Helm 来进行

## 安装步骤

**使用 Helm 安装 KubeBlocks**
**在线安装 KubeBlocks**

1. 创建 CRD 依赖。

Expand Down Expand Up @@ -95,6 +95,125 @@ KubeBlocks 是基于 Kubernetes 的原生应用,你可以使用 Helm 来进行

:::

**离线安装 KubeBlocks**

在生产环境中,K8S 集群一般是不能连接外网的,只会允许办公环境的电脑通过 VPN 连接 K8S 集群。在线安装方式不可用,需要进行离线安装。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The situation described here may not be accurate, so it is recommended to delete the relevant content.

## 环境准备
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The heading level here is problematic: this level is the same as the previous 安装步骤, but the content is a sub-section of 离线安装 KubeBlocks , which is only a bold text

The correct hierarchy should be 安装步骤/离线安装 KubeBlocks/环境准备


<table>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why a HTML table is needed here ?

<tr>
<td colspan="3">1. K8S 集群中有可用的镜像仓库(假定为registry.kb)</td>
</tr >
<tr>
<td colspan="3">2. K8S 的部署节点安装 helm</td>
</tr >
</table>
总得来说就是将在线的crd , helm-charts,公有云镜像下载下来,然后helm install安装

1. 下载crd并安装
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's recommended to first introduce on a manifest of files that needs to be downloaded from the Internet and how to get them, then the rest of the steps only manipulate on these downloaded files.

1. 办公电脑访问下面地址,会自动下载 crd 文件
```bash
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a bash command

https://github.com/apecloud/kubeblocks/releases/download/v0.8.4-beta.11/kubeblocks_crds.yaml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The version is hard-coded here

```
2. 将文件上传到集群中,并安装 crd
```bash
kubectl create -f crds.yaml // 这里假定下载为 crds.yaml
```

2. 下载远程 helmchart 文件
```bash
helm repo add kubeblocks https://apecloud.github.io/helm-charts

helm repo update

helm fetch kubeblocks/kubeblocks --version 0.8.4-beta.11 // 这里指定了版本为 0.8.4-beta.11
```
3. 将仓库的 repo 改成集群可用的仓库,这里假定可用的是 registry.kb
1. 将下载的 helmchart 包解压,会得到一个 kubeblocks 的文件夹,进入后修改 value.yaml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not create a new values.yaml rather than edit the values.yaml in the helm chart ?

```bash
tar zxvf kubeblocks-0.8.4-beta.11
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

version hard-coded

```
2. 改对应的 repo
```bash
## KubeBlocks container image settings
##
## @param image.registry KubeBlocks image registry
## @param image.repository KubeBlocks image repository
## @param image.pullPolicy KubeBlocks image pull policy
## @param image.tag KubeBlocks image tag (immutable tags are recommended)
## @param image.imagePullSecrets KubeBlocks image pull secrets
## @param image.tools.repository KubeBlocks tools image repository
image:
registry: registry.kb //换成可用的 registry
repository: apecloud/kubeblocks
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: ""
imagePullSecrets: []
tools:
repository: apecloud/kubeblocks-tools
datascript:
repository: apecloud/kubeblocks-datascript



## @param addonChartsImage - addon charts image, used to copy Helm charts to the addon job container.
## @param addonChartsImage.chartsPath - the helm charts path in the addon charts image.
addonChartsImage:
# if the value of addonChartsImage.registry is not specified using `--set`, it will be set to the value of 'image.registry' by default
registry: "registry.kb" // 换成可用的 registry
repository: apecloud/kubeblocks-charts
pullPolicy: IfNotPresent
tag: ""
chartsPath: /charts
pullSecrets: []
```
4. 将需要的远程镜像重新 tag 推到 K8S 的镜像仓库
1. 基本需要的镜像是下面这几个
```bash
infracreate-registry.cn-zhangjiakou.cr.aliyuncs.com/apecloud/kubeblocks-datascript:0.8.4-beta.11
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image tag hard-coded

infracreate-registry.cn-zhangjiakou.cr.aliyuncs.com/apecloud/kubeblocks-tools:0.8.4-beta.11
infracreate-registry.cn-zhangjiakou.cr.aliyuncs.com/apecloud/kubeblocks:0.8.4-beta.11
infracreate-registry.cn-zhangjiakou.cr.aliyuncs.com/apecloud/snapshot-controller:v6.2.1
infracreate-registry.cn-zhangjiakou.cr.aliyuncs.com/apecloud/kubeblocks-charts:0.8.4-beta.11
```
2. 将他们重新 tag 后推到远端(以kubeblocks:0.8.4-beta.11举例)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better put these steps at the download phase

```bash
docker pull infracreate-registry.cn-zhangjiakou.cr.aliyuncs.com/apecloud/kubeblocks:0.8.4-beta.11
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

version hard-coded

docker tag infracreate-registry.cn-zhangjiakou.cr.aliyuncs.com/apecloud/kubeblocks:0.8.4-beta.11 registry.kb/apecloud/kubeblocks:0.8.4-beta.11
docker push registry.kb/apecloud/kubeblocks:0.8.4-beta.11
```
后续有需要的镜像也可以按照上面的方式添加

5. 可以将部分自动安装的 addon 关闭,只保留需要的

在kubeblocks/templates/addons 文件夹中,将对应的数据库的配置中的 autoInstall 改成 false(以 apecloud-mysql-addon.yaml举例)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shanshanying Are there any settings in KubeBlocks' values.yaml that control which addons are auto-installed when KubeBlocks is installed? This way, we wouldn't need to manually edit the addon objects in the templates to remove the addons we don't need.

```bash
{{- $selectorLabels := include "kubeblocks.selectorLabels" . }}
{{- include "kubeblocks.buildAddonCR" (merge (dict
"kbVersion" ">=0.7.0"
"selectorLabels" $selectorLabels
"name" "apecloud-mysql"
"version" "0.8.0-beta.8"
"model" "RDBMS"
"provider" "apecloud"
"description" "ApeCloud MySQL is a database that is compatible with MySQL syntax and achieves high availability through the utilization of the RAFT consensus protocol."
"autoInstall" false ) .) -}} // 将原本的 true 改成false
```
6. 部署

将原本的 kubeblocks 文件夹打包上传至集群部署节点
```bash
tar czvf kb0.8.4beta11.tgz kubeblocks
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first command is executed in your local machine that can access the Internet; the second command is executed in your server in the air-gapped environment. They shouldn't be put into the same code block.

helm install kubeblocks kubeblocks/. --create-namespace kb-system
```
:::note

中间有问题需要卸载的时候,一定要使用 helm uninstall 的方式,不能使用删除 kb-system 命名空间的方式,因为部分资源不在 kb-system 下,会导致异常。比如设置某些数据库自动安装的开关失效

:::


## 验证 KubeBlocks 安装

执行以下命令来检查 KubeBlocks 是否已成功安装。
Expand Down
Loading