Files
kubevela/docs/developers/devex/appfile.md
Hongchao Deng 8fdf48eac1 Add appfile tutorial and fix code
includes:
- fix up command to save appfile to env dir
- update cue template to include cmd and config
- move design to doc/design
2020-10-29 22:41:07 -07:00

2.2 KiB

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

In this tutorial, we will build and deploy an example NodeJS app under examples/testapp/.

Prerequisites

1. Download test app code

git clone and go to the testapp directory:

$ 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

vela.yaml is an appfile format supported by Vela.

You need to change this line to the image that you can push to on your host:

Or you may try the local kind cluster option which will be introduced in the following section.

    image: oamdev/testapp:v1

Deploy vela.yaml:

$ vela up

Now the app has been rendered and deployed.

3. Check rendered manifests and deployment

By default, Vela renders the final manifests in .vela/deploy.yaml:

$ cat .vela/deploy.yaml

Check the status of the application deployment:

$ vela app status testapp

$ vela svc status express-server

[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:

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:

$ kind get clusters
kind

Add local option to build:

    build:
      # push image into local kind cluster without remote transfer
      push:
        local: kind

      docker:
        file: Dockerfile
        context: .

Then deploy the app to kind:

$ vela up

kind