From 47bc41ee6874f4da7e79b76d3c57f81a03b2a37d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wei=20=28=E6=AE=B5=E5=B0=91=29?= Date: Thu, 19 Aug 2021 21:01:34 +0800 Subject: [PATCH] updates (#184) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 段少 --- .../components/component-terraform.md | 18 ++----- .../components/custom-component.md | 47 ++++++++++++++++++- sidebars.js | 6 +-- 3 files changed, 54 insertions(+), 17 deletions(-) diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/platform-engineers/components/component-terraform.md b/i18n/zh/docusaurus-plugin-content-docs/current/platform-engineers/components/component-terraform.md index 78cd11c7..86949fb5 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/platform-engineers/components/component-terraform.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/platform-engineers/components/component-terraform.md @@ -12,19 +12,9 @@ title: Terraform 组件 3. KubeVela 通过 Terraform 控制器来拉起对应的云资源。 -### 安装 Terraform 控制器 +### 开启 Terraform 控制器 -从最新的 [发布列表](https://github.com/oam-dev/terraform-controller/releases) 里下载并安装,比如 `terraform-controller-chart-0.1.8.tgz`。 - -```shell -$ helm install terraform-controller terraform-controller-0.1.8.tgz -NAME: terraform-controller -LAST DEPLOYED: Mon Apr 26 15:55:35 2021 -NAMESPACE: default -STATUS: deployed -REVISION: 1 -TEST SUITE: None -``` +推荐你直接通过[系统插件(addon)](../addon)来开启 Terraform 控制器。 ### 配置阿里云鉴权 以下是阿里云的鉴权相关步骤,其它云服务商同理: @@ -117,7 +107,9 @@ kind: Configuration metadata: annotations: kubectl.kubernetes.io/last-applied-configuration: | - {"apiVersion":"terraform.core.oam.dev/v1beta1","kind":"Configuration","metadata":{"annotations":{},"name":"alibaba-oss","namespace":"default"},"spec":{"JSON":"{\n \"resource\": {\n \"alicloud_oss_bucket\": {\n \"bucket-acl\": {\n \"bucket\": \"${var.bucket}\",\n \"acl\": \"${var.acl}\"\n }\n }\n },\n \"output\": {\n \"BUCKET_NAME\": {\n \"value\": \"${alicloud_oss_bucket.bucket-acl.bucket}.${alicloud_oss_bucket.bucket-acl.extranet_endpoint}\"\n }\n },\n \"variable\": {\n \"bucket\": {\n \"default\": \"poc\"\n },\n \"acl\": {\n \"default\": \"private\"\n }\n }\n}\n","variable":{"acl":"private","bucket":"vela-website"},"writeConnectionSecretToRef":{"name":"oss-conn","namespace":"default"}}} + {"apiVersion":"terraform.core.oam.dev/v1beta1","kind":"Configuration","metadata":{"annotations":{},"name":"alibaba-oss","namespace":"default"},"spec": + ... + \"private\"\n }\n }\n}\n","variable":{"acl":"private","bucket":"vela-website"},"writeConnectionSecretToRef":{"name":"oss-conn","namespace":"default"}}} creationTimestamp: "2021-04-02T08:17:08Z" generation: 2 spec: diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/platform-engineers/components/custom-component.md b/i18n/zh/docusaurus-plugin-content-docs/current/platform-engineers/components/custom-component.md index 6a88f0f5..8d7d2480 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/platform-engineers/components/custom-component.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/platform-engineers/components/custom-component.md @@ -347,4 +347,49 @@ hello-world-v1 1/1 1 1 15s $ kubectl get svc NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE hello-world-trait-7bdcff98f7 ClusterIP 8000/TCP 32s -``` \ No newline at end of file +``` + +## 使用 CUE `Context` + +KubeVela 让你可以在运行时,通过 `context` 关键字来引用一些信息。 + +最常用的就是应用部署计划的名称 `context.appName` 和组件的名称 `context.name`。 + +```cue +context: { + appName: string + name: string +} +``` + +举例来说,假设你在实现一个组件定义,希望将容器的名称填充为组件的名称。那么这样做: + +```cue +parameter: { + image: string +} +output: { + ... + spec: { + containers: [{ + name: context.name + image: parameter.image + }] + } + ... +} +``` + +> 注意,`context` 的信息会在资源部署到目标集群之前就自动注入了 + +### CUE `context` 的配置项 + +| Context 变量名 | 说明 | +| :--: | :---------: | +| `context.appRevision` | 应用部署计划的版本 | +| `context.appRevisionNum` | 应用部署计划的版本号(`int` 类型), 比如说如果 `context.appRevision` 是 `app-v1` 的话,`context.appRevisionNum` 会是 `1` | +| `context.appName` | 应用部署计划的名称 | +| `context.name` | 组件的名称 | +| `context.namespace` | 应用部署计划的命名空间 | +| `context.output` | 组件中渲染的工作负载 API 资源,这通常用在运维特征里 | +| `context.outputs.` | 组件中渲染的运维特征 API 资源,这通常用在运维特征里 | \ No newline at end of file diff --git a/sidebars.js b/sidebars.js index 807079d8..5dd137d0 100644 --- a/sidebars.js +++ b/sidebars.js @@ -88,8 +88,8 @@ module.exports = { }, { 'Debugging': [ - 'end-user/debug/health', - 'end-user/debug/monitoring', + // 'end-user/debug/health', + // 'end-user/debug/monitoring', 这部分要和可观测合并 'end-user/debug/live-diff', ] }, @@ -123,7 +123,7 @@ module.exports = { { 'Learning CUE': [ 'platform-engineers/cue/basic', - 'platform-engineers/cue/advanced', + // 'platform-engineers/cue/advanced', 暂时隐藏,来不及随 1.1 发布,随后补充 ] }, {