mirror of
https://github.com/kubevela/kubevela.git
synced 2026-08-18 03:56:36 +00:00
doc: add app init, config, and capability references
additionally: - change backend workload type to worker - add cue format script Signed-off-by: Hongchao Deng <hongchaodeng1@gmail.com>
This commit is contained in:
@@ -20,7 +20,7 @@ endif
|
||||
all: build
|
||||
|
||||
# Run tests
|
||||
test: fmt vet lint
|
||||
test: vet lint
|
||||
go test -race -coverprofile=coverage.txt -covermode=atomic ./pkg/... ./cmd/...
|
||||
|
||||
# Build manager binary
|
||||
@@ -66,6 +66,7 @@ run: fmt vet
|
||||
# Run go fmt against code
|
||||
fmt:
|
||||
go fmt ./...
|
||||
./hack/cue-fmt.sh
|
||||
|
||||
# Run go vet against code
|
||||
vet:
|
||||
|
||||
@@ -16,28 +16,28 @@ spec:
|
||||
extension:
|
||||
template: |
|
||||
output: {
|
||||
apiVersion: "standard.oam.dev/v1alpha1"
|
||||
kind: "Route"
|
||||
spec: {
|
||||
host: parameter.domain
|
||||
apiVersion: "standard.oam.dev/v1alpha1"
|
||||
kind: "Route"
|
||||
spec: {
|
||||
host: parameter.domain
|
||||
|
||||
if parameter.issuer != "" {
|
||||
tls: {
|
||||
issuerName: parameter.issuer
|
||||
}
|
||||
}
|
||||
if parameter.issuer != "" {
|
||||
tls: {
|
||||
issuerName: parameter.issuer
|
||||
}
|
||||
}
|
||||
|
||||
if parameter["rules"] != _|_ {
|
||||
rules: parameter.rules
|
||||
}
|
||||
}
|
||||
if parameter["rules"] != _|_ {
|
||||
rules: parameter.rules
|
||||
}
|
||||
}
|
||||
}
|
||||
parameter: {
|
||||
domain: *"" | string
|
||||
issuer: *"" | string
|
||||
rules?: [...{
|
||||
path: string
|
||||
rewriteTarget: *"" | string
|
||||
}]
|
||||
domain: *"" | string
|
||||
issuer: *"" | string
|
||||
rules?: [...{
|
||||
path: string
|
||||
rewriteTarget: *"" | string
|
||||
}]
|
||||
}
|
||||
|
||||
|
||||
@@ -12,34 +12,33 @@ spec:
|
||||
extension:
|
||||
template: |
|
||||
output: {
|
||||
apiVersion: "v1"
|
||||
kind: "Job"
|
||||
metadata: name: context.name
|
||||
spec: {
|
||||
parallelism: parameter.count
|
||||
completions: parameter.count
|
||||
template: spec: {
|
||||
containers: [{
|
||||
name: context.name
|
||||
image: parameter.image
|
||||
apiVersion: "v1"
|
||||
kind: "Job"
|
||||
metadata: name: context.name
|
||||
spec: {
|
||||
parallelism: parameter.count
|
||||
completions: parameter.count
|
||||
template: spec: {
|
||||
containers: [{
|
||||
name: context.name
|
||||
image: parameter.image
|
||||
|
||||
if parameter["cmd"] != _|_ {
|
||||
command: parameter.cmd
|
||||
}
|
||||
command:
|
||||
}]
|
||||
}
|
||||
}
|
||||
if parameter["cmd"] != _|_ {
|
||||
command: parameter.cmd
|
||||
}
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
parameter: {
|
||||
// +usage=specify number of tasks to run in parallel
|
||||
// +short=c
|
||||
count: *1 | int
|
||||
// +usage=specify number of tasks to run in parallel
|
||||
// +short=c
|
||||
count: *1 | int
|
||||
|
||||
// +usage=specify app image
|
||||
// +short=i
|
||||
image: string
|
||||
// +usage=specify app image
|
||||
// +short=i
|
||||
image: string
|
||||
|
||||
cmd?: [...string]
|
||||
cmd?: [...string]
|
||||
}
|
||||
|
||||
|
||||
@@ -12,71 +12,71 @@ spec:
|
||||
extension:
|
||||
template: |
|
||||
output: {
|
||||
apiVersion: "apps/v1"
|
||||
kind: "Deployment"
|
||||
metadata: name: context.name
|
||||
spec: {
|
||||
replicas: 1
|
||||
apiVersion: "apps/v1"
|
||||
kind: "Deployment"
|
||||
metadata: name: context.name
|
||||
spec: {
|
||||
replicas: 1
|
||||
|
||||
selector: matchLabels: {
|
||||
"app.oam.dev/component": context.name
|
||||
}
|
||||
selector: matchLabels: {
|
||||
"app.oam.dev/component": context.name
|
||||
}
|
||||
|
||||
template: {
|
||||
metadata: labels: {
|
||||
"app.oam.dev/component": context.name
|
||||
}
|
||||
template: {
|
||||
metadata: labels: {
|
||||
"app.oam.dev/component": context.name
|
||||
}
|
||||
|
||||
spec: {
|
||||
containers: [{
|
||||
name: context.name
|
||||
image: parameter.image
|
||||
spec: {
|
||||
containers: [{
|
||||
name: context.name
|
||||
image: parameter.image
|
||||
|
||||
if parameter["cmd"] != _|_ {
|
||||
command: parameter.cmd
|
||||
}
|
||||
if parameter["cmd"] != _|_ {
|
||||
command: parameter.cmd
|
||||
}
|
||||
|
||||
if parameter["env"] != _|_ {
|
||||
env: parameter.env
|
||||
}
|
||||
|
||||
if context["config"] != _|_ {
|
||||
env: [
|
||||
for k, v in context.config {
|
||||
name: k
|
||||
value: v
|
||||
}
|
||||
]
|
||||
}
|
||||
if parameter["env"] != _|_ {
|
||||
env: parameter.env
|
||||
}
|
||||
|
||||
ports: [{
|
||||
containerPort: parameter.port
|
||||
}]
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
if context["config"] != _|_ {
|
||||
env: [
|
||||
for k, v in context.config {
|
||||
name: k
|
||||
value: v
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
ports: [{
|
||||
containerPort: parameter.port
|
||||
}]
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
parameter: {
|
||||
// +usage=specify app image
|
||||
// +short=i
|
||||
image: string
|
||||
// +usage=specify app image
|
||||
// +short=i
|
||||
image: string
|
||||
|
||||
cmd?: [...string]
|
||||
cmd?: [...string]
|
||||
|
||||
// +usage=specify port for container
|
||||
// +short=p
|
||||
port: *6379 | int
|
||||
// +usage=specify port for container
|
||||
// +short=p
|
||||
port: *6379 | int
|
||||
|
||||
env?: [...{
|
||||
name: string
|
||||
value?: string
|
||||
valueFrom?: {
|
||||
secretKeyRef: {
|
||||
name: string
|
||||
key: string
|
||||
}
|
||||
}
|
||||
}]
|
||||
env?: [...{
|
||||
name: string
|
||||
value?: string
|
||||
valueFrom?: {
|
||||
secretKeyRef: {
|
||||
name: string
|
||||
key: string
|
||||
}
|
||||
}
|
||||
}]
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
apiVersion: core.oam.dev/v1alpha2
|
||||
kind: WorkloadDefinition
|
||||
metadata:
|
||||
name: backend
|
||||
name: worker
|
||||
annotations:
|
||||
definition.oam.dev/apiVersion: "apps/v1"
|
||||
definition.oam.dev/kind: "Deployment"
|
||||
@@ -12,45 +12,45 @@ spec:
|
||||
extension:
|
||||
template: |
|
||||
output: {
|
||||
apiVersion: "apps/v1"
|
||||
kind: "Deployment"
|
||||
metadata:
|
||||
name: context.name
|
||||
spec: {
|
||||
replicas: 1
|
||||
|
||||
selector: matchLabels: {
|
||||
"app.oam.dev/component": context.name
|
||||
}
|
||||
apiVersion: "apps/v1"
|
||||
kind: "Deployment"
|
||||
metadata:
|
||||
name: context.name
|
||||
spec: {
|
||||
replicas: 1
|
||||
|
||||
template: {
|
||||
metadata: labels: {
|
||||
"app.oam.dev/component": context.name
|
||||
}
|
||||
|
||||
spec: {
|
||||
containers: [{
|
||||
name: context.name
|
||||
image: parameter.image
|
||||
selector: matchLabels: {
|
||||
"app.oam.dev/component": context.name
|
||||
}
|
||||
|
||||
if parameter["cmd"] != _|_ {
|
||||
command: parameter.cmd
|
||||
}
|
||||
}]
|
||||
}
|
||||
}
|
||||
template: {
|
||||
metadata: labels: {
|
||||
"app.oam.dev/component": context.name
|
||||
}
|
||||
|
||||
selector:
|
||||
matchLabels:
|
||||
"app.oam.dev/component": context.name
|
||||
}
|
||||
spec: {
|
||||
containers: [{
|
||||
name: context.name
|
||||
image: parameter.image
|
||||
|
||||
if parameter["cmd"] != _|_ {
|
||||
command: parameter.cmd
|
||||
}
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
||||
selector:
|
||||
matchLabels:
|
||||
"app.oam.dev/component": context.name
|
||||
}
|
||||
}
|
||||
|
||||
parameter: {
|
||||
// +usage=specify app image
|
||||
// +short=i
|
||||
image: string
|
||||
// +usage=specify app image
|
||||
// +short=i
|
||||
image: string
|
||||
|
||||
cmd?: [...string]
|
||||
cmd?: [...string]
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -10,7 +10,7 @@ Learn and use KubeVela with tutorials and user stories.
|
||||
|
||||
**For Developers**
|
||||
- [Setting Up Deployment Environment](developers/config-enviroments.md)
|
||||
- [Deploying Application](developers/deploy-app.md)
|
||||
- [Initializing Application](developers/app-init.md)
|
||||
- [Setting Routes](developers/set-route.md)
|
||||
- [Setting Auto-scaling Policy](developers/set-autoscaling.md)
|
||||
- [Setting Rollout Strategy](developers/set-rollout.md)
|
||||
@@ -19,7 +19,7 @@ Learn and use KubeVela with tutorials and user stories.
|
||||
- [Check Application Logs](developers/check-logs.md)
|
||||
- [Execute Commands in Container](developers/exec-cmd.md)
|
||||
- [Port Forward to Container](developers/port-forward.md)
|
||||
- [Setting Configurations in Application](developers/config-app.md)
|
||||
- [Configuring data/env in Application](developers/config-app.md)
|
||||
- [Consuming Cloud Services](developers/cloud-service.md)
|
||||
|
||||
**For Platform Engineers**
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
# Initializating Application
|
||||
|
||||
## `vela init`
|
||||
|
||||
To initialize and deploy an application with one service, run:
|
||||
|
||||
> If you only want to initialize without deploying the app, add `--render-only` flag
|
||||
|
||||
```console
|
||||
$ vela init
|
||||
Welcome to use KubeVela CLI! We're going to help you run applications through a couple of questions.
|
||||
|
||||
Environment: default, namespace: default
|
||||
|
||||
? Do you want to setup a domain for web service:
|
||||
? Provide an email for production certification:
|
||||
? What would you like to name your application: testapp
|
||||
? Choose workload type for your service: webservice
|
||||
? What would you name this webservice: testsvc
|
||||
? specify app image crccheck/hello-world
|
||||
? specify port for container 8000
|
||||
...
|
||||
✅ Application Deployed Successfully!
|
||||
- Name: testsvc
|
||||
Type: webservice
|
||||
HEALTHY Ready: 1/1
|
||||
Routes:
|
||||
|
||||
Last Deployment:
|
||||
Created at: ...
|
||||
Updated at: ...
|
||||
```
|
||||
|
||||
Check the application:
|
||||
|
||||
```console
|
||||
$ vela show testapp
|
||||
About:
|
||||
|
||||
Name: testapp
|
||||
Created at: ...
|
||||
Updated at: ...
|
||||
|
||||
|
||||
Environment:
|
||||
|
||||
Namespace: default
|
||||
|
||||
Services:
|
||||
|
||||
- Name: testsvc
|
||||
WorkloadType: webservice
|
||||
Arguments:
|
||||
image: crccheck/hello-world
|
||||
port: 8000
|
||||
Traits:
|
||||
```
|
||||
|
||||
## Deploy Multiple Services
|
||||
|
||||
You can also use KubeVela CLI to deploy multiple services for an application.
|
||||
|
||||
Check the available workload types.
|
||||
|
||||
```console
|
||||
$ vela workloads
|
||||
NAME DESCRIPTION
|
||||
worker Backend worker without ports exposed
|
||||
webservice Long running service with network routes
|
||||
```
|
||||
|
||||
Deploy the first service named `frontend` with `Web Service` type:
|
||||
|
||||
```console
|
||||
$ vela svc deploy frontend --app testapp -t webservice --image crccheck/hello-world
|
||||
App testapp deployed
|
||||
```
|
||||
|
||||
> TODO auto generate a random application name, so --app testapp becomes optional
|
||||
|
||||
Deploy the second service named `backend` with "Backend Worker" type:
|
||||
|
||||
```console
|
||||
$ vela svc deploy backend --app testapp2 -t worker --image crccheck/hello-world
|
||||
App testapp2 deployed
|
||||
```
|
||||
|
||||
```console
|
||||
$ vela ls
|
||||
SERVICE APP TYPE TRAITS STATUS CREATED-TIME
|
||||
frontend testapp ...
|
||||
backend testapp ...
|
||||
```
|
||||
@@ -0,0 +1,83 @@
|
||||
# Configuring Data/Env in Application
|
||||
|
||||
`vela` provides a `config` command to manage config data.
|
||||
|
||||
## `vela config set`
|
||||
|
||||
```console
|
||||
$ vela config set test a=b c=d
|
||||
reading existing config data and merging with user input
|
||||
config data saved successfully ✅
|
||||
```
|
||||
|
||||
## `vela config get`
|
||||
|
||||
```console
|
||||
$ vela config get test
|
||||
Data:
|
||||
a: b
|
||||
c: d
|
||||
```
|
||||
|
||||
## `vela config del`
|
||||
|
||||
```console
|
||||
$ vela config del test
|
||||
config (test) deleted successfully
|
||||
```
|
||||
|
||||
## `vela config ls`
|
||||
|
||||
```console
|
||||
$ vela config set test a=b
|
||||
$ vela config set test2 c=d
|
||||
$ vela config ls
|
||||
NAME
|
||||
test
|
||||
test2
|
||||
```
|
||||
|
||||
## Configure env in application
|
||||
|
||||
The config data can be set as the env in applications.
|
||||
|
||||
```console
|
||||
$ vela config set demo DEMO_HELLO=helloworld
|
||||
```
|
||||
|
||||
Save the following to `vela.yaml` in current directory:
|
||||
|
||||
```yaml
|
||||
name: testapp
|
||||
services:
|
||||
env-config-demo:
|
||||
image: heroku/nodejs-hello-world
|
||||
config: demo
|
||||
```
|
||||
|
||||
Then run:
|
||||
```console
|
||||
$ vela up
|
||||
Parsing vela.yaml ...
|
||||
Loading templates ...
|
||||
|
||||
Rendering configs for service (env-config-demo)...
|
||||
writing deploy config to (.vela/deploy.yaml)
|
||||
|
||||
Applying deploy configs ...
|
||||
Checking if app has been deployed...
|
||||
app has not been deployed, creating a new deployment...
|
||||
✅ app has been deployed 🚀🚀🚀
|
||||
Port forward: vela port-forward testapp
|
||||
SSH: vela exec testapp
|
||||
Logging: vela logs testapp
|
||||
App status: vela status testapp
|
||||
Service status: vela status testapp --svc env-config-demo
|
||||
```
|
||||
|
||||
Check env var:
|
||||
|
||||
```
|
||||
$ vela exec testapp -- printenv | grep DEMO_HELLO
|
||||
DEMO_HELLO=helloworld
|
||||
```
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
# 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 show myapp
|
||||
About:
|
||||
|
||||
Name: myapp
|
||||
Created at: 2020-11-02 11:39:04.626416 +0800 CST
|
||||
Updated at: 2020-11-02 11:39:04.627998 +0800 CST
|
||||
|
||||
|
||||
Environment:
|
||||
|
||||
Namespace: default
|
||||
|
||||
Services:
|
||||
|
||||
- Name: frontend
|
||||
WorkloadType: webservice
|
||||
Arguments:
|
||||
port: 8000
|
||||
image: crccheck/hello-world
|
||||
Traits:
|
||||
- route:
|
||||
domain: frontend.example.com
|
||||
issuer: oam-env-default
|
||||
```
|
||||
|
||||
## Deploy Application Step by Step
|
||||
|
||||
You can also use KubeVela CLI to deploy a more complex micro-services application step by step, with 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
|
||||
App myapp deployed
|
||||
```
|
||||
|
||||
> 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 ls
|
||||
SERVICE APP TYPE TRAITS STATUS CREATED-TIME
|
||||
frontend myapp Deployed 2020-11-02 11:39:05 +0800 CST
|
||||
```
|
||||
@@ -0,0 +1,12 @@
|
||||
# Metrics
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Path** | **string** | the metric path of the service | [default to /metrics]
|
||||
**Format** | **string** | +format of the metrics, default as prometheus | [default to prometheus]
|
||||
**Scheme** | **string** | | [default to http]
|
||||
**Enabled** | **bool** | | [default to true]
|
||||
**Port** | **int32** | the port for metrics, will discovery automatically by default | [default to 0], >=1024 & <=65535
|
||||
**Selector** | **map[string]string** | the label selector for the pods, will discovery automatically by default | [optional]
|
||||
@@ -0,0 +1,17 @@
|
||||
# Route
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Domain** | **string** | | [default to ]
|
||||
**Issuer** | **string** | | [default to ]
|
||||
**Rules** | [**[]RouteRules**](routerules.md) | | [optional]
|
||||
|
||||
|
||||
### RouteRules
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Path** | **string** | |
|
||||
**RewriteTarget** | **string** | | [default to ]
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
# Scaler
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Replica** | **int32** | | [default to 1]
|
||||
@@ -0,0 +1,8 @@
|
||||
# Worker
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Cmd** | **[]string** | | [optional]
|
||||
**Image** | **string** | pecify app image |
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
# Task
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Cmd** | **[]string** | | [optional]
|
||||
**Count** | **int32** | specify number of tasks to run in parallel | [default to 1]
|
||||
**Image** | **string** | specify app image |
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
# Webservice
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Cmd** | **[]string** | | [optional]
|
||||
**Env** | [**[]WebserviceEnv**](#webserviceenv) | | [optional]
|
||||
**Image** | **string** | specify app image |
|
||||
**Port** | **int32** | specify port for container | [default to 6379]
|
||||
|
||||
|
||||
### WebserviceEnv
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Name** | **string** | |
|
||||
**Value** | **string** | | [optional]
|
||||
**ValueFrom** | [**WebserviceValueFrom**](#webservicevaluefrom) | | [optional]
|
||||
|
||||
|
||||
### WebserviceValueFrom
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**SecretKeyRef** | [**WebserviceValueFromSecretKeyRef**](#webservicevaluefromsecretkeyref) | |
|
||||
|
||||
### WebserviceValueFromSecretKeyRef
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Name** | **string** | |
|
||||
**Key** | **string** | |
|
||||
@@ -6,7 +6,7 @@ from outside world via `route` feature.
|
||||
```console
|
||||
$ vela svc ls
|
||||
NAME APP WORKLOAD TRAITS STATUS CREATED-TIME
|
||||
frontend myapp webservice Deployed 2020-09-18 22:42:04 +0800 CST
|
||||
frontend testapp webservice Deployed 2020-09-18 22:42:04 +0800 CST
|
||||
```
|
||||
|
||||
## `port-forward`
|
||||
@@ -14,7 +14,7 @@ frontend myapp webservice Deployed 2020-09-18 22:42:04 +0800 CST
|
||||
It will directly open browser for you.
|
||||
|
||||
```console
|
||||
$ vela port-forward myapp
|
||||
$ vela port-forward testapp
|
||||
Forwarding from 127.0.0.1:8080 -> 80
|
||||
Forwarding from [::1]:8080 -> 80
|
||||
|
||||
@@ -32,7 +32,7 @@ Handling connection for 8080
|
||||
You can manually configure it by setting domain parameter.
|
||||
|
||||
```console
|
||||
$ vela route myapp --domain frontend.mycustom.domain
|
||||
$ vela route testapp --domain frontend.mycustom.domain
|
||||
Adding route for app frontend
|
||||
|
||||
Rendering configs for service (frontend)...
|
||||
@@ -56,7 +56,7 @@ $ curl -H "Host:frontend.mycustom.domain" 123.57.10.233
|
||||
### If you have domain set in environment
|
||||
|
||||
```console
|
||||
$ vela route myapp
|
||||
$ vela route testapp
|
||||
Adding route for app frontend
|
||||
|
||||
Rendering configs for service (frontend)...
|
||||
|
||||
+4
-17
@@ -14,7 +14,7 @@ Welcome to use KubeVela CLI! We're going to help you run applications through a
|
||||
|
||||
Environment: default, namespace: default
|
||||
|
||||
? Do you want to setup a domain for web service:
|
||||
? Do you want to setup a domain for web service: example.com
|
||||
? Provide an email for production certification:
|
||||
? What would you like to name your application: testapp
|
||||
? Choose workload type for your service: webservice
|
||||
@@ -34,27 +34,14 @@ updateTime: ...
|
||||
name: testapp
|
||||
services:
|
||||
testsvc:
|
||||
type: webservice
|
||||
image: crccheck/hello-world
|
||||
port: 8000
|
||||
type: webservice
|
||||
```
|
||||
|
||||
## 2. Add Routing Config
|
||||
|
||||
Add routing config under `route`:
|
||||
|
||||
```yaml
|
||||
services:
|
||||
testsvc:
|
||||
...
|
||||
route:
|
||||
domain: testsvc.example.com
|
||||
rules:
|
||||
- path: /testapp
|
||||
rewriteTarget: /
|
||||
```
|
||||
|
||||
## 3. Deploy Application
|
||||
## 2. Deploy Application
|
||||
|
||||
```console
|
||||
$ vela up
|
||||
@@ -102,7 +89,7 @@ Services:
|
||||
> If not in kind cluster, replace localhost with ingress address
|
||||
|
||||
```
|
||||
$ curl -H "Host:testsvc.example.com" http://localhost/testapp
|
||||
$ curl -H "Host:testsvc.example.com" http://localhost/
|
||||
<xmp>
|
||||
Hello World
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ var notExistedEnvMeta = apis.Environment{
|
||||
}
|
||||
|
||||
var webserviceWorkloadType = "webservice"
|
||||
var backendWorkloadType = "backend"
|
||||
var workerWorkloadType = "worker"
|
||||
var taskWorkloadType = "task"
|
||||
|
||||
var _ = ginkgo.Describe("API", func() {
|
||||
@@ -210,7 +210,7 @@ var _ = ginkgo.Describe("API", func() {
|
||||
for _, i := range data {
|
||||
var workloadDefinition = i.(map[string]interface{})
|
||||
gomega.Expect(err).NotTo(gomega.HaveOccurred())
|
||||
gomega.Expect([]string{webserviceWorkloadType, backendWorkloadType, taskWorkloadType}).To(gomega.Or(gomega.ContainElement(workloadDefinition["name"])))
|
||||
gomega.Expect([]string{webserviceWorkloadType, workerWorkloadType, taskWorkloadType}).To(gomega.Or(gomega.ContainElement(workloadDefinition["name"])))
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Executable
+11
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
if ! cue version ; then
|
||||
echo "Installing CUE..."
|
||||
GO111MODULE=off go get -u cuelang.org/go/cmd/cue
|
||||
fi
|
||||
|
||||
echo "Formatting CUE templates..."
|
||||
cue fmt ./hack/vela-templates/cue/*
|
||||
@@ -1,25 +1,25 @@
|
||||
output: {
|
||||
apiVersion: "standard.oam.dev/v1alpha1"
|
||||
kind: "Route"
|
||||
spec: {
|
||||
host: parameter.domain
|
||||
apiVersion: "standard.oam.dev/v1alpha1"
|
||||
kind: "Route"
|
||||
spec: {
|
||||
host: parameter.domain
|
||||
|
||||
if parameter.issuer != "" {
|
||||
tls: {
|
||||
issuerName: parameter.issuer
|
||||
}
|
||||
}
|
||||
if parameter.issuer != "" {
|
||||
tls: {
|
||||
issuerName: parameter.issuer
|
||||
}
|
||||
}
|
||||
|
||||
if parameter["rules"] != _|_ {
|
||||
rules: parameter.rules
|
||||
}
|
||||
}
|
||||
if parameter["rules"] != _|_ {
|
||||
rules: parameter.rules
|
||||
}
|
||||
}
|
||||
}
|
||||
parameter: {
|
||||
domain: *"" | string
|
||||
issuer: *"" | string
|
||||
rules?: [...{
|
||||
path: string
|
||||
rewriteTarget: *"" | string
|
||||
}]
|
||||
domain: *"" | string
|
||||
issuer: *"" | string
|
||||
rules?: [...{
|
||||
path: string
|
||||
rewriteTarget: *"" | string
|
||||
}]
|
||||
}
|
||||
|
||||
@@ -1,31 +1,30 @@
|
||||
output: {
|
||||
apiVersion: "v1"
|
||||
kind: "Job"
|
||||
metadata: name: context.name
|
||||
spec: {
|
||||
parallelism: parameter.count
|
||||
completions: parameter.count
|
||||
template: spec: {
|
||||
containers: [{
|
||||
name: context.name
|
||||
image: parameter.image
|
||||
apiVersion: "v1"
|
||||
kind: "Job"
|
||||
metadata: name: context.name
|
||||
spec: {
|
||||
parallelism: parameter.count
|
||||
completions: parameter.count
|
||||
template: spec: {
|
||||
containers: [{
|
||||
name: context.name
|
||||
image: parameter.image
|
||||
|
||||
if parameter["cmd"] != _|_ {
|
||||
command: parameter.cmd
|
||||
}
|
||||
command:
|
||||
}]
|
||||
}
|
||||
}
|
||||
if parameter["cmd"] != _|_ {
|
||||
command: parameter.cmd
|
||||
}
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
parameter: {
|
||||
// +usage=specify number of tasks to run in parallel
|
||||
// +short=c
|
||||
count: *1 | int
|
||||
// +usage=specify number of tasks to run in parallel
|
||||
// +short=c
|
||||
count: *1 | int
|
||||
|
||||
// +usage=specify app image
|
||||
// +short=i
|
||||
image: string
|
||||
// +usage=specify app image
|
||||
// +short=i
|
||||
image: string
|
||||
|
||||
cmd?: [...string]
|
||||
cmd?: [...string]
|
||||
}
|
||||
|
||||
@@ -1,68 +1,68 @@
|
||||
output: {
|
||||
apiVersion: "apps/v1"
|
||||
kind: "Deployment"
|
||||
metadata: name: context.name
|
||||
spec: {
|
||||
replicas: 1
|
||||
apiVersion: "apps/v1"
|
||||
kind: "Deployment"
|
||||
metadata: name: context.name
|
||||
spec: {
|
||||
replicas: 1
|
||||
|
||||
selector: matchLabels: {
|
||||
"app.oam.dev/component": context.name
|
||||
}
|
||||
selector: matchLabels: {
|
||||
"app.oam.dev/component": context.name
|
||||
}
|
||||
|
||||
template: {
|
||||
metadata: labels: {
|
||||
"app.oam.dev/component": context.name
|
||||
}
|
||||
template: {
|
||||
metadata: labels: {
|
||||
"app.oam.dev/component": context.name
|
||||
}
|
||||
|
||||
spec: {
|
||||
containers: [{
|
||||
name: context.name
|
||||
image: parameter.image
|
||||
spec: {
|
||||
containers: [{
|
||||
name: context.name
|
||||
image: parameter.image
|
||||
|
||||
if parameter["cmd"] != _|_ {
|
||||
command: parameter.cmd
|
||||
}
|
||||
if parameter["cmd"] != _|_ {
|
||||
command: parameter.cmd
|
||||
}
|
||||
|
||||
if parameter["env"] != _|_ {
|
||||
env: parameter.env
|
||||
}
|
||||
|
||||
if context["config"] != _|_ {
|
||||
env: [
|
||||
for k, v in context.config {
|
||||
name: k
|
||||
value: v
|
||||
}
|
||||
]
|
||||
}
|
||||
if parameter["env"] != _|_ {
|
||||
env: parameter.env
|
||||
}
|
||||
|
||||
ports: [{
|
||||
containerPort: parameter.port
|
||||
}]
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
if context["config"] != _|_ {
|
||||
env: [
|
||||
for k, v in context.config {
|
||||
name: k
|
||||
value: v
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
ports: [{
|
||||
containerPort: parameter.port
|
||||
}]
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
parameter: {
|
||||
// +usage=specify app image
|
||||
// +short=i
|
||||
image: string
|
||||
// +usage=specify app image
|
||||
// +short=i
|
||||
image: string
|
||||
|
||||
cmd?: [...string]
|
||||
cmd?: [...string]
|
||||
|
||||
// +usage=specify port for container
|
||||
// +short=p
|
||||
port: *6379 | int
|
||||
// +usage=specify port for container
|
||||
// +short=p
|
||||
port: *6379 | int
|
||||
|
||||
env?: [...{
|
||||
name: string
|
||||
value?: string
|
||||
valueFrom?: {
|
||||
secretKeyRef: {
|
||||
name: string
|
||||
key: string
|
||||
}
|
||||
}
|
||||
}]
|
||||
env?: [...{
|
||||
name: string
|
||||
value?: string
|
||||
valueFrom?: {
|
||||
secretKeyRef: {
|
||||
name: string
|
||||
key: string
|
||||
}
|
||||
}
|
||||
}]
|
||||
}
|
||||
|
||||
@@ -1,42 +1,42 @@
|
||||
output: {
|
||||
apiVersion: "apps/v1"
|
||||
kind: "Deployment"
|
||||
metadata:
|
||||
name: context.name
|
||||
spec: {
|
||||
replicas: 1
|
||||
|
||||
selector: matchLabels: {
|
||||
"app.oam.dev/component": context.name
|
||||
}
|
||||
apiVersion: "apps/v1"
|
||||
kind: "Deployment"
|
||||
metadata:
|
||||
name: context.name
|
||||
spec: {
|
||||
replicas: 1
|
||||
|
||||
template: {
|
||||
metadata: labels: {
|
||||
"app.oam.dev/component": context.name
|
||||
}
|
||||
|
||||
spec: {
|
||||
containers: [{
|
||||
name: context.name
|
||||
image: parameter.image
|
||||
selector: matchLabels: {
|
||||
"app.oam.dev/component": context.name
|
||||
}
|
||||
|
||||
if parameter["cmd"] != _|_ {
|
||||
command: parameter.cmd
|
||||
}
|
||||
}]
|
||||
}
|
||||
}
|
||||
template: {
|
||||
metadata: labels: {
|
||||
"app.oam.dev/component": context.name
|
||||
}
|
||||
|
||||
selector:
|
||||
matchLabels:
|
||||
"app.oam.dev/component": context.name
|
||||
}
|
||||
spec: {
|
||||
containers: [{
|
||||
name: context.name
|
||||
image: parameter.image
|
||||
|
||||
if parameter["cmd"] != _|_ {
|
||||
command: parameter.cmd
|
||||
}
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
||||
selector:
|
||||
matchLabels:
|
||||
"app.oam.dev/component": context.name
|
||||
}
|
||||
}
|
||||
|
||||
parameter: {
|
||||
// +usage=specify app image
|
||||
// +short=i
|
||||
image: string
|
||||
// +usage=specify app image
|
||||
// +short=i
|
||||
image: string
|
||||
|
||||
cmd?: [...string]
|
||||
cmd?: [...string]
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
apiVersion: core.oam.dev/v1alpha2
|
||||
kind: WorkloadDefinition
|
||||
metadata:
|
||||
name: backend
|
||||
name: worker
|
||||
annotations:
|
||||
definition.oam.dev/apiVersion: "apps/v1"
|
||||
definition.oam.dev/kind: "Deployment"
|
||||
|
||||
Reference in New Issue
Block a user