add translation of kubevela adoption

Signed-off-by: Jianbo Sun <jianbo.sjb@alibaba-inc.com>
This commit is contained in:
Jianbo Sun 2023-03-28 17:32:42 +08:00
parent b081854e7c
commit 4d56e57f21
9 changed files with 1337 additions and 15 deletions

View File

@ -1115,4 +1115,6 @@ If you want to adopt all helm releases in a namespace, you can use `--all` flag
```bash
vela adopt --all --type helm
```
```
That's all about the adoption feature. We hope that KubeVela can help you deliver your applications with ease and confidence.

View File

@ -30,7 +30,7 @@ module.exports = {
id: 'start',
content:
'<div class="header-item">⭐️ If you like KubeVela, give it a star on <a target="_blank" rel="noopener noreferrer" href="https://github.com/kubevela/kubevela">GitHub</a>!⭐️</div>' +
'<div class="header-item"><span>KubeVela v1.7.3 is now available.(2023-02-08)</span> <a target="_blank" style="color: var(--ifm-color-primary)" rel="noopener noreferrer" href="https://github.com/kubevela/kubevela/releases/tag/v1.7.3">Read Release Note</a></div>',
'<div class="header-item"><span>KubeVela v1.7.7 is now available.(2023-02-08)</span> <a target="_blank" style="color: var(--ifm-color-primary)" rel="noopener noreferrer" href="https://github.com/kubevela/kubevela/releases/tag/v1.7.7">Read Release Note</a></div>',
},
algolia: {
appId: 'PXMFHFWUGZ',

View File

@ -785,21 +785,17 @@ NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
默认情况下,`vela adopt` 将从给定源(本机资源列表或 Helm Chart中获取资源并将其分组到不同的组件中。对于像 Deployment 或 StatefulSet 这样的资源,原始的字段将被保留。对于其他资源,如 ConfigMap 或 Secret接管时应用不会保存其中的数据这也意味着 vela application 不会对其中的内容做终态保持。对于特殊资源CustomResourceDefinition`garbage-collect` 和 `apply-once`应用策略将附加到应用程序中。
将资源转换为应用程序是通过使用 CUE 模板来实现的。您可以参考 GitHub 查看默认模板。
将资源转换为应用程序是通过使用 CUE 模板来实现的。您可以参考 [GitHub](https://github.com/kubevela/kubevela/blob/master/references/cli/adopt-templates/default.cue) 查看默认模板。
您还可以使用 CUE 构建自己的采用规则,并将 --adopt-template 添加到 vela adopt 命令中。
您还可以使用 CUE 构建自己的采用规则,并将 `--adopt-template` 添加到 `vela adopt` 命令中。
The conversion from resources into application is achieved by using the CUE template. You can refer to [GitHub](https://github.com/kubevela/kubevela/blob/master/references/cli/adopt-templates/default.cue) to see the default template.
You can also build your own adoption rule using CUE and add `--adopt-template` to `vela adopt` command.
1. For example, let's create an example deployment.
1. 例如,让我们创建一个示例部署。
```bash
kubectl create deploy custom-adopt --image=nginx
```
2. Create a file named `my-adopt-rule.cue`.
1. 创建一个名为 `my-adopt-rule.cue` 的自定义规则。
```
import "list"
@ -891,9 +887,9 @@ import "list"
}
```
This customized adoption rule will automatically recognize deployment resources and convert it into KubeVela application's `webservice` component. It can intelligently detect the replicas number of the given deployment and attach a `scaler` trait to the component.
此自定义接管规则将自动识别 Deployment 资源并将其转换为 KubeVela 应用的 `webservice` 组件。它可以智能地检测给定部署的副本数,并将一个`scaler` trait 附加到该组件上。
3. Run `vela adopt deployment/custom-adopt --adopt-template=my-adopt-rule.cue`. You can see the converted application as
1. 运行 `vela adopt deployment/custom-adopt --adopt-template=my-adopt-rule.cue`。你就可以看到转换出来的应用了。
```yaml
apiVersion: core.oam.dev/v1beta1
kind: Application
@ -923,4 +919,204 @@ spec:
status: {}
```
With this capability, you can make your own rules for building application from existing resources or helm charts.
有了这个能力,您可以为从现有资源或 Helm Chart 中构建应用程序创建自己的规则。
### 批量接管
#### 批量接管原生资源
如果你想要批量接管一个 K8s 命名空间的所有资源,你可以使用 `--all` 标记。
```bash
vela adopt --all
```
默认情况下它将接管命名空间中的所有部署Deployment/有状态集StatefulSet/守护程序集DaemonSet资源。您还可以指定一个自定义资源进行采用。
```bash
vela adopt mycrd --all
```
此命令将首先尝试在命名空间中列出所有指定的资源,并根据资源拓扑规则找到相关资源(如 ConfigMap、Secret、Service 等)进行采用。
资源拓扑规则是使用 CUE 模板编写的,默认模板在 [GitHub](https://github.com/kubevela/kubevela/blob/master/references/cli/resource-topology/builtin-rule.cue) 中。使用此默认规则,将与 Deployment/StatefulSet/DaemonSet 相关的资源ConfigMap、Secret、Service、Ingress一起接管。
例如,如果在集群中有以下资源:
<details>
<summary>Resources(Deployment, ConfigMap, Service, Ingress)</summary>
apiVersion: apps/v1
kind: Deployment
metadata:
name: test1
namespace: default
spec:
progressDeadlineSeconds: 600
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
myapp: test1
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
creationTimestamp: null
labels:
myapp: test1
spec:
containers:
- image: crccheck/hello-world
imagePullPolicy: Always
name: test1
ports:
- containerPort: 8000
name: port-8000
protocol: TCP
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /test
name: configmap-my-test
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
volumes:
- configMap:
defaultMode: 420
name: my-test1
name: configmap-my-test
---
apiVersion: v1
kind: ConfigMap
metadata:
name: my-test1
namespace: default
---
apiVersion: v1
kind: Service
metadata:
name: test1
spec:
ports:
- port: 8000
protocol: TCP
targetPort: 8000
selector:
myapp: test1
type: ClusterIP
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: nginx
name: test1
namespace: default
spec:
rules:
- host: testsvc.example.com
http:
paths:
- backend:
service:
name: test1
port:
number: 8000
path: /
pathType: ImplementationSpecific
status:
loadBalancer: {}
</details>
通过 `vela adopt --all` 命令,这些资源会自动被接管到如下应用中:
<details>
<summary>接管后的应用</summary>
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: test1
namespace: default
spec:
components:
- name: test1.Deployment.test1
properties:
objects:
- apiVersion: apps/v1
kind: Deployment
metadata:
name: test1
namespace: default
spec:
...
type: k8s-objects
- name: test1.Service.test1
properties:
objects:
- apiVersion: v1
kind: Service
metadata:
name: test1
namespace: default
spec:
...
type: k8s-objects
- name: test1.Ingress.test1
properties:
objects:
- apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: test1
namespace: default
spec:
...
type: k8s-objects
- name: test1.config
properties:
objects:
- apiVersion: v1
kind: ConfigMap
metadata:
name: record-event
namespace: default
type: k8s-objects
policies:
- name: read-only
properties:
rules:
- selector:
componentNames:
- test1.Deployment.test1
- test1.Service.test1
- test1.Ingress.test1
- test1.config
type: read-only
</details>
您还可以使用 CUE 构建自己的资源拓扑规则,以查找自定义资源关系,并将 `--resource-topology-rule` 添加到 `vela adopt` 命令中。
```
vela adopt --all --resource-topology-rule=my-rule.cue
```
在采用所有资源并将其应用于集群之后,您可以使用 `vela ls` 或仪表板查看所有采用的应用程序。
![](https://static.kubevela.net/images/1.8/adopt-all.gif)
#### 批量接管 Helm 部署
如果您想在命名空间中批量接管 Helm 发布,则可以使用 `--all` 标志以及 `--type=helm`
```bash
vela adopt --all --type helm
```
以上就是所有的接管功能了,期待 KubeVela 为你的应用交付保驾护航。

Binary file not shown.

After

Width:  |  Height:  |  Size: 333 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 333 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 KiB

View File

@ -47,7 +47,7 @@ Although the resources selected in the `read-only` policy will not be editable t
<details>
<summary>practice</summary>
1. First creat the nginx deployment.
1. First create the nginx deployment.
```bash
kubectl create deploy nginx --image=nginx
```
@ -1115,4 +1115,6 @@ If you want to adopt all helm releases in a namespace, you can use `--all` flag
```bash
vela adopt --all --type helm
```
```
That's all about the adoption feature. We hope that KubeVela can help you deliver your applications with ease and confidence.