# Application Example In this Demo, Application application-sample will be converted to appcontext and component The fields in the application spec come from the parametes defined in the definition template , so we must install Definition at first Step 1: Install ComponentDefinition & Trait Definition ``` kubectl apply -f template.yaml ``` Step 2: Create a sample application in the cluster ``` kubectl apply -f application-sample.yaml ``` Step 3: View the application status ``` kubectl get -f application-sample.yaml -oyaml // You can see the following apiVersion: core.oam.dev/v1beta1 kind: Application metadata: annotations: kubectl.kubernetes.io/last-applied-configuration: | {"apiVersion":"core.oam.dev/v1beta1","kind":"Application","metadata":{"annotations":{},"name":"application-sample","namespace":"default"},"spec":{"components":[{"name":"myweb","properties":{"cmd":["sleep","1000"],"image":"busybox"},"traits":[{"properties":{"replicas":10},"type":"scaler"},{"properties":{"image":"nginx","name":"sidecar-test"},"type":"sidecar"},{"properties":{"http":{"server":80}},"type":"kservice"}],"type":"worker"}]}} ... spec: components: - name: myweb properties: cmd: - sleep - "1000" image: busybox traits: - properties: replicas: 10 type: scaler - properties: image: nginx name: sidecar-test type: sidecar - properties: http: server: 80 type: kservice type: worker status: batchRollingState: "" components: - apiVersion: core.oam.dev/v1alpha2 kind: Component name: myweb conditions: - reason: Available status: "True" type: Parsed - reason: Available status: "True" type: Built - reason: Available status: "True" type: Applied status: running ... ``` Step 4: View the oam CR generated by application ``` kubectl get appcontext/application-sample -oyaml // appconfig is as follows apiVersion: core.oam.dev/v1alpha2 kind: ApplicationContext metadata: annotations: kubectl.kubernetes.io/last-applied-configuration: | {"apiVersion":"core.oam.dev/v1beta1","kind":"Application","metadata":{"annotations":{},"name":"application-sample","namespace":"default"},"spec":{"components":[{"name":"myweb","properties":{"cmd":["sleep","1000"],"image":"busybox"},"traits":[{"properties":{"replicas":10},"type":"scaler"},{"properties":{"image":"nginx","name":"sidecar-test"},"type":"sidecar"},{"properties":{"http":{"server":80}},"type":"kservice"}],"type":"worker"}]}} generation: 1 labels: app.oam.dev/app-revision-hash: 99749f6e7a78024b name: application-sample namespace: default ownerReferences: - apiVersion: core.oam.dev/v1beta1 controller: true kind: Application name: application-sample ... spec: applicationRevisionName: application-sample-v1 status: conditions: - reason: ReconcileSuccess status: "True" type: Synced dependency: {} observedGeneration: 0 workloads: - appliedComponentRevision: myweb-v1 componentName: myweb componentRevisionName: myweb-v1 traits: - traitRef: apiVersion: v1 kind: Service name: myweb workloadRef: apiVersion: apps/v1 kind: Deployment name: myweb-v1 kubectl get component/myweb -oyaml // component is as follows apiVersion: core.oam.dev/v1alpha2 kind: Component metadata: generation: 1 labels: app.oam.dev/name: application-sample name: myweb namespace: default ownerReferences: - apiVersion: core.oam.dev/v1beta1 controller: true kind: Application name: application-sample ... spec: workload: apiVersion: apps/v1 kind: Deployment metadata: labels: app.oam.dev/component: myweb app.oam.dev/name: application-sample workload.oam.dev/type: worker spec: replicas: 10 selector: matchLabels: app.oam.dev/component: myweb template: metadata: labels: app: myweb app.oam.dev/component: myweb spec: containers: - command: - sleep - "1000" image: busybox name: myweb - image: nginx name: sidecar-test status: latestRevision: name: myweb-v1 revision: 1 observedGeneration: 1 ```