Skip to content

Commit

Permalink
update more docs for 1.6
Browse files Browse the repository at this point in the history
Signed-off-by: Jianbo Sun <[email protected]>
  • Loading branch information
wonderflow committed Oct 25, 2022
1 parent bf67b7d commit ee8e7bf
Show file tree
Hide file tree
Showing 7 changed files with 252 additions and 659 deletions.
319 changes: 1 addition & 318 deletions docs/end-user/components/more.md

Large diffs are not rendered by default.

61 changes: 57 additions & 4 deletions docs/platform-engineers/components/custom-component.md
Original file line number Diff line number Diff line change
Expand Up @@ -541,10 +541,6 @@ local ─── default ─┬─ Service/hello-webserver-auxiliaryworkloa

You can also define health check policy and status message when a component deployed and tell the real status to end users.

:::caution
Reference `parameter` defined in `template` is not supported now in health check and custom status, they work in different stage with the resource template. While we're going to support this feature in https://github.com/kubevela/kubevela/issues/4863 .
:::

### Health check

The spec of health check is `<component-type-name>.attributes.status.healthPolicy`.
Expand Down Expand Up @@ -585,6 +581,27 @@ webserver: {
}
```

You can also use the `parameter` defined in the template like:

```
webserver: {
type: "component"
...
attributes: {
status: {
healthPolicy: #"""
isHealth: (context.output.status.readyReplicas > 0) && (context.output.status.readyReplicas == parameter.replicas)
"""#
}
}
template: {
parameter: {
replicas: int
}
...
}
```

The health check result will be recorded into the corresponding component in `.status.services` of `Application` resource.

```yaml
Expand Down Expand Up @@ -669,6 +686,42 @@ status:
| `context.replicaKey` | The key of replication in context. Replication is an internal policy, it will replicate resources with different keys specified. (This feature will be introduced in v1.6+.) | string |


### Cluster Version

| Context Variable | Description | Type |
| :---------------------------------: | :---------------------------------------------------------: | :----: |
| `context.clusterVersion.major` | The major version of the runtime Kubernetes cluster. | string |
| `context.clusterVersion.gitVersion` | The gitVersion of the runtime Kubernetes cluster. | string |
| `context.clusterVersion.platform` | The platform information of the runtime Kubernetes cluster. | string |
| `context.clusterVersion.minor` | The minor version of the runtime Kubernetes cluster. | int |

The cluster version context info can be used for graceful upgrade of definition. For example, you can define different API according to the cluster version.

```
outputs: ingress: {
if context.clusterVersion.minor < 19 {
apiVersion: "networking.k8s.io/v1beta1"
}
if context.clusterVersion.minor >= 19 {
apiVersion: "networking.k8s.io/v1"
}
kind: "Ingress"
}
```
Or use string contain pattern for this usage:
```
import "strings"

if strings.Contains(context.clusterVersion.gitVersion, "k3s") {
provider: "k3s"
}
if strings.Contains(context.clusterVersion.gitVersion, "aliyun") {
provider: "aliyun"
}
```
## Component definition in Kubernetes
KubeVela is fully programmable via CUE, while it leverage Kubernetes as control plane and align with the API in yaml.
Expand Down
61 changes: 57 additions & 4 deletions docs/platform-engineers/traits/customize-trait.md
Original file line number Diff line number Diff line change
Expand Up @@ -424,10 +424,6 @@ So KubeVela allow patch or override in this case, please refer to [patch trait](

You can also define health check policy and status message when a trait deployed and tell the real status to end users.

:::caution
Reference `parameter` defined in `template` is not supported now in health check and custom status, they work in different stage with the resource template. While we're going to support this feature in https://github.com/kubevela/kubevela/issues/4863 .
:::

### Health Check

The spec of health check is `<trait-type-name>.attributes.status.healthPolicy`, it's similar to component definition.
Expand Down Expand Up @@ -467,6 +463,27 @@ my-ingress: {
}
```

You can also use the `parameter` defined in the template like:

```cue
mytrait: {
type: "trait"
...
attributes: {
status: {
healthPolicy: #"""
isHealth: context.outputs."mytrait-\(parameter.name)".status.state == "Available"
"""#
}
}
template: {
parameter: {
name: string
}
...
}
```

The health check result will be recorded into the corresponding trait in `.status.services` of `Application` resource.

```yaml
Expand Down Expand Up @@ -562,6 +579,42 @@ status:
| `context.appLabels` | The labels of the current application instance. | Object Map |
| `context.appAnnotations` | The annotations of the current application instance. | Object Map |

### Cluster Version

| Context Variable | Description | Type |
| :---------------------------------: | :---------------------------------------------------------: | :----: |
| `context.clusterVersion.major` | The major version of the runtime Kubernetes cluster. | string |
| `context.clusterVersion.gitVersion` | The gitVersion of the runtime Kubernetes cluster. | string |
| `context.clusterVersion.platform` | The platform information of the runtime Kubernetes cluster. | string |
| `context.clusterVersion.minor` | The minor version of the runtime Kubernetes cluster. | int |

The cluster version context info can be used for graceful upgrade of definition. For example, you can define different API according to the cluster version.

```
outputs: ingress: {
if context.clusterVersion.minor < 19 {
apiVersion: "networking.k8s.io/v1beta1"
}
if context.clusterVersion.minor >= 19 {
apiVersion: "networking.k8s.io/v1"
}
kind: "Ingress"
}
```
Or use string contain pattern for this usage:
```
import "strings"

if strings.Contains(context.clusterVersion.gitVersion, "k3s") {
provider: "k3s"
}
if strings.Contains(context.clusterVersion.gitVersion, "aliyun") {
provider: "aliyun"
}
```
## Trait definition in Kubernetes
Expand Down
28 changes: 14 additions & 14 deletions docs/platform-engineers/workflow/workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,20 +237,20 @@ KubeVela allows you to reference some runtime data via the `context` keyword.

In a workflow step definition, you can use the following context data:

| Context Variable | Description | Type |
| :------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :--------: |
| `context.name` | The name of the Application. | string |
| `context.appName` | The name of the Application. | string |
| `context.namespace` | The namespace of the Application. | string |
| `context.appRevision` | The revision of the Application. | string |
| `context.stepName` | The name of current step. | string |
| `context.stepSessionID` | The ID of current step. | string |
| `context.spanID` | The trace ID of current step in this reconcile. ID | string |
| `context.workflowName` | The workflow name specified in annotation. | string |
| `context.publishVersion` | The version of application instance specified in annotation. | string |


## Kubernetes 中的 WorkflowStepDefinition
| Context Variable | Description | Type |
| :----------------------: | :----------------------------------------------------------: | :----: |
| `context.name` | The name of the Application. | string |
| `context.appName` | The name of the Application. | string |
| `context.namespace` | The namespace of the Application. | string |
| `context.appRevision` | The revision of the Application. | string |
| `context.stepName` | The name of current step. | string |
| `context.stepSessionID` | The ID of current step. | string |
| `context.spanID` | The trace ID of current step in this reconcile. ID | string |
| `context.workflowName` | The workflow name specified in annotation. | string |
| `context.publishVersion` | The version of application instance specified in annotation. | string |


## Kubernetes API for WorkflowStepDefinition

KubeVela is fully programmable through CUE, while it leverages Kubernetes as a control plane and is consistent with the API in YAML.

Expand Down
Loading

0 comments on commit ee8e7bf

Please sign in to comment.