---
# System prepended metadata

title: app platform

---

# app platform

YAML sample:

```yaml
build:
  artifacts:
  - image: acr.io/k8s-app/example
    docker:
      ...
    buildpacks:
      ...
      
deploy: # render k4apps workload and apply it to target env directly
  type: web-service
  name: front-api
  configurations: # application configuration
    cpu: CPU
    min-scale: MIN
    max-scale: MAX
    concurrency-target: MAX-REQUESTS
    
release:
  traffic:  # only works for web-service
    - revision: v2
      weight: 50
    - revision: v1
      weight: 50
```

```yaml

# start from source code repo
$ git clone https://github.com/myapp/example

# initialize environment, addons, generate initial manifest
$ k4a init
# ... interactive shell

$ k4a build

build:
  artifacts:
  - image: acr.io/k8s-app/example
    docker:
      ...
    buildpacks:
      ...

$ k4a deploy

# default: direct apply

deploy: # render k4apps workload and apply it to target env directly
  type: web-service
  name: front-api
  configurations: # application configuration
    cpu: CPU
    min-scale: MIN
    max-scale: MAX
    concurrency-target: MAX-REQUESTS
    
# advanced: deploy with package

#   type: package
#     format: kustomize
#     configurations:
#       manifests:
#       - deploy/k8s-*

#     format: helm
#     configurations:
#       chart: ./helm
#       url: chart://...
#       values: ...

# optional: deploy via GitOps

#   gitops:
#     addon: argocd # works for both helm or kustomize pkg, kustomize as default
#     configurations:
#       configRepo: url://...
#       imageUpdatePolicy: ...



$ k4a release # $ k4a rollout?

release:
  traffic:  # only works for web-service
    - revision: v2
      weight: 50
    - revision: v1
      weight: 50
      
  # canary:
  #   - step: 1
  #     interval: 2
  #     ...

# discussion

$ k4a ls build | deploy | release 
$ k4a rollback #?

# miscellaneous parts from core workflow

$ k4a secret
$ k4a config
$ k4a storage

```
CI/CD example:

```yaml
# GitHub Actions
steps:
  - uses: actions/checkout@v2
  - uses: k4apps
    with:
      version: '0.1.0'
- run: k4a init --name=test ... # init target environments
- run: k4a build
- run: k4a deploy
- run: k4a release --traffic 50 --revision v2 
```

