# Using Appfile for More Flexible Configuration Appfile supports more flexible options than CLI/UI to configure appliation deployment on Vela. A detailed design doc could be found [here](../../design/appfile-design.md) In this tutorial, we will build and deploy an example NodeJS app under [examples/testapp/](https://github.com/oam-dev/kubevela/tree/master/examples/testapp). ## Prerequisites - [docker](https://docs.docker.com/get-docker/) installed on the host - [vela](../../install.md) installed and configured ## 1. Download test app code git clone and go to the testapp directory: ```console $ git clone https://github.com/oam-dev/kubevela.git $ cd kubevela/examples/testapp ``` The example contains NodeJS app code, Dockerfile to build the app. ## 2. Deploy app in one command In the directory there is a [vela.yaml](../../../examples/testapp/vela.yaml) which follows Appfile format supported by Vela. We are going to use it to build and deploy the app. ATTENTION: change the image field in vela.yaml to something you can push to on your host: > Or you may try the local kind cluster option which will be introduced in the following section. ```yaml image: oamdev/testapp:v1 ``` Run the following command: ```console $ vela up Parsing vela.yaml ... Loading templates ... Building service (express-server)... Sending build context to Docker daemon 71.68kB Step 1/10 : FROM mhart/alpine-node:12 ---> 9d88359808c3 ... pushing image (oamdev/testapp:v1)... ... Rendering configs for service (express-server)... 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 ``` Now the app deployment has been rendered and run. Check the status of the application deployment: ```console $ vela svc status express-server [0:06:32] Showing status of service(type: webservice) express-server deployed in Environment default Service express-server Status: HEALTHY Ready: 1/1 scaler: replica=1 scaler: replica=1 Last Deployment: Created at: 2020-10-30 00:06:10 -0700 PDT Updated at: 2020-10-30T00:06:10-07:00 ``` ## 3. Check rendered manifests By default, Vela renders the final manifests in `.vela/deploy.yaml`: ```yaml apiVersion: core.oam.dev/v1alpha2 kind: ApplicationConfiguration metadata: name: testapp namespace: default spec: components: - componentName: express-server traits: - trait: apiVersion: core.oam.dev/v1alpha2 kind: ManualScalerTrait ... - trait: apiVersion: standard.oam.dev/v1alpha1 kind: Route ... --- apiVersion: core.oam.dev/v1alpha2 kind: Component metadata: name: express-server namespace: default spec: workload: apiVersion: apps/v1 kind: Deployment metadata: name: express-server ... --- apiVersion: core.oam.dev/v1alpha2 kind: HealthScope metadata: name: testapp-default-health namespace: default spec: ... ``` ## [Optional] Configure "task" workload type In above we deploy *webservice* workload. We can also deploy *task* workload via appfile. Below is a simplified example from k8s doc: ```yaml services: pi: image: perl cmd: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"] ``` ## [Optional] Local kind cluster testing without pushing image remotely If you have local kind cluster running: ```console $ kind get clusters kind ``` Add local option to `build`: ```yaml build: # push image into local kind cluster without remote transfer push: local: kind docker: file: Dockerfile context: . ``` Then deploy the app to kind: ```console $ vela up ``` [kind](https://kind.sigs.k8s.io/)