diff --git a/docs/platform-engineers/debug/debug.md b/docs/platform-engineers/debug/debug.md new file mode 100644 index 00000000..9e0e7c96 --- /dev/null +++ b/docs/platform-engineers/debug/debug.md @@ -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 --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 -s -f ` 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 ` 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 ` 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 -s ` to see all resources rendered in a single component. + +![](https://static.kubevela.net/images/1.4/debug-application-comp.gif) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/platform-engineers/debug/debug.md b/i18n/zh/docusaurus-plugin-content-docs/current/platform-engineers/debug/debug.md new file mode 100644 index 00000000..8f0ac0e8 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/platform-engineers/debug/debug.md @@ -0,0 +1,68 @@ +--- +title: 在环境中调试 +--- + +当你在测试环境中部署应用,并发现应用出现问题时,你可能会想要在环境中调试应用。KubeVela 提供了 `vela debug` 命令,来帮助你在环境中调试应用。 + +## 使用工作流的应用 + +如果你的应用使用了工作流,那么在使用 `vela debug` 命令前,请确保你的应用中使用了 `debug` 策略: + +```yaml +polices: + - name: debug + type: debug +``` + +你也可以使用 `vela up -f --debug` 来为你的应用自动加上 debug 策略。 + +对于使用了工作流的应用,`vela debug` 会首先列出工作流中的所有步骤,你可以选择指定的步骤进行调试。选择完步骤后,你可以分别查看该步骤中的所有 CUE 变量内容。其中:黄色标明的 `do` 和 `provider` 是本次使用的 CUE action,错误的内容将以红色标志。 + +![](https://static.kubevela.net/images/1.4/debug-workflow.gif) + +你也可以使用 `vela debug -s -f ` 来查看单个 步骤中的指定变量的内容。 + +![](https://static.kubevela.net/images/1.4/debug-workflow-focus.gif) + +## 仅使用组件的应用 + +如果你的应用只使用了组件,没有使用工作流。那么,你可以直接使用 `vela debug ` 命令来进行调试你的应用。 + +部署如下应用,该应用的第一个组件会使用 `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 ` 命令分组件来查看该应用渲染出来的所有资源。 + +![](https://static.kubevela.net/images/1.4/debug-application.gif) + +你也可以使用 `vela debug -s ` 来查看单个组件中被渲染出来的所有资源。 + +![](https://static.kubevela.net/images/1.4/debug-application-comp.gif) diff --git a/package.json b/package.json index 8300a40b..f125d31c 100644 --- a/package.json +++ b/package.json @@ -40,4 +40,4 @@ "last 1 safari version" ] } -} \ No newline at end of file +} diff --git a/sidebars.js b/sidebars.js index 61ca4af5..e36f6722 100644 --- a/sidebars.js +++ b/sidebars.js @@ -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', ], },