From eb4efc960fa995811c3a291ab759cc477bebc715 Mon Sep 17 00:00:00 2001 From: wyike <77846369+wangyikewxgm@users.noreply.github.com> Date: Mon, 29 Mar 2021 23:25:43 +0800 Subject: [PATCH] add demo for app doc (#1349) * add demo for app doc * Update docs/en/application.md Co-authored-by: Jianbo Sun --- docs/en/application.md | 68 ++++++++++++++++++++++++++++- docs/examples/registry/sidecar.yaml | 22 ++++++++++ 2 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 docs/examples/registry/sidecar.yaml diff --git a/docs/en/application.md b/docs/en/application.md index b71a4511a..71c0f85d1 100644 --- a/docs/en/application.md +++ b/docs/en/application.md @@ -136,6 +136,31 @@ spec: cpuUtil: *50 | int } ``` +The application also have a sidecar trait. +```yaml +apiVersion: core.oam.dev/v1beta1 +kind: TraitDefinition +metadata: + annotations: + definition.oam.dev/description: "add sidecar to the app" + name: sidecar +spec: + appliesToWorkloads: + - webservice + - worker + schematic: + cue: + template: |- + patch: { + // +patchKey=name + spec: template: spec: containers: [parameter] + } + parameter: { + name: string + image: string + command?: [...string] + } +``` All the definition objects are expected to be defined and installed by platform team. The end users will only focus on `Application` resource. @@ -153,4 +178,45 @@ After the `Application` resource is applied to Kubernetes cluster, the KubeVela |`trait.oam.dev/resource=` | The name of trait resource instance | |`app.oam.dev/appRevision=` | The name of the application revision it belongs to | -> TBD: a demo for kubectl apply above Application CR and show full detailed underlying resources. +## Run Application + + +Apply application yaml above, then you'll get the application started +```shell +$ kubectl get application -o yaml +apiVersion: core.oam.dev/v1beta1 +kind: Application +metadata: + name: website +.... +status: + components: + - apiVersion: core.oam.dev/v1alpha2 + kind: Component + name: backend + - apiVersion: core.oam.dev/v1alpha2 + kind: Component + name: frontend +.... + status: running + +``` + +Check the status of frontend workload. The fluentd container has been injected into the pod +```shell +$ kubectl get deploy frontend +NAME READY UP-TO-DATE AVAILABLE AGE +frontend 1/1 1 1 100m +``` +Check the status of backend workload +```shell +$ kubectl get deploy backend +NAME READY UP-TO-DATE AVAILABLE AGE +backend 1/1 1 1 100m +``` +Check the status of HPA +```shell +$ kubectl get HorizontalPodAutoscaler frontend +NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE +frontend Deployment/frontend /50% 1 10 1 101m +``` diff --git a/docs/examples/registry/sidecar.yaml b/docs/examples/registry/sidecar.yaml new file mode 100644 index 000000000..750ae1721 --- /dev/null +++ b/docs/examples/registry/sidecar.yaml @@ -0,0 +1,22 @@ +apiVersion: core.oam.dev/v1beta1 +kind: TraitDefinition +metadata: + annotations: + definition.oam.dev/description: "add sidecar to the app" + name: sidecar +spec: + appliesToWorkloads: + - webservice + - worker + schematic: + cue: + template: |- + patch: { + // +patchKey=name + spec: template: spec: containers: [parameter] + } + parameter: { + name: string + image: string + command?: [...string] + } \ No newline at end of file