Merge pull request #643 from FogDong/feat-debug

Feat: add debug doc
This commit is contained in:
barnettZQG 2022-05-06 10:57:15 +08:00 committed by GitHub
commit 71000b6c5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 138 additions and 1 deletions

View File

@ -0,0 +1,68 @@
---
title: Debug in the environment
---
When you deploy your application in a test environment and find problems with the application, you may want to debug the application in the environment. KubeVela provides the `vela debug` command to help you debug your application in the environment.
## Applications with workflow
If your application uses workflow, make sure your app has the `debug` policy before using the `vela debug` command:
```yaml
polices:
- name: debug
type: debug
```
You can also use `vela up -f <application yaml> --debug` to automatically add debug policy to your application.
For applications that use workflows, `vela debug` will first list all the steps in the workflow, and you can select the specified steps to debug. After selecting a step, you can view the contents of all CUE variables in that step individually. Among them: `do` and `provider` marked in yellow are the CUE actions used this time, and the error content will be marked in red.
![](https://static.kubevela.net/images/1.4/debug-workflow.gif)
You can also use `vela debug <application-name> -s <step-name> -f <variable>` to view the contents of specified variables in a single step.
![](https://static.kubevela.net/images/1.4/debug-workflow-focus.gif)
## Applications with components only
If your application only uses components, not workflows, then, you can use the `vela debug <application-name>` command directly to debug your application.
Deploy the following application. The first component will use `k8s-objects` to create a Namespace, and the second component will use the `webservice` with `gateway` trait to create a Deployment and its corresponding Service and Ingress.
```yaml
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: gateway-app
spec:
components:
- name: comp-namespace
type: k8s-objects
properties:
objects:
- apiVersion: v1
kind: Namespace
metadata:
name: test-ns1
- name: express-server
type: webservice
properties:
image: crccheck/hello-world
ports:
- port: 8000
traits:
- type: gateway
properties:
domain: testsvc.example.com
http:
"/": 8000
```
After the application is deployed, you can use the `vela debug <application-name>` command to view all the resources rendered by the application.
![](https://static.kubevela.net/images/1.4/debug-application.gif)
You can also use `vela debug <application-name> -s <component-name>` to see all resources rendered in a single component.
![](https://static.kubevela.net/images/1.4/debug-application-comp.gif)

View File

@ -0,0 +1,68 @@
---
title: 在环境中调试
---
当你在测试环境中部署应用并发现应用出现问题时你可能会想要在环境中调试应用。KubeVela 提供了 `vela debug` 命令,来帮助你在环境中调试应用。
## 使用工作流的应用
如果你的应用使用了工作流,那么在使用 `vela debug` 命令前,请确保你的应用中使用了 `debug` 策略:
```yaml
polices:
- name: debug
type: debug
```
你也可以使用 `vela up -f <application yaml> --debug` 来为你的应用自动加上 debug 策略。
对于使用了工作流的应用,`vela debug` 会首先列出工作流中的所有步骤,你可以选择指定的步骤进行调试。选择完步骤后,你可以分别查看该步骤中的所有 CUE 变量内容。其中:黄色标明的 `do``provider` 是本次使用的 CUE action错误的内容将以红色标志。
![](https://static.kubevela.net/images/1.4/debug-workflow.gif)
你也可以使用 `vela debug <application-name> -s <step-name> -f <variable>` 来查看单个 步骤中的指定变量的内容。
![](https://static.kubevela.net/images/1.4/debug-workflow-focus.gif)
## 仅使用组件的应用
如果你的应用只使用了组件,没有使用工作流。那么,你可以直接使用 `vela debug <application-name>` 命令来进行调试你的应用。
部署如下应用,该应用的第一个组件会使用 `k8s-objects` 创建一个 Namespace第二个组件则会使用 `webservice` 组件以及 `gateway` 运维特征,从而创建一个 Deployment 及其对应的 Service 和 Ingress。
```yaml
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: gateway-app
spec:
components:
- name: comp-namespace
type: k8s-objects
properties:
objects:
- apiVersion: v1
kind: Namespace
metadata:
name: test-ns1
- name: express-server
type: webservice
properties:
image: crccheck/hello-world
ports:
- port: 8000
traits:
- type: gateway
properties:
domain: testsvc.example.com
http:
"/": 8000
```
部署完应用后,你可以使用 `vela debug <application-name>` 命令分组件来查看该应用渲染出来的所有资源。
![](https://static.kubevela.net/images/1.4/debug-application.gif)
你也可以使用 `vela debug <application-name> -s <component-name>` 来查看单个组件中被渲染出来的所有资源。
![](https://static.kubevela.net/images/1.4/debug-application-comp.gif)

View File

@ -40,4 +40,4 @@
"last 1 safari version"
]
}
}
}

View File

@ -165,6 +165,7 @@ module.exports = {
},
'platform-engineers/system-operation/velaql',
'platform-engineers/debug/dry-run',
'platform-engineers/debug/debug',
'platform-engineers/x-def-version',
],
},