-
Notifications
You must be signed in to change notification settings - Fork 117
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
zh: helm offline document #378
Merged
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
7e70cea
helm offline
weekface f0c5d2a
fix ci
weekface 0512fdc
tiny fix
weekface 85fc8b5
Apply suggestions from code review
weekface 37de330
Update zh/tidb-toolkit.md
weekface 74267d9
Merge branch 'master' into helm-offline
ran-huang 2493df8
Merge branch 'master' into helm-offline
ran-huang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -138,26 +138,94 @@ tidb-ctl schema in mysql | |
|
||
[Helm](https://helm.sh/) 是一个 Kubernetes 的包管理工具,确保安装的 Helm 版本为 >= 2.11.0 && < 3.0.0 && != [2.16.4](https://github.com/helm/helm/issues/7797)。安装步骤如下: | ||
|
||
1. 参考[官方文档](https://v2.helm.sh/docs/using_helm/#installing-helm)安装 Helm 客户端 | ||
1. 参考[官方文档](https://v2.helm.sh/docs/using_helm/#installing-helm)安装 Helm 客户端。 | ||
|
||
如果服务器没有外网,需要先将 Helm 客户端在有外网的机器上下载下来,然后再拷贝到服务器上,这里以安装 Helm 客户端 `2.16.7` 为例: | ||
|
||
{{< copyable "shell-regular" >}} | ||
|
||
```shell | ||
wget https://get.helm.sh/helm-v2.16.7-linux-amd64.tar.gz | ||
tar zxvf helm-v2.16.7-linux-amd64.tar.gz | ||
``` | ||
|
||
解压之后,有以下文件: | ||
|
||
```shell | ||
linux-amd64/ | ||
linux-amd64/README.md | ||
linux-amd64/tiller | ||
linux-amd64/helm | ||
linux-amd64/LICENSE | ||
``` | ||
|
||
请自行将 `linux-amd64/helm` 文件拷贝到服务器上,并将其放到 `/usr/local/bin/` 目录下即可。 | ||
|
||
然后执行 `helm verison -c`,如果正常输出则表示 Helm 客户端安装成功: | ||
|
||
{{< copyable "shell-regular" >}} | ||
|
||
```shell | ||
helm version -c | ||
``` | ||
|
||
```shell | ||
Client: &version.Version{SemVer:"v2.16.7", GitCommit:"5f2584fd3d35552c4af26036f0c464191287986b", GitTreeState:"clean"} | ||
``` | ||
|
||
2. 安装 Helm 服务端 | ||
|
||
在集群中应用 Helm 服务端组件 `tiller` 所需的 `RBAC` 规则,并安装 `tiller`: | ||
|
||
{{< copyable "shell-regular" >}} | ||
|
||
```shell | ||
kubectl apply -f https://raw.githubusercontent.com/pingcap/tidb-operator/master/manifests/tiller-rbac.yaml && \ | ||
kubectl apply -f https://raw.githubusercontent.com/pingcap/tidb-operator/v1.1.0/manifests/tiller-rbac.yaml && \ | ||
helm init --service-account=tiller --upgrade | ||
``` | ||
|
||
如果无法访问 gcr.io,你可以尝试 mirror 仓库: | ||
如果服务器没有外网,需要先用有外网的机器下载 `tiller-rbac.yaml` 文件: | ||
|
||
{{< copyable "shell-regular" >}} | ||
|
||
```shell | ||
wget https://raw.githubusercontent.com/pingcap/tidb-operator/v1.1.0/manifests/tiller-rbac.yaml | ||
``` | ||
|
||
将 `tiller-rbac.yaml` 文件拷贝到服务器上并安装 `tiller`: | ||
|
||
{{< copyable "shell-regular" >}} | ||
|
||
```shell | ||
kubectl apply -f tiller-rbac.yaml | ||
helm init --service-account=tiller --skip-refresh | ||
``` | ||
|
||
Helm 服务端是一个名字叫 `tiller` 的服务,是作为一个 Pod 运行在 Kubernetes 集群里的。这个 Pod 使用的镜像是 `gcr.io/kubernetes-helm/tiller:v2.16.7`,如果无法访问 gcr.io,你可以尝试 mirror 仓库: | ||
|
||
{{< copyable "shell-regular" >}} | ||
|
||
``` shell | ||
helm init --service-account=tiller --upgrade --tiller-image registry.cn-hangzhou.aliyuncs.com/google_containers/tiller:$(helm version --client --short | grep -Eo 'v[0-9]\.[0-9]+\.[0-9]+') | ||
``` | ||
|
||
如果服务器没有外网或者无法访问 `gcr.io` 和 `registry.cn-hangzhou.aliyuncs.com`,需要先将 `tiller` Docker 镜像在有外网的机器下载下来: | ||
|
||
{{< copyable "shell-regular" >}} | ||
|
||
``` shell | ||
docker pull gcr.io/kubernetes-helm/tiller:v2.16.7 | ||
docker save -o tiller-v2.16.7.tar gcr.io/kubernetes-helm/tiller:v2.16.7 | ||
``` | ||
|
||
将 `tiller-v2.16.7.tar` 文件拷贝到服务器上,执行 `docker load` 命令将其 load 到服务器上: | ||
|
||
{{< copyable "shell-regular" >}} | ||
|
||
``` shell | ||
docker load -i tiller-v2.16.7.tar | ||
``` | ||
|
||
通过下面命令确认 `tiller` Pod 进入 running 状态: | ||
|
||
{{< copyable "shell-regular" >}} | ||
|
@@ -174,94 +242,119 @@ tidb-ctl schema in mysql | |
helm init --upgrade | ||
``` | ||
|
||
Kubernetes 应用在 Helm 中被打包为 chart。PingCAP 针对 Kubernetes 上的 TiDB 部署运维提供了多个 Helm chart: | ||
3. 配置 Helm repo | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这里提一下没网络的话直接跳到 step 4? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 都是一个 list 上下两项,无需频繁提及。 |
||
|
||
* `tidb-operator`:用于部署 TiDB Operator; | ||
* `tidb-cluster`:用于部署 TiDB 集群; | ||
* `tidb-backup`:用于 TiDB 集群备份恢复; | ||
* `tidb-lightning`:用于 TiDB 集群导入数据; | ||
* `tidb-drainer`:用于部署 TiDB Drainer; | ||
* `tikv-importer`:用于部署 TiKV Importer; | ||
Kubernetes 应用在 Helm 中被打包为 chart。PingCAP 针对 Kubernetes 上的 TiDB 部署运维提供了多个 Helm chart: | ||
|
||
这些 chart 都托管在 PingCAP 维护的 helm chart 仓库 `https://charts.pingcap.org/` 中,你可以通过下面的命令添加该仓库: | ||
* `tidb-operator`:用于部署 TiDB Operator; | ||
* `tidb-cluster`:用于部署 TiDB 集群; | ||
* `tidb-backup`:用于 TiDB 集群备份恢复; | ||
* `tidb-lightning`:用于 TiDB 集群导入数据; | ||
* `tidb-drainer`:用于部署 TiDB Drainer; | ||
* `tikv-importer`:用于部署 TiKV Importer; | ||
|
||
{{< copyable "shell-regular" >}} | ||
这些 chart 都托管在 PingCAP 维护的 helm chart 仓库 `https://charts.pingcap.org/` 中,你可以通过下面的命令添加该仓库: | ||
|
||
```shell | ||
helm repo add pingcap https://charts.pingcap.org/ | ||
``` | ||
{{< copyable "shell-regular" >}} | ||
|
||
```shell | ||
helm repo add pingcap https://charts.pingcap.org/ | ||
``` | ||
|
||
添加完成后,可以使用 `helm search` 搜索 PingCAP 提供的 chart: | ||
添加完成后,可以使用 `helm search` 搜索 PingCAP 提供的 chart: | ||
|
||
如果 Helm 版本 < 2.16.0: | ||
- 如果 Helm 版本 < 2.16.0: | ||
|
||
{{< copyable "shell-regular" >}} | ||
{{< copyable "shell-regular" >}} | ||
|
||
```shell | ||
helm search pingcap -l | ||
``` | ||
```shell | ||
helm search pingcap -l | ||
``` | ||
|
||
如果 Helm 版本 >= 2.16.0: | ||
- 如果 Helm 版本 >= 2.16.0: | ||
|
||
{{< copyable "shell-regular" >}} | ||
{{< copyable "shell-regular" >}} | ||
|
||
```shell | ||
helm search pingcap -l --devel | ||
``` | ||
```shell | ||
helm search pingcap -l --devel | ||
``` | ||
|
||
``` | ||
NAME CHART VERSION APP VERSION DESCRIPTION | ||
pingcap/tidb-backup v1.0.0 A Helm chart for TiDB Backup or Restore | ||
pingcap/tidb-cluster v1.0.0 A Helm chart for TiDB Cluster | ||
pingcap/tidb-operator v1.0.0 tidb-operator Helm chart for Kubernetes | ||
... | ||
``` | ||
``` | ||
NAME CHART VERSION APP VERSION DESCRIPTION | ||
pingcap/tidb-backup v1.0.0 A Helm chart for TiDB Backup or Restore | ||
pingcap/tidb-cluster v1.0.0 A Helm chart for TiDB Cluster | ||
pingcap/tidb-operator v1.0.0 tidb-operator Helm chart for Kubernetes | ||
... | ||
``` | ||
|
||
当新版本的 chart 发布后,你可以使用 `helm repo update` 命令更新本地对于仓库的缓存: | ||
当新版本的 chart 发布后,你可以使用 `helm repo update` 命令更新本地对于仓库的缓存: | ||
|
||
{{< copyable "shell-regular" >}} | ||
{{< copyable "shell-regular" >}} | ||
|
||
``` | ||
helm repo update | ||
``` | ||
``` | ||
helm repo update | ||
``` | ||
|
||
Helm 的常用操作有部署(`helm install`)、升级(`helm upgrade`)、销毁(`helm del`)、查询(`helm ls`)。Helm chart 往往都有很多可配置参数,通过命令行进行配置比较繁琐,因此推荐使用 YAML 文件的形式来编写这些配置项,基于 Helm 社区约定俗称的命名方式,我们在文档中将用于配置 chart 的 YAML 文件称为 `values.yaml` 文件。 | ||
Helm 的常用操作有部署(`helm install`)、升级(`helm upgrade`)、销毁(`helm del`)、查询(`helm ls`)。Helm chart 往往都有很多可配置参数,通过命令行进行配置比较繁琐,因此推荐使用 YAML 文件的形式来编写这些配置项,基于 Helm 社区约定俗称的命名方式,我们在文档中将用于配置 chart 的 YAML 文件称为 `values.yaml` 文件。 | ||
|
||
执行部署、升级、销毁等操作前,可以使用 `helm ls` 查看集群中已部署的应用: | ||
执行部署、升级、销毁等操作前,可以使用 `helm ls` 查看集群中已部署的应用: | ||
|
||
{{< copyable "shell-regular" >}} | ||
{{< copyable "shell-regular" >}} | ||
|
||
```shell | ||
helm ls | ||
``` | ||
```shell | ||
helm ls | ||
``` | ||
|
||
在执行部署和升级操作时,必须指定使用的 chart 名字(`chart-name`)和部署后的应用名(`release-name`),还可以指定一个或多个 `values.yaml` 文件来配置 chart。此外,假如对 chart 有特定的版本需求,则需要通过 `--version` 参数指定 `chart-version` (默认为最新的 GA 版本)。命令形式如下: | ||
在执行部署和升级操作时,必须指定使用的 chart 名字(`chart-name`)和部署后的应用名(`release-name`),还可以指定一个或多个 `values.yaml` 文件来配置 chart。此外,假如对 chart 有特定的版本需求,则需要通过 `--version` 参数指定 `chart-version` (默认为最新的 GA 版本)。命令形式如下: | ||
|
||
* 执行安装: | ||
* 执行安装: | ||
|
||
{{< copyable "shell-regular" >}} | ||
|
||
```shell | ||
helm install ${chart_name} --name=${release_name} --namespace=${namespace} --version=${chart_version} -f ${values_file} | ||
``` | ||
|
||
* 执行升级(升级可以是修改 `chart-version` 升级到新版本的 chart,也可以是修改 `values.yaml` 文件更新应用配置): | ||
|
||
{{< copyable "shell-regular" >}} | ||
|
||
```shell | ||
helm upgrade ${release_name} ${chart_name} --version=${chart_version} -f ${values_file} | ||
``` | ||
|
||
最后,假如要删除 helm 部署的应用,可以执行: | ||
|
||
{{< copyable "shell-regular" >}} | ||
|
||
```shell | ||
helm install ${chart_name} --name=${release_name} --namespace=${namespace} --version=${chart_version} -f ${values_file} | ||
helm del --purge ${release_name} | ||
``` | ||
|
||
* 执行升级(升级可以是修改 `chart-version` 升级到新版本的 chart,也可以是修改 `values.yaml` 文件更新应用配置): | ||
更多 helm 的相关文档,请参考 [Helm 官方文档](https://helm.sh/docs/)。 | ||
|
||
4. 离线情况下配置 Helm repo | ||
weekface marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
如果服务器上没有外网,就无法通过配置 Helm repo 来安装 TiDB Operator 组件以及其他应用。这时,我们需要在有外网的机器上下载集群安装需用到的 chart 文件,再拷贝到服务器上。 | ||
|
||
通过以下命令,下载集群安装时需要的 chart 文件: | ||
|
||
{{< copyable "shell-regular" >}} | ||
|
||
```shell | ||
helm upgrade ${release_name} ${chart_name} --version=${chart_version} -f ${values_file} | ||
wget http://charts.pingcap.org/tidb-operator-v1.1.0.tgz | ||
wget http://charts.pingcap.org/tidb-drainer-v1.1.0.tgz | ||
wget http://charts.pingcap.org/tidb-lightning-v1.1.0.tgz | ||
``` | ||
|
||
最后,假如要删除 helm 部署的应用,可以执行: | ||
|
||
{{< copyable "shell-regular" >}} | ||
将这些 chart 文件拷贝到服务器上并解压,可以通过 `helm install` 命令使用这些 chart 来安装相应组件,以 `tidb-operator` 为例: | ||
|
||
```shell | ||
helm del --purge ${release_name} | ||
``` | ||
{{< copyable "shell-regular" >}} | ||
|
||
更多 helm 的相关文档,请参考 [Helm 官方文档](https://helm.sh/docs/)。 | ||
```shell | ||
tar zxvf tidb-operator.v1.1.0.tgz | ||
helm install ./tidb-operator --name=${release_name} --namespace=${namespace} -f ${values_file} | ||
``` | ||
|
||
## 使用 Terraform | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
v2.16.7 是可变的
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里是举例说明