Skip to content

Commit

Permalink
doc(platform-engineers): translate the non-translate docs in `platfor…
Browse files Browse the repository at this point in the history
…m-engineers` chapter (#1297)

* doc(openapi): translate VelaUX openapi doc

Signed-off-by: 上郡 <[email protected]>

* doc(platform-engineers): translate the non-translate docs in  chapter

Signed-off-by: 上郡 <[email protected]>

* doc(platform-engineers): replace the openapi/overview.md in current folder to the translated version

Signed-off-by: 上郡 <[email protected]>

---------

Signed-off-by: 上郡 <[email protected]>
  • Loading branch information
iambocai committed Nov 5, 2023
1 parent 704da33 commit 5192dcd
Show file tree
Hide file tree
Showing 14 changed files with 178 additions and 178 deletions.
2 changes: 1 addition & 1 deletion docs/platform-engineers/cloneset.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ workload:
This is how you register OpenKruise Cloneset's API resource (`fapps.kruise.io/v1alpha1.CloneSet`) as the workload type.
KubeVela uses Kubernetes API resource discovery mechanism to manage all registered capabilities.

#### 4. Define Template
#### 3. Define Template

```yaml
...
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
---
title: Systems Integration
title: 系统集成
---

KubeVela application natively supports impersonation even without the Authentication flag enabled. That means when the Authentication flag is disabled, you can manually set the identity to impersonate in the application's annotation fields. For example, the following guide will give an example on how to manually set the application to impersonate as a ServiceAccount.
KubeVela 的应用(Application)天然支持身份模拟,即使没有启用其身份验证功能。 这意味着当禁用身份验证时,您可以在应用的注解部分手动设置要模拟的身份。例如以下指南将举例说明如何使用指定的服务账号(ServiceAccount)部署应用 。

## Example
## 例子

Let's assume that we have two namespaces:
假设我们有两个名称空间:

- `demo-service`: for managing application
- `demo-service-prod`: to deploy components for the production environment
- `demo-service`:用于管理应用程序
- `demo-service-prod`:为生产环境部署组件

In this example, we will make the Application use a specific ServiceAccount instead of the controller ServiceAccount.
在此示例中,我们将使应用使用特定的服务账号而不是控制器的服务账号来进行部署。

### Creating ServiceAccount
### 创建服务账号(ServiceAccount

Create `deployer` ServiceAccount in `demo-service` namespace.
`demo-service` 命名空间下创建 `deployer` 服务账号。

```yaml
apiVersion: v1
Expand All @@ -25,11 +25,11 @@ metadata:
namespace: demo-service
```
### Creating Role/RoleBinding
### 创建角色/角色绑定(Role/RoleBinding
Allow `deployer` ServiceAccount in `demo-service` to manage Deployments in `demo-service-prod` by creating Role/RoleBinding.
通过创建角色和角色绑定来允许 `demo-service` 命名空间下的 `deployer` 服务账号管理 `demo-service-prod` 命名空间下的 Deployments。

> Notice that KubeVela application requires the identity to impersonate to have the privileges for writing ControllerRevision. If you use `--optimize-disable-component-revision` in the KubeVela controller, you can ignore this requirement.
> 请注意,KubeVela 应用程序需要模拟身份才能拥有写 ControllerRevision 的权限。 如果您在 KubeVela 控制器中使用 `--optimize-disable-component-revision`,则可以忽略此要求。

```yaml
apiVersion: rbac.authorization.k8s.io/v1
Expand Down Expand Up @@ -57,7 +57,7 @@ subjects:
namespace: demo-service
```

### Deploying an Application with ServiceAccount
### 使用指定服务账号部署应用

```yaml
apiVersion: core.oam.dev/v1beta1
Expand All @@ -66,7 +66,7 @@ metadata:
name: multi-env-demo-with-service-account
namespace: demo-service
annotations:
app.oam.dev/service-account-name: deployer # the name of the ServiceAccount we created
app.oam.dev/service-account-name: deployer # 我们上面创建的服务账号
spec:
components:
- name: nginx-server
Expand Down Expand Up @@ -100,7 +100,7 @@ spec:
env: prod
```

After deploying the Application, you can check the Application is deployed successfully.
部署应用程序后,您可以检查应用程序是否部署成功:

```bash
$ vela status multi-env-demo-with-service-account -n demo-service
Expand Down Expand Up @@ -133,12 +133,12 @@ Services:
No trait applied
```

If you set non-authorized ServiceAccount to the annotation, you can find an error message like below in the Application status.
如果你在注解中设置了非授权的服务账号,你会在应用的status输出中看到类似下面的错误信息:

```
Dispatch: Found 1 errors. [(cannot get object: deployments.apps "nginx-server" is forbidden: User "system:serviceaccount:demo-service:non-authorized-account" cannot get resource "deployments" in API group "apps" in the namespace "demo-service-prod")]
```
## Impersonate as User/Groups
## 模拟指定用户/用户组
If you would like to let the application to impersonate as specific user and group, you can set the annotation `app.oam.dev/username` and `app.oam.dev/group` in the application respectively.
如果您想让应用程序模拟特定的用户和组,您可以在应用程序中分别设置注解 `app.oam.dev/username` `app.oam.dev/group`
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
---
title: Extend CRD Operator as Component Type
title: CRD Operator 扩展为组件
---

Let's use [OpenKruise](https://github.com/openkruise/kruise) as example of extend CRD as KubeVela Component.
**The mechanism works for all CRD Operators**.
让我们使用 [OpenKruise](https://github.com/openkruise/kruise) 演示如何将 CRD 扩展为 KubeVela 组件。
**该机制适用于所有 CRD Operator**

### Step 1: Install the CRD controller
### 第 1 步:安装 CRD 控制器

You need to [install the CRD controller](https://github.com/openkruise/kruise#quick-start) into your K8s system.
您需要 [安装 CRD 控制器](https://github.com/openkruise/kruise#quick-start) 到您的 K8s 系统中。

### Step 2: Create Component Definition
### 第 2 步:创建组件定义

To register Cloneset(one of the OpenKruise workloads) as a new workload type in KubeVela, the only thing needed is to create an `ComponentDefinition` object for it.
A full example can be found in this [cloneset.yaml](https://github.com/kubevela/catalog/blob/master/registry/cloneset.yaml).
Several highlights are list below.
要将 ClonesetOpenKruise 工作负载之一)注册为 KubeVela 中的新工作负载类型,唯一需要做的就是为其创建一个 `ComponentDefinition` 对象。
完整的示例可以在这个 [cloneset.yaml](https://github.com/kubevela/catalog/blob/master/registry/cloneset.yaml) 中找到。
下面列出几个重点。

#### 1. Describe The Workload Type
#### 1. 描述工作负载类型

```yaml
...
Expand All @@ -24,9 +24,9 @@ Several highlights are list below.
...
```

A one line description of this component type. It will be shown in helper commands such as `$ vela components`.
该组件类型的一行描述。 它将显示在辅助命令中,例如 `$ vela Components`

#### 2. Register it's underlying CRD
#### 2.注册其底层CRD

```yaml
...
Expand All @@ -37,10 +37,10 @@ workload:
...
```

This is how you register OpenKruise Cloneset's API resource (`fapps.kruise.io/v1alpha1.CloneSet`) as the workload type.
KubeVela uses Kubernetes API resource discovery mechanism to manage all registered capabilities.
这是将 OpenKruise ClonesetAPI 资源 (`fapps.kruise.io/v1alpha1.CloneSet`) 注册为工作负载类型的方法。
KubeVela使用Kubernetes API资源发现机制来管理所有注册的能力。

#### 4. Define Template
#### 3. 定义模板

```yaml
...
Expand Down Expand Up @@ -81,12 +81,12 @@ schematic:
}
```
### Step 3: Register New Component Type to KubeVela
### 第 3 步:向 KubeVela 注册新组件类型
As long as the definition file is ready, you just need to apply it to Kubernetes.
只要定义文件准备好了,你只需要把它应用到 Kubernetes 上就可以了。
```bash
$ kubectl apply -f https://raw.githubusercontent.com/oam-dev/catalog/master/registry/cloneset.yaml
```

And the new component type will immediately become available for developers to use in KubeVela.
新的组件类型将立即可供开发人员在 KubeVela 中使用。
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: 定义CRD
---

This documentation has been merged into [Definition Protocol](./oam/x-definition.md).
该文档已合并到[定义协议](./oam/x-definition.md)中。


The definition revision part has been migrated to [here](./x-def-version.md).
定义修订部分已迁移到[此处](./x-def-version.md)
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@
title: VelaUX OpenAPI
---

This section will introduce how to integrate VelaUX OpenAPI, please make sure you have enabled the `velaux` addon. Let's use port-forward to expose the endpoint for the following demo.
本节将介绍如何集成 VelaUX OpenAPI,请确保您已启用 `velaux` 插件。 让我们使用端口转发来公开以下演示的端点。

```bash
vela port-forward addon-velaux -n vela-system 8000:80
```

## Authentication and API Example
## 身份验证和 API 示例

### Login and get the token
### 登录并获取令牌

VelaUX has introduced [Json Web Token](https://jwt.io/) for authorization. As a result, you need to call the login API to complete the authentication and get the token. The following example is with the default admin account.
VelaUX 引入了 [Json Web Token](https://jwt.io/) 进行授权。 因此,您需要调用登录接口来完成认证并获取token。 以下示例使用默认管理员帐户。

```bash
curl -H Content-Type:application/json -X POST -d '{"username": "admin", "password":"VelaUX12345"}' http://127.0.0.1:8000/api/v1/auth/login
```

> `http://127.0.0.1:8000` This is demo address, you should replace it with the real address. If you changed the password, replace it with the real password.
> `http://127.0.0.1:8000` 这是演示地址,您应该将其替换为真实地址。 如果您更改了密码,请将其替换为真实密码。
The expected output should be like this:
预期的输出应该是这样的:

