Co-authored-by: 段少 <duanwei.duan@alibaba-inc.com>
This commit is contained in:
Wei (段少) 2021-08-20 22:49:08 +08:00 committed by GitHub
parent 68d501691b
commit e71f987c15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 261 additions and 26 deletions

View File

@ -2,4 +2,46 @@
title: Application
---
TBD
KubeVela takes Application as the basis of modeling, uses Components and Traits to complete a set of application deployment plans. After you are familiar with these core concepts, you can develop in accordance with the user manual and administrator manual according to your needs.
In modeling, the YAML file is the bearer of the application deployment plan. A typical YAML example is as follows:
```
# sample.yaml
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: website
spec:
components:
- name: frontend # This is the component I want to deploy
type: webservice
properties:
image: nginx
traits:
- type: cpuscaler # Automatically scale the component by CPU usage after deployed
properties:
min: 1
max: 10
cpuPercent: 60
- type: sidecar # Inject a fluentd sidecar before applying the component to runtime cluster
properties:
name: "sidecar-test"
image: "fluentd"
- name: backend
type: worker
properties:
image: busybox
cmd:
- sleep
- '1000'
```
The fields here correspond to:
- apiVersion: The OAM API version used.
- kind: of CRD Resourse Type. The one we use most often is Pod.
- metadata: business-related information. For example, this time I want to create a website.
- Spec: Describe what we need to deliver and tell Kubernetes what to make. Here we put the components of KubeVela.
- components: KubeVela's component system.
- Traits: KubeVela's operation and maintenance feature system.

View File

@ -2,4 +2,14 @@
title: Architecture
---
TBD
The overall architecture of KubeVela is shown as below:
![alt](../resources/arch.png)
### Control Plane
Control plane is where KubeVela itself lives in. As the project's name implies, KubeVela by design leverages Kubernetes as control plane. This is the key of how KubeVela guarantees full *automation* and strong *determinism* to application delivery at scale. Users will interact with KubeVela via the application centric API to model the application deployment, and KubeVela will deliver the application to target *runtime infrastructure* per policies and workflow declared by users and ensure the success.
### Runtime Infrastructures
Runtime infrastructures are where the applications are actually running on. KubeVela allows you to deploy and manage applications on both Kubernetes based infrastructures (local, managed offerings, or IoT/Edge/On-Premise ones) and non-Kubernetes environments such as public/private clouds in a consistent workflow. KubeVela itself does not run on the runtime infrastructures, they two are fully decoupled.

View File

