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

Update 使用Velero跨云平台迁移集群资源到TKE.md #15939

Open
wants to merge 1 commit into
base: master
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 @@ -63,7 +63,7 @@ xxx-StorageClass xxx-Provider Delete Immediate true
```
2. 修改 [with-pv.yaml](https://github.com/vmware-tanzu/velero/blob/v1.5.1/examples/nginx-app/with-pv.yaml) 文件中的 PVC 资源清单,使用集群中存储类名为 “xxx-StorageClass” 的存储类来动态创建。示例如下:
<dx-codeblock>
::: yaml
```yaml
...
---
kind: PersistentVolumeClaim
Expand All @@ -82,19 +82,22 @@ spec:
requests:
storage: 20Gi # 由于该云平台限制存储最小为20Gi,本示例需要同步修改此值为20Gi
...
:::
```
</dx-codeblock>

3. 执行以下命令,应用示例中的 with-pv.yaml,创建如下的集群资源(nginx-example 命名空间)。示例如下:

```bash
$ kubectl apply -f with-pv.yaml
namespace/nginx-example created
persistentvolumeclaim/nginx-logs created
deployment.apps/nginx-deployment created
service/my-nginx created
```

4. 创建的 PVC “nginx-logs” 已挂载至 Nginx 容器的 `/var/log/nginx` 目录,作为服务的日志存储。本文示例通过在浏览器测试访问 Nginx 服务,为挂载的 PVC 生产日志数据,以便后续还原后进行数据比对。示例如下:
<dx-codeblock>
::: bash
``` bash
$ kubectl exec -it nginx-deployment-5ccc99bffb-6nm5w bash -n nginx-example
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl kubectl exec [POD] -- [COMMAND]
Defaulting container name to nginx.
Expand All @@ -111,7 +114,7 @@ $ head -n 2 /var/log/nginx/access.log
$ head -n 2 /var/log/nginx/error.log
2020/12/29 03:02:32 [error] 6#6: *597 open() "/usr/share/nginx/html/favicon.ico" failed (2: No such file or directory), client: 192.168.0.73, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "47.242.233.22", referrer: "http://47.242.233.22/?spm=5176.2020520152.0.0.22d016ddHXZumX"
2020/12/29 03:07:21 [error] 6#6: *1172 open() "/usr/share/nginx/html/0bef" failed (2: No such file or directory), client: 192.168.0.73, server: localhost, request: "GET /0bef HTTP/1.0"
:::
```
</dx-codeblock>


Expand All @@ -134,7 +137,7 @@ kubectl api-resources --verbs=list -o name | xargs -n 1 kubectl get --show-kind
```
2. 可以根据实际情况筛选出需要被迁移的资源清单。本文示例将直接从该云平台迁移 “nginx-example” 命名空间下 Nginx 工作负载相关的资源到容器服务 TKE,涉及资源如下所示:
<dx-codeblock>
::: bash
``` bash
$ kubectl get all -n nginx-example
NAME READY STATUS RESTARTS AGE
pod/nginx-deployment-5ccc99bffb-tn2sh 2/2 Running 0 2d19h
Expand All @@ -155,7 +158,7 @@ nginx-logs Bound d-j6ccrq4k1moziu1l6l5r 20Gi RWO xxx-Sto
$ kubectl get pv
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
d-j6ccrq4k1moziu1l6l5r 20Gi RWO Delete Bound nginx-example/nginx-logs xxx-StorageClass 2d19h
:::
```
</dx-codeblock>


Expand All @@ -165,7 +168,7 @@ d-j6ccrq4k1moziu1l6l5r 20Gi RWO Delete Bound ngi

本文示例在 [with-pv.yaml](https://github.com/vmware-tanzu/velero/blob/v1.5.1/examples/nginx-app/with-pv.yaml) 中已配置“备份 Nginx 工作负载前将文件系统设置为只读,在备份后恢复读写”的 Hook 策略,YAML 文件如下所示:
<dx-codeblock>
::: yaml
``` yaml
...
annotations:
# 备份 Hook 策略的注解表示:在开始备份之前将 nginx 日志目录设置为只读模式,备份完成后恢复读写模式
Expand Down Expand Up @@ -195,7 +198,7 @@ d-j6ccrq4k1moziu1l6l5r 20Gi RWO Delete Bound ngi
- mountPath: "/var/log/nginx"
name: nginx-logs
...
:::
```
</dx-codeblock>


Expand Down