```json
{
Expand All @@ -36,20 +36,20 @@ The expected output should be like this:
}
```

* accessToken: This is the token to request other APIs, which will expire in an hour.
* refreshToken: This is the token to refresh the access token.
* accessToken: 这是请求其他API的token,一个小时后就会过期。
* refreshToken: 这是刷新访问令牌的令牌。

### Request other APIs
### 请求其他API

* Create an application
* 创建一个应用程序

```bash
curl -H Content-Type:application/json -H "Authorization: Bearer <accessToken>" -X POST -d '{"name":"first-vela-app", "project": "default", "alias": "Demo App", "envBinding": [{"name": "default"}], "component": {"name":"express-server","componentType":"webservice", "properties": "{\"image\":\"oamdev/hello-world\"}"}}' http://127.0.0.1:8000/api/v1/applications
```

> Please replace `<accessToken>` with the response from the previous step.
> 请将 `<accessToken>` 替换为上一步的响应。
The expected output should be like this:
预期的输出应该是这样的:

```json
{
Expand All @@ -73,13 +73,13 @@ The expected output should be like this:
}
```

* Deploy an application
* 部署应用程序

```bash
curl -H Content-Type:application/json -H "Authorization: Bearer <accessToken>" -X POST -d '{"workflowName":"workflow-default","triggerType":"api"}' http://127.0.0.1:8000/api/v1/applications/first-vela-app/deploy
```

