Init docs for kubevela

Move non user facint things into e2e
This commit is contained in:
Harry Zhang
2020-10-25 22:34:33 -07:00
parent 24a92c9cbc
commit ec5b45a428
108 changed files with 332 additions and 376 deletions

View File

@@ -1,5 +1,9 @@
# CONTRIBUTING
## About KubeVela
KubeVela project is initialized and maintained by the cloud native community since day 0 with [bootstrapping contributors from 8+ different organizations](https://github.com/oam-dev/kubevela/graphs/contributors). We intend for KubeVela to have a open governance since the very beginning and donate the project to neutral foundation as soon as it's released.
This doc explains how to set up a development environment, so you can get started
contributing to `kubevela` or build a PoC (Proof of Concept).

340
README.md
View File

@@ -1,338 +1,28 @@
![alt](resources/KubeVela-03.png)
*Making shipping applications more enjoyable.*
# KubeVela
The Open Application Platform based on Kubernetes and Open Application Model (OAM).
For developers, KubeVela is a tool that enables developers to describe and ship their applications with simple commands.
## Project Status
For platform engineers, KubeVela is a fully extensible engine that enables platform builders to integrate ecosystem capabilities at ease so to create their own application platforms.
:rotating_light: **Warning: this project is still a work in progress with lots of rough edges, please don't look inside unless you know what you are doing.**
- Slack: [Discuss](https://cloud-native.slack.com/archives/C01BLQ3HTJA)
- Gitter: [Community](https://gitter.im/oam-dev/community)
KubeVela project is initialized and maintained by the cloud native community since day 0 with [bootstrapping contributors from 8+ different organizations](https://github.com/oam-dev/kubevela/graphs/contributors). We intend for KubeVela to have a open governance since the very beginning and donate the project to neutral foundation as soon as it's released.
## Quick Start
## Purpose and Goal
Quick start guides are available on [this section](docs/quick-start.md).
- For developers and operators
- KubeVela, as an out-of-box Cloud Native Application Management Platform, provides numerous workloads and operation tooling for application defining, deployment, scaling, traffic, rollout, routing, monitoring, logging, alerting, CI/CD and so on.
- For platform builders
- KubeVela, as a highly extensible PaaS/Serverless Core, provides pluggable capabilities, an elegant way to integrate any workloads and operational capabilities (i.e. traits).
## Documentation
## Design and Architecture
Read more about [KubeVela's high level design and architecture](DESIGN.md).
## Demo Instructions
See the demo instructions below get a sense of what we've accomplished and are working on.
## Install
### Prerequisites
- Kubernetes cluster running Kubernetes v1.15.0 or greater
- kubectl current context is configured for the target cluster install
- ```kubectl config current-context```
### Get the Vela CLI
Download the `vela` binary from the [releases page](https://github.com/oam-dev/kubevela/releases). Unpack the `vela` binary and add it to `$PATH` to get started.
```shell
sudo mv ./vela /usr/local/bin/vela
```
### Install Vela Core
```console
$ vela install
```
This command will install vela core controller into your K8s cluster, along with built-in workloads and traits.
## Using KubeVela
After `vela install` you will see available workloads and traits.
```console
$ vela workloads
NAME DEFINITION
backend podspecworkloads.standard.oam.dev
task jobs.batch.k8s.io
webservice podspecworkloads.standard.oam.dev
```
```console
$ vela traits
NAME DEFINITION APPLIES TO
route routes.standard.oam.dev webservice,backend
scale manualscalertraits.core.oam.dev webservice,backend
```
### Create environment
Before working with your application, you should prepare an deploy environment for it (e.g. test, staging, prod etc).
```console
$ vela env init demo --namespace demo --email my@email.com --domain kubevela.io
ENVIROMENT demo CREATED, Namespace: demo, Email: my@email.com.
```
Vela will create a Kubernetes namespace called `demo` , with namespace level issuer for certificate generation using the email you provided.
You could check the environment metadata in your local:
```console
$ cat ~/.vela/envs/demo/config.json
{"name":"demo","namespace":"demo","email":"my@email.com","domain":"kubevela.io","issuer":"oam-env-demo"}
```
### Create simple component
Then let's create application, we will use the `demo` environment.
```console
$ vela comp deploy mycomp -t webservice --image crccheck/hello-world --port 8000 --app myapp
Creating AppConfig appcomp
SUCCEED
```
### Create micro-services application
Vela supports micro-services application by default thanks to Open Application Model.
```console
$ vela comp deploy db -t backend --image crccheck/hello-world --app myapp
Creating App myapp
SUCCEED
```
```console
$ vela comp ls
NAME APP WORKLOAD TRAITS STATUS CREATED-TIME
db myapp backend Deployed 2020-09-18 22:42:04 +0800 CST
mycomp myapp webservice Deployed 2020-09-18 22:42:04 +0800 CST
```
#### Under the hood
In Kubernetes, vela creates an OAM application configuration named `myapp` to manage all related components.
```console
$ kubectl get appconfig -n demo
NAME AGE
myapp 24s
```
```console
$ kubectl get components -n demo
NAME AGE
mycomp 24s
db 10s
```
Vela Core is responsible for managing the underlying Kubernetes resources linked with the components and application configuration above.
```console
$ kubectl get deployment -n demo
NAME READY UP-TO-DATE AVAILABLE AGE
mycomp 1/1 1 1 38s
db 1/1 1 1 20s
```
```console
$ kubectl get svc -n demo
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
mycomp ClusterIP 172.21.4.228 <none> 8080/TCP 49s
```
### Manage operational configurations of the application
Vela leverages OAM trait system to manage operational configurations such as `scale`, `route`, `canary`, `autocale`etc in application centric approach.
Let's take `route` as example.
### `route`
If you want to use `route`, please make sure you have [nginx-ingress controller[https://kubernetes.github.io/ingress-nginx/deploy/] in your cluster.
```console
$ vela route mycomp --app myapp
Adding route for app mycomp
Succeeded!
```
For now you have to check the public address manually (this will be fixed soon so `vela route` will return visiting URL as result):
```console
$ kubectl get ingress -n demo
NAME HOSTS ADDRESS PORTS AGE
mycomp-trait-5b576c4fc mycomp.kubevela.io 123.57.10.233 80, 443 73s
```
And after you configure the `kubevela.io` domain pointing to the public address above.
Your application will be reached by `https://mycomp.kubevela.io` with `mTLS` automatically enabled.
### Under the hood
Vela will manage the underlying Kubernetes resource which implements the `route` trait.
```console
$ kubectl get routes.standard.oam.dev -n demo
NAME AGE
mycomp-trait-5b576c4fc 18s
```
`routes.standard.oam.dev` is a CRD controller which will manage ingress, domain, certificate etc for your application.
### Check status
Check the application:
```console
$ vela app show myapp
About:
Name: myapp
Created at: 2020-09-18 22:42:04.191171 +0800 CST
Updated at: 2020-09-18 22:51:11.128997 +0800 CST
Environment:
Namespace: demo
Components:
Name Type Traits
db backend
mycomp webservice route
```
Check specific component:
```console
$ vela comp show mycomp
About:
Name: mycomp
WorkloadType: webservice
Application: myapp
Environment:
Namespace: demo
Arguments:
image: crccheck/hello-world
name: mycomp
port: 8000
Traits:
route:
domain: mycomp.kubevela.io
issuer: oam-env-demo
name: route
```
```
$ vela comp status mycomp
Showing status of Component mycomp deployed in Environment demo
Component Status:
Name: mycomp PodSpecWorkload(type) UNKNOWN APIVersion standard.oam.dev/v1alpha1 Kind PodSpecWorkload workload is unknown for HealthScope
Traits
└─Trait/route
Last Deployment:
Created at: 2020-09-18 22:42:04 +0800 CST
Updated at: 2020-09-18T22:51:11+08:00
```
### Delete application or component
```console
$ vela app ls
myapp
```
```console
$ vela comp ls
NAME APP WORKLOAD TRAITS STATUS CREATED-TIME
db myapp backend Deployed 2020-09-18 22:42:04 +0800 CST
mycomp myapp webservice route Deployed 2020-09-18 22:42:04 +0800 CST
```
```console
$ vela comp delete db
Deleting Component 'db' from Application 'db'
```
```console
$ vela comp ls
NAME APP WORKLOAD TRAITS STATUS CREATED-TIME
mycomp myapp webservice route Deployed 2020-09-18 22:42:04 +0800 CST
```
```console
$ vela app delete myapp
Deleting Application "myapp"
delete apps succeed myapp from demo
```
## Dashboard
Vela has a simple client side dashboard for you to interact with (note it's still under development). The functionality is equivalent to the vela cli.
```console
$ vela dashboard
```
#### Auto-completion
##### bash
```console
To load completions in your current shell session:
$ source <(vela completion bash)
To load completions for every new session, execute once:
Linux:
$ vela completion bash > /etc/bash_completion.d/vela
MacOS:
$ vela completion bash > /usr/local/etc/bash_completion.d/vela
```
##### zsh
```console
To load completions in your current shell session:
$ source <(vela completion zsh)
To load completions for every new session, execute once:
$ vela completion zsh > "${fpath[1]}/_vela"
```
### Clean your environment
```console
$ helm uninstall kubevela -n vela-system
release "kubevela" uninstalled
```
```console
$ kubectl delete crd workloaddefinitions.core.oam.dev traitdefinitions.core.oam.dev scopedefinitions.core.oam.dev
customresourcedefinition.apiextensions.k8s.io "workloaddefinitions.core.oam.dev" deleted
customresourcedefinition.apiextensions.k8s.io "traitdefinitions.core.oam.dev" deleted
```
```console
$ rm -r ~/.vela
```
Full documentation is available on the [documentation section](docs/README.md).
## Contributing
Check out [CONTRIBUTING.md](./CONTRIBUTING.md) to see how to develop with KubeVela.
Check out [CONTRIBUTING](./CONTRIBUTING.md) to see how to develop with KubeVela.
## Code of Conduct
This project has adopted the [CNCF Code of Conduct](https://github.com/cncf/foundation/blob/master/code-of-conduct.md). See [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) for further details.
This project has adopted the [CNCF Code of Conduct](https://github.com/cncf/foundation/blob/master/code-of-conduct.md). See [CODE OF CONDUCT](CODE_OF_CONDUCT.md) for details.
> NOTE: KubeVela is an early project and iterating quickly to continue to make it easier to ship applications and build platforms atop. It's still under preview release for now.

30
docs/README.md Normal file
View File

@@ -0,0 +1,30 @@
# KubeVela Documentation
Learn and use KubeVela with tutorials and user stories.
**Overview**
- [Introduction](introduction.md)
- [Quick Start](quick-start.md)
- [Concepts](concepts.md)
**For Developers**
- [Configuring Deployment Environment](developers/config-enviroments.md)
- [Deploying Application](developers/deploy-app.md)
- [Visiting Application](developers/set-route.md)
- [Setting Auto-scaling Policy](developers/set-autoscaling.md)
- [Setting Rollout Strategy](developers/set-rollout.md)
- [Monitoring Application](developers/set-metrics.md)
- [Using Appfile](developers/devex/appfile.md)
- [Execute Commands in Container](developers/exec-cmd.md)
- [Check Application Logs](developers/check-logs.md)
- [Configuring Application](developers/config-app.md)
- [Consuming Cloud Services](developers/cloud-service.md)
**For Platform Engineers**
- [Extending KubeVela](platform-engineers/extending-kubevela.md)
**Internals**
- [Design and Architecture](design.md)
**Roadmap**
- [Roadmap of KubeVela v1.0](roadmap.md)

1
docs/concepts.md Normal file
View File

@@ -0,0 +1 @@
<!-- Glossaries in KubeVela-->

View File

@@ -54,7 +54,7 @@ Thus, KubeVela choose to:
Instead of creating a in-house "application CRD", KubeVela adopts [Open Application Model (OAM)](https://github.com/oam-dev/spec) as its application definition, since OAM:
1. Defines micro-services application by default.
2. Can model operations as part of the application (i.e. `Trait`).
2. Model operations as part of the application (i.e. `Trait`).
2. Highly extensible: every workload and trait in OAM is a independent definition, no abstraction or capability lock-in.
### 2. Capability Oriented Architecture
@@ -130,48 +130,11 @@ $ vela comp deploy frontend -t webservice --image oamdev/testapp:v1 --port 80 --
The `-t webservice --image oamdev/testapp:v1 --port 80` arguments are not hard coded, they are schema defined by in-line CUE template of `WebService` workload definition.
The `appfile` is essentially a YAML version of command line tool so we can support more complex and serious scenarios by simply running `$ vela up hello-world.yaml`:
The `appfile` is essentially a YAML version of command line tool so we can support more complex and serious scenarios by simply running `$ vela up my-app.yaml`:
```yaml
version: "1.0-alpha.1"
![alt](resources/appfile.png)
name: helloworld
services:
express-server:
type: webservice # workload type
build:
docker:
file: Dockerfile
context: .
image: oamdev/testapp:v1
cmd: ["node", "server.js"]
ports:
- 8080:80
env:
- FOO=bar
scale: # scaling trait
replica: 2
auto:
range: "1-10"
cpu: 80
qps: 1000
canary: # canary trait
step: 5
headers:
- "foo:bar.*"
redis:
image: oamdev/redis
secrets:
my-secret: /local-path/my-secret # load local file into k8s secret
```
The schema of above `appfile` is not hard coded, they are defined by in-line CUE templates of `WebService` workload definition, `Scaling` trait definition and `Canary` trait definition.
The schema of above `appfile` is not hard coded, they are structured following OAM and enforced by CUE templates of `WebService` workload definition, `Scaling` trait definition and `Canary` trait definition.
We will skip the example of dashboard, but similarly, the schema of GUI forms are defined by in-lined CUE template of definition objects.
@@ -185,8 +148,8 @@ From highest level, KubeVela is composed by only two components:
Including: `cli`, `dashboard`, `appfile`, they are all client side tools to provide developer facing abstractions by leveraging CUElang based parametering and templating.
### 2. KubeVela core
Including:
- [OAM Kubernetes runtime](https://github.com/crossplane/oam-kubernetes-runtime) to provide application level building blocks such as `Component` and `Application` etc.
- [Built-in workload and trait controllers](https://github.com/oam-dev/kubevela/tree/master/pkg/controller/v1alpha1) to implement core capabilities such as `webservice`, `route` and `rollout` etc.
- [OAM Kubernetes runtime](https://github.com/crossplane/oam-kubernetes-runtime) to provide application-centric building blocks such as `Component` and `Application` etc.
- [Built-in workload and trait controllers](https://github.com/oam-dev/kubevela/tree/master/pkg/controller/v1alpha1) to provide core capabilities such as `webservice`, `route` and `rollout` etc.
- Capability Management: manage features of KubeVela following Capability Oriented Architecture.
- Every feature of KubeVela is a "addon", and it is registered by Kubernetes API resource (including CRD) leveraging OAM definition objects.
- CRD Registry: register controllers of Kubernetes add-ons and discover them by CRD. This will enable automatically install controllers/operators when CRD is missing in the cluster.

View File

View File

View File

View File

@@ -0,0 +1,20 @@
# Configuring Deployment Environments
Before working with your application, you need to prepare a deployment environment (e.g. test, staging, prod etc) which will configure the workspace, email for certificate issuer and domain for your application.
## Create environment
> TODO `--namespace` and `--domain` should be able to skipped
> TODO why don't use xip.io as demo?
```console
$ vela env init demo --namespace demo --email my@email.com --domain kubevela.demo
ENVIROMENT demo CREATED, Namespace: demo, Email: my@email.com.
```
## Check the deployment environment metadata
```console
$ cat ~/.vela/envs/demo/config.json
{"name":"demo","namespace":"demo","email":"my@email.com","domain":"kubevela.demo","issuer":"oam-env-demo"}
```

View File

@@ -0,0 +1,95 @@
# Deploying Application
## `vela app init`
The simplest way to deploy an application with KubeVela is using `$ vela app init` .
```console
$ vela app init
```
Check the application:
```console
$ vela app show myapp
About:
Name: myapp
Created at: 2020-09-18 22:42:04.191171 +0800 CST
Updated at: 2020-09-18 22:51:11.128997 +0800 CST
Environment:
Namespace: demo
Components:
Name Type Traits
frontend webservice route
```
Check the deployed service:
```console
$ vela svc show mycomp
About:
Name: frontend
WorkloadType: webservice
Application: myapp
Environment:
Namespace: demo
Arguments:
image: crccheck/hello-world
name: frontend
port: 8000
Traits:
route:
domain: frontend.kubevela.io
issuer: oam-env-demo
name: route
```
## Step by Step
You can also use KubeVela CLI to deploy application step by step, with more detailed configurations.
Check the available workload types.
```console
$ vela workloads
TODO
```
Deploy the first service named `frontend` with `Web Service` type.
```console
$ vela svc deploy frontend -t webservice --image crccheck/hello-world --app myapp
Creating frontend ...
SUCCEED
```
> TODO auto generate a random application name, so --app myapp becomes optional
Deploy the second service named `backend` with "Backend Worker" type for the same application.
```console
$ vela svc deploy backend -t backendworker --image crccheck/hello-world --app myapp
Creating backend
SUCCEED
```
```console
$ vela svc ls
NAME APP WORKLOAD TRAITS STATUS CREATED-TIME
backend myapp backendworker Deployed 2020-09-18 22:42:04 +0800 CST
frontend myapp webservice Deployed 2020-09-18 22:42:04 +0800 CST
```

View File

@@ -0,0 +1,3 @@
# Appfile
> TODO a complete demo to show off Appfile with route, autoscaling and rollout capability

View File

@@ -0,0 +1,28 @@
# KubeVela CLI
Learn about general configurations for `vela` command line tool. For the usage of the CLI, please check the KubeVela's [user documentation](../../README.md) instead.
### Auto-completion
#### bash
```console
To load completions in your current shell session:
$ source <(vela completion bash)
To load completions for every new session, execute once:
Linux:
$ vela completion bash > /etc/bash_completion.d/vela
MacOS:
$ vela completion bash > /usr/local/etc/bash_completion.d/vela
```
#### zsh
```console
To load completions in your current shell session:
$ source <(vela completion zsh)
To load completions for every new session, execute once:
$ vela completion zsh > "${fpath[1]}/_vela"
```

View File

@@ -0,0 +1,10 @@
# KubeVela Dashboard (WIP)
KubeVela has a simple client side dashboard for you to interact with. The functionality is equivalent to the vela cli.
```console
$ vela dashboard
```
> NOTE: this feature is still under development.

View File

View File

@@ -0,0 +1,5 @@
# KubeVela Workload Types and Traits References.
Note: All the contents under this directory are designed to be referenced by other documentations as the full schema or usage of specific workload types or traits..
In the upcoming releases, we plan to auto-generate all these reference documentations from the CUE templates in KubeVela's definition objects.

View File

@@ -0,0 +1,3 @@
# Setting Auto-scaling Policy
> TODO

View File

@@ -0,0 +1,3 @@
# Monitoring Application
> TODO

View File

@@ -0,0 +1,3 @@
# Setting Rollout Strategy
> TODO

View File

@@ -0,0 +1,28 @@
# Visiting Application
Once your web services of the application is deployed, you can visit it from outside world via `route` feature.
## `route`
```console
$ vela svc ls
NAME APP WORKLOAD TRAITS STATUS CREATED-TIME
frontend myapp webservice Deployed 2020-09-18 22:42:04 +0800 CST
```
```console
$ vela route frontend --app myapp
Adding route for app frontend
Succeeded!
Route information:
HOSTS ADDRESS PORTS AGE
frontend.kubevela.demo 123.57.10.233 80, 443 73s
```
> TODO why don't use xip.io as demo?
Please configure `kubevela.demo` domain pointing to the public address (e.g. `123.57.10.233`) and your application can be then reached by `https://frontend.kubevela.demo`.
> You can achieve this by modifying `/etc/hosts` if your domain is fake.

0
docs/exec-cmd.md Normal file
View File

54
docs/install.md Normal file
View File

@@ -0,0 +1,54 @@
# Install KubeVela
## Prerequisites
- ubernete cluster which is v1.15.0 or greater
- kubectl current context is configured for the target cluster install
- ```kubectl config current-context```
### Minikube
> TODO enable ingress controller
### KinD
> TODO anything need to do?
## Get KubeVela
> TODO please give a copy-paste friendly shell instead of instructions
1. Download the latest `vela` binary from the [releases page](https://github.com/oam-dev/kubevela/releases).
2. Unpack the `vela` binary and add it to `$PATH` to get started.
```console
$ sudo mv ./vela /usr/local/bin/vela
```
## Initialize KubeVela
```console
$ vela install
```
This command will install KubeVela server components in your Kubernetes cluster.
## Verify
> TODO Paste a output of successful installation here.
## Clean Up
```console
$ helm uninstall kubevela -n vela-system
release "kubevela" uninstalled
```
```console
$ kubectl delete crd workloaddefinitions.core.oam.dev traitdefinitions.core.oam.dev scopedefinitions.core.oam.dev
customresourcedefinition.apiextensions.k8s.io "workloaddefinitions.core.oam.dev" deleted
customresourcedefinition.apiextensions.k8s.io "traitdefinitions.core.oam.dev" deleted
```
```console
$ rm -r ~/.vela
```

1
docs/introduction.md Normal file
View File

@@ -0,0 +1 @@
> TODO Welcome to KubeVela! This documentation covers what KubeVela is, why KubeVela, and how KubeVela vs others.

View File

@@ -0,0 +1 @@
<!-- Three steps to integrate a external capability -->

13
docs/quick-start.md Normal file
View File

@@ -0,0 +1,13 @@
# Quick Start
## Install
Please follow [this simple guide](install.md).
## Deploy Application
```console
$ vela app init
```
> TODO Please give an full example of `vela app init` with route

1
docs/roadmap.md Normal file
View File

@@ -0,0 +1 @@
> TODO KubeVela v1.0

View File

@@ -13,7 +13,7 @@ OAM will automatically install a prometheus stack in the `monitoring` namespace
## Run ApplicationConfiguration
```shell script
kubectl apply -f documentation/samples/metrics-demo/
kubectl apply -f e2e/raw-objects/samples/metrics-demo/
workloaddefinition.core.oam.dev/deployments.apps created
traitdefinition.core.oam.dev/services created
traitdefinition.core.oam.dev/metricstraits.standard.oam.dev created

View File

@@ -16,15 +16,15 @@ bin/vela install
## Run ApplicationConfiguration V1
```shell script
kubectl apply -f documentation/samples/rollout-demo/definitions.yaml
kubectl apply -f e2e/raw-objects/samples/rollout-demo/definitions.yaml
traitdefinition.core.oam.dev/canaries.flagger.app created
traitdefinition.core.oam.dev/ingresses.extensions created
workloaddefinition.core.oam.dev/deployments.apps created
kubectl apply -f documentation/samples/rollout-demo/deploy-component-v1.yaml
kubectl apply -f e2e/raw-objects/samples/rollout-demo/deploy-component-v1.yaml
component.core.oam.dev/rollout-demo-app created
kubectl apply -f documentation/samples/rollout-demo/appConfig-rollout-v1.yaml
kubectl apply -f e2e/raw-objects/samples/rollout-demo/appConfig-rollout-v1.yaml
applicationconfiguration.core.oam.dev/sample-application-rollout created
```
@@ -41,10 +41,10 @@ rollout-demo-app-v1 1/1 1 1 80s
## Upgrade the component to v2 and change the revision name of the component in the appConfig
```shell script
kubectl apply -f documentation/samples/rollout-demo/deploy-component-v2.yaml
kubectl apply -f e2e/raw-objects/samples/rollout-demo/deploy-component-v2.yaml
component.core.oam.dev/rollout-demo-app configured
kubectl apply -f documentation/samples/rollout-demo/appConfig-rollout-v2.yaml
kubectl apply -f e2e/raw-objects/samples/rollout-demo/appConfig-rollout-v2.yaml
applicationconfiguration.core.oam.dev/sample-application-rollout created
```
@@ -140,7 +140,7 @@ rollout-demo-app-v2 7/7 7 7 15m
## Roll back to V1
```shell script
kubectl apply -f documentation/samples/rollout-demo/appConfig-rollback-v1.yaml
kubectl apply -f e2e/raw-objects/samples/rollout-demo/appConfig-rollback-v1.yaml
applicationconfiguration.core.oam.dev/sample-application-rollout configured
```
@@ -171,7 +171,7 @@ rollout-demo-app-v2 0/0 0 0 24m
## Clean up
```shell script
kubectl delete -f documentation/samples/rollout-demo/
kubectl delete -f e2e/raw-objects/samples/rollout-demo/
```
## Improvements

Some files were not shown because too many files have changed in this diff Show More