@ -25,38 +25,221 @@ worker vela-system deployments.apps Describes long-run
你所看到,在 vela-system 命令空间下的 webservice、task 和 worker 等组件类型,都是通过 CUE 模版来内置的。
我们以一个简单的 task 类型组件进行讲解,它用来给定一个运行代码或脚本的作业
KubeVela 内置的这几种开箱即用的 CUE 组件,涵盖了主流的微服务场景
先用 vela CLI 查询熟悉一下 task 组件的配置项目
我们以 Web Service 作为例子进行讲解,编写如下的 YAML 文件
```
$ vela show task
# Properties
+---------+-------------+----------+----------+---------+
| NAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT |
+---------+-------------+----------+----------+---------+
| cmd | | []string | false | |
| count | | int | true | 1 |
| restart | | string | true | Never |
| image | | string | true | |
+---------+-------------+----------+----------+---------+
```
然后编写一个如下的 YMAL 并部署到运行时集群:
```yaml
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: app-worker
name: website
spec:
components:
- name: mytask
type: task
- name: frontend
type: webservice
properties:
image: perl
count: 10
cmd: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"]
image: oamdev/testapp:v1
cmd: ["node", "server.js"]
port: 8080
cpu: "0.1"
env:
- name: FOO
value: bar
- name: FOO
valueFrom:
secretKeyRef:
name: bar
key: bar
```
部署到运行时集群,并通过 `vela ls` 查看是否成功:
```
$ kubectl apply -f web-service.yaml
application.core.oam.dev/website configured
$ vela ls
APP COMPONENT TYPE TRAITS PHASE HEALTHY STATUS CREATED-TIME
website frontend webservice rendering healthy 2021-07-15 11:24:52 +0800 CST
```
最后,在你想要通过自定义组件来满足需求的时候,可以自己查看管理员手册里的[自定义组件](../../platform-engineers/components/custom-component)进行开发,或者请求你们的平台管理员进行开发。
### 附录Web Service 配置项
你可以使用 vela show <组件名称> 的命令来查看详细信息,对所有组件适用。比如 Web Service 配置项如下:
```
# Properties
+------------------+-------------------------------------------------------------------------------------------+-----------------------------------+----------+---------+
| NAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT |
+------------------+-------------------------------------------------------------------------------------------+-----------------------------------+----------+---------+
| cmd | Commands to run in the container | []string | false | |
| env | Define arguments by using environment variables | [[]env](#env) | false | |
| image | Which image would you like to use for your service | string | true | |
| port | Which port do you want customer traffic sent to | int | true | 80 |
| imagePullPolicy | Specify image pull policy for your service | string | false | |
| cpu | Number of CPU units for the service, like `0.5` (0.5 CPU core), `1` (1 CPU core) | string | false | |
| memory | Specifies the attributes of the memory resource required for the container. | string | false | |
| volumes | Declare volumes and volumeMounts | [[]volumes](#volumes) | false | |
| livenessProbe | Instructions for assessing whether the container is alive. | [livenessProbe](#livenessProbe) | false | |
| readinessProbe | Instructions for assessing whether the container is in a suitable state to serve traffic. | [readinessProbe](#readinessProbe) | false | |
| imagePullSecrets | Specify image pull secrets for your service | []string | false | |
+------------------+-------------------------------------------------------------------------------------------+-----------------------------------+----------+---------+
########### readinessProbe
+---------------------+------------------------------------------------------------------------------------------------------+-------------------------+----------+---------+
| NAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT |
+---------------------+------------------------------------------------------------------------------------------------------+-------------------------+----------+---------+
| exec | Instructions for assessing container health by executing a command. Either this attribute or the | [exec](#exec) | false | |
| | httpGet attribute or the tcpSocket attribute MUST be specified. This attribute is mutually exclusive | | | |
| | with both the httpGet attribute and the tcpSocket attribute. | | | |
| httpGet | Instructions for assessing container health by executing an HTTP GET request. Either this attribute | [httpGet](#httpGet) | false | |
| | or the exec attribute or the tcpSocket attribute MUST be specified. This attribute is mutually | | | |
| | exclusive with both the exec attribute and the tcpSocket attribute. | | | |
| tcpSocket | Instructions for assessing container health by probing a TCP socket. Either this attribute or the | [tcpSocket](#tcpSocket) | false | |
| | exec attribute or the httpGet attribute MUST be specified. This attribute is mutually exclusive with | | | |
| | both the exec attribute and the httpGet attribute. | | | |
| initialDelaySeconds | Number of seconds after the container is started before the first probe is initiated. | int | true | 0 |
| periodSeconds | How often, in seconds, to execute the probe. | int | true | 10 |
| timeoutSeconds | Number of seconds after which the probe times out. | int | true | 1 |
| successThreshold | Minimum consecutive successes for the probe to be considered successful after having failed. | int | true | 1 |
| failureThreshold | Number of consecutive failures required to determine the container is not alive (liveness probe) or | int | true | 3 |
| | not ready (readiness probe). | | | |
+---------------------+------------------------------------------------------------------------------------------------------+-------------------------+----------+---------+
############### tcpSocket
+------+---------------------------------------------------------------------------------------+------+----------+---------+
| NAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT |
+------+---------------------------------------------------------------------------------------+------+----------+---------+
| port | The TCP socket within the container that should be probed to assess container health. | int | true | |
+------+---------------------------------------------------------------------------------------+------+----------+---------+
############# httpGet
+-------------+---------------------------------------------------------------------------------------+-------------------------------+----------+---------+
| NAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT |
+-------------+---------------------------------------------------------------------------------------+-------------------------------+----------+---------+
| path | The endpoint, relative to the port, to which the HTTP GET request should be directed. | string | true | |
| port | The TCP socket within the container to which the HTTP GET request should be directed. | int | true | |
| httpHeaders | | [[]httpHeaders](#httpHeaders) | false | |
+-------------+---------------------------------------------------------------------------------------+-------------------------------+----------+---------+
############## httpHeaders
+-------+-------------+--------+----------+---------+
| NAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT |
+-------+-------------+--------+----------+---------+
| name | | string | true | |
| value | | string | true | |
+-------+-------------+--------+----------+---------+
############ exec
+---------+------------------------------------------------------------------------------------------------------+----------+----------+---------+
| NAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT |
+---------+------------------------------------------------------------------------------------------------------+----------+----------+---------+
| command | A command to be executed inside the container to assess its health. Each space delimited token of | []string | true | |
| | the command is a separate array element. Commands exiting 0 are considered to be successful probes, | | | |
| | whilst all other exit codes are considered failures. | | | |
+---------+------------------------------------------------------------------------------------------------------+----------+----------+---------+
###### livenessProbe
+---------------------+------------------------------------------------------------------------------------------------------+-------------------------+----------+---------+
| NAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT |
+---------------------+------------------------------------------------------------------------------------------------------+-------------------------+----------+---------+
| exec | Instructions for assessing container health by executing a command. Either this attribute or the | [exec](#exec) | false | |
| | httpGet attribute or the tcpSocket attribute MUST be specified. This attribute is mutually exclusive | | | |
| | with both the httpGet attribute and the tcpSocket attribute. | | | |
| httpGet | Instructions for assessing container health by executing an HTTP GET request. Either this attribute | [httpGet](#httpGet) | false | |
| | or the exec attribute or the tcpSocket attribute MUST be specified. This attribute is mutually | | | |
| | exclusive with both the exec attribute and the tcpSocket attribute. | | | |
| tcpSocket | Instructions for assessing container health by probing a TCP socket. Either this attribute or the | [tcpSocket](#tcpSocket) | false | |
| | exec attribute or the httpGet attribute MUST be specified. This attribute is mutually exclusive with | | | |
| | both the exec attribute and the httpGet attribute. | | | |
| initialDelaySeconds | Number of seconds after the container is started before the first probe is initiated. | int | true | 0 |
| periodSeconds | How often, in seconds, to execute the probe. | int | true | 10 |
| timeoutSeconds | Number of seconds after which the probe times out. | int | true | 1 |
| successThreshold | Minimum consecutive successes for the probe to be considered successful after having failed. | int | true | 1 |
| failureThreshold | Number of consecutive failures required to determine the container is not alive (liveness probe) or | int | true | 3 |
| | not ready (readiness probe). | | | |
+---------------------+------------------------------------------------------------------------------------------------------+-------------------------+----------+---------+
########## tcpSocket
+------+---------------------------------------------------------------------------------------+------+----------+---------+
| NAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT |
+------+---------------------------------------------------------------------------------------+------+----------+---------+
| port | The TCP socket within the container that should be probed to assess container health. | int | true | |
+------+---------------------------------------------------------------------------------------+------+----------+---------+
######## httpGet
+-------------+---------------------------------------------------------------------------------------+-------------------------------+----------+---------+
| NAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT |
+-------------+---------------------------------------------------------------------------------------+-------------------------------+----------+---------+
| path | The endpoint, relative to the port, to which the HTTP GET request should be directed. | string | true | |
| port | The TCP socket within the container to which the HTTP GET request should be directed. | int | true | |
| httpHeaders | | [[]httpHeaders](#httpHeaders) | false | |
+-------------+---------------------------------------------------------------------------------------+-------------------------------+----------+---------+
######### httpHeaders
+-------+-------------+--------+----------+---------+
| NAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT |
+-------+-------------+--------+----------+---------+
| name | | string | true | |
| value | | string | true | |
+-------+-------------+--------+----------+---------+
####### exec
+---------+------------------------------------------------------------------------------------------------------+----------+----------+---------+
| NAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT |
+---------+------------------------------------------------------------------------------------------------------+----------+----------+---------+
| command | A command to be executed inside the container to assess its health. Each space delimited token of | []string | true | |
| | the command is a separate array element. Commands exiting 0 are considered to be successful probes, | | | |
| | whilst all other exit codes are considered failures. | | | |
+---------+------------------------------------------------------------------------------------------------------+----------+----------+---------+
##### volumes
+-----------+---------------------------------------------------------------------+--------+----------+---------+
| NAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT |
+-----------+---------------------------------------------------------------------+--------+----------+---------+
| name | | string | true | |
| mountPath | | string | true | |
| type | Specify volume type, options: "pvc","configMap","secret","emptyDir" | string | true | |
+-----------+---------------------------------------------------------------------+--------+----------+---------+
## env
+-----------+-----------------------------------------------------------+-------------------------+----------+---------+
| NAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT |
+-----------+-----------------------------------------------------------+-------------------------+----------+---------+
| name | Environment variable name | string | true | |
| value | The value of the environment variable | string | false | |
| valueFrom | Specifies a source the value of this var should come from | [valueFrom](#valueFrom) | false | |
+-----------+-----------------------------------------------------------+-------------------------+----------+---------+
### valueFrom
+--------------+--------------------------------------------------+-------------------------------+----------+---------+
| NAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT |
+--------------+--------------------------------------------------+-------------------------------+----------+---------+
| secretKeyRef | Selects a key of a secret in the pod's namespace | [secretKeyRef](#secretKeyRef) | true | |
+--------------+--------------------------------------------------+-------------------------------+----------+---------+
#### secretKeyRef
+------+------------------------------------------------------------------+--------+----------+---------+
| NAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT |
+------+------------------------------------------------------------------+--------+----------+---------+
| name | The name of the secret in the pod's namespace to select from | string | true | |
| key | The key of the secret to select from. Must be a valid secret key | string | true | |
+------+------------------------------------------------------------------+--------+----------+---------+
```