The expected output should be like this:
预期的输出应该是这样的:

```json
{
Expand All @@ -96,15 +96,15 @@ The expected output should be like this:
}
```

* Using VelaQL to Query the application pod list
* 使用VelaQL查询应用程序pod列表

```bash
curl -H "Authorization: Bearer <accessToken>" -G \
"http://127.0.0.1:8000/api/v1/query" \
--data-urlencode 'velaql=component-pod-view{appNs=default,appName=first-vela-app}.status'
```

The expected output should be like this:
预期的输出应该是这样的:

```json
{
Expand Down Expand Up @@ -138,15 +138,15 @@ The expected output should be like this:
}
```

For more use cases about VelaQL, Please refer to [VelaQL](../system-operation/velaql.md)
更多关于 VelaQL 的使用案例,请参考 [VelaQL](../system-operation/velaql.md)

### Refresh the token
### 刷新令牌

```bash
curl -H Content-Type:application/json -X GET -H RefreshToken:<refreshToken> http://127.0.0.1:8000/api/v1/auth/refresh_token
```

The expected output should be like this:
预期的输出应该是这样的:

```json
{
Expand All @@ -157,25 +157,25 @@ The expected output should be like this:

## API Document

There is the latest swagger config file: [https://github.com/kubevela/kubevela/blob/master/docs/apidoc/swagger.json](https://github.com/kubevela/kubevela/blob/master/docs/apidoc/swagger.json)
最新的swagger配置文件: [https://github.com/kubevela/velaux/blob/main/docs/apidoc/swagger.json](https://github.com/kubevela/velaux/blob/main/docs/apidoc/swagger.json)

### 1.7

Refer to [Kubevela API 1.7](https://kubevela.stoplight.io/docs/kubevela/b8aer09sc4q9e-kube-vela-api-1-7)
参考 [KubeVela API 1.7](https://kubevela.stoplight.io/docs/kubevela/b8aer09sc4q9e-kube-vela-api-1-7)

### 1.6

Refer to [KubeVela API 1.6](https://kubevela.stoplight.io/docs/kubevela/178jb51mk763f-kube-vela-api-1-6)
参考 [KubeVela API 1.6](https://kubevela.stoplight.io/docs/kubevela/178jb51mk763f-kube-vela-api-1-6)

### 1.5

Refer to [KubeVela API 1.5](https://kubevela.stoplight.io/docs/kubevela/pi1st0zdzoejp-kube-vela-api-1-5)
参考 [KubeVela API 1.5](https://kubevela.stoplight.io/docs/kubevela/pi1st0zdzoejp-kube-vela-api-1-5)


### 1.4

Refer to [Kubevela API 1.4](https://kubevela.stoplight.io/docs/kubevela/uz7fzdxthv175-kube-vela-api-1-4)
参考 [KubeVela API 1.4](https://kubevela.stoplight.io/docs/kubevela/uz7fzdxthv175-kube-vela-api-1-4)

### 1.3

Refer to [Kubevela API 1.3](https://kubevela.stoplight.io/docs/kubevela/1d086db94299e-kube-vela-api-1-3)
参考 [KubeVela API 1.3](https://kubevela.stoplight.io/docs/kubevela/1d086db94299e-kube-vela-api-1-3)
Loading

0 comments on commit 5192dcd

Please sign in to comment.