fix quick start guide as we don't have route trait installed as default (#954)

* fix quick start guide as we don't have route trait installed as default

* add a description for ingress trait
This commit is contained in:
Jianbo Sun
2021-01-29 14:56:38 +08:00
committed by GitHub
parent f39660c286
commit 66fb99954e
9 changed files with 127 additions and 64 deletions
@@ -0,0 +1,60 @@
# Code generated by KubeVela templates. DO NOT EDIT.
apiVersion: core.oam.dev/v1alpha2
kind: TraitDefinition
metadata:
annotations:
definition.oam.dev/description: "Configures K8s ingress and service to enable web traffic for your service.
Please use route trait in cap center for advanced usage."
name: ingress
spec:
appliesToWorkloads:
- webservice
- worker
extension:
template: |
parameter: {
domain: string
http: [string]: int
}
// trait template can have multiple outputs in one trait
outputs: service: {
apiVersion: "v1"
kind: "Service"
metadata:
name: context.name
spec: {
selector:
"app.oam.dev/component": context.name
ports: [
for k, v in parameter.http {
port: v
targetPort: v
},
]
}
}
outputs: ingress: {
apiVersion: "networking.k8s.io/v1beta1"
kind: "Ingress"
metadata:
name: context.name
spec: {
rules: [{
host: parameter.domain
http: {
paths: [
for k, v in parameter.http {
path: k
backend: {
serviceName: context.name
servicePort: v
}
},
]
}
}]
}
}
@@ -34,10 +34,6 @@ spec:
}]
}
}
selector:
matchLabels:
"app.oam.dev/component": context.name
}
}
+2 -2
View File
@@ -103,13 +103,13 @@ services:
type: webservice
image: oamdev/testapp:v1
route:
ingress:
domain: example.com
http: # match the longest prefix
"/": 8080
```
This `appfile` is composed of a `frontend` component including workload type of `Web Service` and a `route` trait. Developer fills in the values based on the independent schema documentations for such workload type and trait. KubeVela will check the corresponding definition objects in OAM Kubernetes runtime to validate and generate the final Kubernetes resources. This is how we make the user interface of KubeVela highly extensible.
This `appfile` is composed of a `frontend` component including workload type of `Web Service` and a `ingress` trait. Developer fills in the values based on the independent schema documentations for such workload type and trait. KubeVela will check the corresponding definition objects in OAM Kubernetes runtime to validate and generate the final Kubernetes resources. This is how we make the user interface of KubeVela highly extensible.
In order to make building such high level abstractions easier, we adopted [CUElang](https://github.com/cuelang/cue) in the OAM Kubernetes runtime for creating the "last mile" abstractions (i.e., eliminating non user facing fields or merging multiple objects into one). All the abstractions in `appfile` are essentially defined by the CUE templates saved in the OAM Control Plane Objects. The platform builders can modify those templates at any time. The updates will take effect immediately in the schema of the `appfile`.
+3 -2
View File
@@ -45,8 +45,9 @@ Services:
Last Deployment:
Created at: ...
Updated at: ...
Routes:
- route: Visiting URL: http://testsvc.example.com IP: localhost
Traits:
- ✅ ingress: domain=testsvc.example.com
http=map[/:8000]
```
**In [kind cluster setup](./install.md#kind)**, you can visit the service via localhost. In other setups, replace localhost with ingress address accordingly.
-50
View File
@@ -1,50 +0,0 @@
apiVersion: core.oam.dev/v1alpha2
kind: TraitDefinition
metadata:
name: ingress
spec:
extension:
template: |
parameter: {
domain: string
http: [string]: int
}
// trait template can have multiple outputs in one trait
outputs: service: {
apiVersion: "v1"
kind: "Service"
spec: {
selector:
app: context.name
ports: [
for k, v in parameter.http {
port: v
targetPort: v
}
]
}
}
outputs: ingress: {
apiVersion: "networking.k8s.io/v1beta1"
kind: "Ingress"
metadata:
name: context.name
spec: {
rules: [{
host: parameter.domain
http: {
paths: [
for k, v in parameter.http {
path: k
backend: {
serviceName: context.name
servicePort: v
}
}
]
}
}]
}
}
+4 -2
View File
@@ -4,5 +4,7 @@ services:
type: webservice
image: crccheck/hello-world
port: 8000
route:
domain: testsvc.example.com
ingress:
domain: testsvc.example.com
http:
"/": 8000
+45
View File
@@ -0,0 +1,45 @@
parameter: {
domain: string
http: [string]: int
}
// trait template can have multiple outputs in one trait
outputs: service: {
apiVersion: "v1"
kind: "Service"
metadata:
name: context.name
spec: {
selector:
"app.oam.dev/component": context.name
ports: [
for k, v in parameter.http {
port: v
targetPort: v
},
]
}
}
outputs: ingress: {
apiVersion: "networking.k8s.io/v1beta1"
kind: "Ingress"
metadata:
name: context.name
spec: {
rules: [{
host: parameter.domain
http: {
paths: [
for k, v in parameter.http {
path: k
backend: {
serviceName: context.name
servicePort: v
}
},
]
}
}]
}
}
-4
View File
@@ -22,10 +22,6 @@ output: {
}]
}
}
selector:
matchLabels:
"app.oam.dev/component": context.name
}
}
@@ -0,0 +1,13 @@
apiVersion: core.oam.dev/v1alpha2
kind: TraitDefinition
metadata:
annotations:
definition.oam.dev/description: "Configures K8s ingress and service to enable web traffic for your service.
Please use route trait in cap center for advanced usage."
name: ingress
spec:
appliesToWorkloads:
- webservice
- worker
extension:
template: |