Compare commits

..

2 Commits

Author SHA1 Message Date
Sun Jianbo
17ac119f9b Merge pull request #297 from wonderflow/readme
add more readme
2020-09-18 23:11:21 +08:00
天元
829b813b1a add move readme 2020-09-18 23:02:10 +08:00
3 changed files with 240 additions and 44 deletions

251
README.md
View File

@@ -24,59 +24,254 @@ sudo mv ./vela /usr/local/bin/vela
```shell script
$ vela install
```
This command will install vela core controller into your K8s cluster, along with built-in workloads and traits.
## Demos
* Create ENV
After `vela install` you will have workloads and traits locally, and available to use by vela cli.
```shell script
vela env init myenv --namespace myenv --email my@email.com --domain kubevela.io
$ vela workloads
NAME DEFINITION
backend containerizeds.standard.oam.dev
containerized containerizedworkloads.core.oam.dev
task jobs
webservice containerizeds.standard.oam.dev
```
* Create Component
```shell script
$ vela traits
NAME DEFINITION APPLIES TO
route routes.standard.oam.dev webservice
backend
scale manualscalertraits.core.oam.dev webservice
backend
```
For example, use the following command to create and run an application.
### Create ENV
Before working with your application, you should create an env for it.
```shell script
$ vela comp run mycomp -t webservice --image crccheck/hello-world --port 8000
$ vela env init myenv --namespace myenv --email my@email.com --domain kubevela.io
ENV myenv CREATED, Namespace: myenv, Email: my@email.com.
```
It will create a namespace called myenv
```shell script
$ kubectl get ns
NAME STATUS AGE
myenv Active 40s
```
A namespace level issuer for certificate generation with email.
```shell script
$ kubectl get issuers.cert-manager.io -n myenv
NAME READY AGE
oam-env-myenv True 40s
```
A env metadata in your local:
```shell script
$ cat ~/.vela/envs/myenv/config.json
{"name":"myenv","namespace":"myenv","email":"my@email.com","domain":"kubevela.io","issuer":"oam-env-myenv"}
```
### Create Component
Then let's create application, we will use our env created by default.
```shell script
$ vela comp run mycomp -t webservice --image crccheck/hello-world --port 8000 --app myapp
Creating AppConfig appcomp
SUCCEED
```
* Add Trait
It will create component named `mycomp`.
```shell script
$ vela route mycomp
Adding route for app abc
Succeeded!
$ kubectl get components -n myenv
NAME WORKLOAD-KIND AGE
mycomp Containerized 10s
```
* Check Status
And an AppConfig named myapp.
```
$ vela comp status abc
Showing status of Component abc deployed in Environment t2
Component Status:
Name: abc Containerized(type) UNKNOWN APIVersion standard.oam.dev/v1alpha1 Kind Containerized workload is unknown for HealthScope
Traits
└─Trait/route
Last Deployment:
Created at: 2020-09-18 18:47:09 +0800 CST
Updated at: 2020-09-18T18:47:16+08:00
```shell script
$ kubectl get appconfig -n myenv
NAME AGE
myapp 24s
```
* Delete App
Vela Core will work for AppConfig and create K8s deployment and service.
```shell script
$ kubectl get deployment -n myenv
NAME READY UP-TO-DATE AVAILABLE AGE
mycomp 1/1 1 1 38s
```
```shell script
$ kubectl get svc -n myenv
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
mycomp ClusterIP 172.21.4.228 <none> 8080/TCP 49s
```
### Multiple Component
Creating a new component in the same application is easy, just use the `--app` flag.
```shell script
$ vela comp run db -t backend --image crccheck/hello-world --app myapp
Creating App myapp
SUCCEED
```
```shell script
$ 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
```
Now we can see the application deployed, let's add route trait for visiting.
### Add Trait
```shell script
$ vela route mycomp --app myapp
Adding route for app mycomp
Succeeded!
```
It will create route trait for this component.
```shell script
$ kubeclt get routes.standard.oam.dev -n myenv
NAME AGE
mycomp-trait-5b576c4fc 18s
```
Controller of route trait which is part of vela core will create an ingress for it.
```shell script
$ kubectl get ingress -n myenv
NAME HOSTS ADDRESS PORTS AGE
mycomp-trait-5b576c4fc mycomp.kubevela.io 123.57.10.233 80, 443 73s
```
Please configure your domain pointing to the public address.
Then you will be able to visit it by `https://mycomp.kubevela.io`, `mTLS` is automatically enabled.
### Check Status
App level:
```shell script
$ 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: myenv
Components:
Name Type Traits
db backend
mycomp webservice route
```
Component Level:
```shell script
$ vela comp show mycomp
About:
Name: mycomp
WorkloadType: webservice
Application: myapp
Environment:
Namespace: myenv
Arguments:
image: crccheck/hello-world
name: mycomp
port: 8000
Traits:
route:
domain: mycomp.kubevela.io
issuer: oam-env-myenv
name: route
```
```
$ vela comp status mycomp
Showing status of Component mycomp deployed in Environment myenv
Component Status:
Name: mycomp Containerized(type) UNKNOWN APIVersion standard.oam.dev/v1alpha1 Kind Containerized 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 App or Component
```shell script
$ vela app ls
abc
myapp
```
$ vela app delete abc
Deleting Application "abc"
delete apps succeed abc from t2
```shell script
$ 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
```
```shell script
$ vela comp delete db
Deleting Component 'db' from Application 'db'
```
```shell script
$ vela comp ls
NAME APP WORKLOAD TRAITS STATUS CREATED-TIME
mycomp myapp webservice route Deployed 2020-09-18 22:42:04 +0800 CST
```
```shell script
$ vela app delete myapp
Deleting Application "myapp"
delete apps succeed myapp from myenv
```
## Dashboard
We also prepared a dashboard for you, but it's still in heavily development.
```shell script
$ vela dashboard
```
#### Auto-Completion

View File

@@ -11,8 +11,6 @@ spec:
childResourceKinds:
- apiVersion: apps/v1
kind: Deployment
- apiVersion: v1
kind: Service
extension:
template: |
#Template: {
@@ -21,16 +19,19 @@ spec:
metadata:
name: backend.name
spec: {
containers: [{
image: backend.image
name: backend.name
}]
replicas: 1
podSpec: {
containers: [{
image: backend.image
name: backend.name
}]
}
}
}
backend: {
name: string
// +usage=specify app image
// +short=i
image: string
}

View File

@@ -1,13 +1,16 @@
#Template: {
apiVersion: "core.oam.dev/v1alpha2"
kind: "ContainerizedWorkload"
apiVersion: "standard.oam.dev/v1alpha1"
kind: "Containerized"
metadata:
name: backend.name
spec: {
containers: [{
image: backend.image
name: backend.name
}]
replicas: 1
podSpec: {
containers: [{
image: backend.image
name: backend.name
}]
}
}
}
@@ -16,7 +19,4 @@ backend: {
// +usage=specify app image
// +short=i
image: string
// +usage=specify port for container
// +short=p
port: *6379 | int
}