应用清单提供了一种供开发者以声明方式记录应用执行环境的方式。它们允许应用以一致的方式重复部署。
格式
清单是应用的根目录中的 YAML 文件。它们必须命名为 manifest.yml 或 manifest.yaml。
Kf 应用清单可以有一个顶级元素:applications。applications 元素可以包含一个或多个应用条目。
应用字段
以下字段对 applications 下的对象有效:
| 字段 | 类型 | 说明 | 
|---|---|---|
name | 
string | 
应用名称。应用名称应为小写字母数字字符和短划线。不能以短划线开头。 | 
path | 
string | 
应用来源的路径。默认为清单的目录。 | 
buildpacks | 
string[] | 
要应用到应用的 buildpack 列表。 | 
stack | 
string | 
用于使用 buildpack 创建的应用的基础映像。 | 
docker | 
object | 
Docker 对象。如需了解详情,请参阅“Docker 字段”部分。 | 
env | 
map | 
键/值对,用作应用和构建的环境变量。 | 
services | 
string[] | 
要自动绑定到应用的服务实例名称的列表。 | 
disk_quota | 
quantity | 
应用应获取的磁盘数量。默认为 1GiB。 | 
memory | 
quantity | 
为应用提供的 RAM 容量。默认为 1GiB。 | 
cpu † | 
quantity | 
为应用提供的 CPU 容量。默认为 0.1(CPU 的 1/10)。 | 
instances | 
int | 
要运行的应用实例数。默认为 1。 | 
routes | 
object | 
应用应侦听的路由列表。如需了解详情,请参阅“路由字段”部分。 | 
no-route | 
boolean | 
如果设置为 true,则应用无法路由。 | 
random-route | 
boolean | 
如果设置为 true,则应用将获得随机路由。 | 
timeout | 
int | 
等待应用运行状况良好的秒数。 | 
health-check-type | 
string | 
使用 port、process、none 或 http 的健康检查类型。默认值:port | 
health-check-http-endpoint | 
string | 
要作为健康检查的一部分进行定位的端点。仅在 health-check-type 为 http 时有效。 | 
command | 
string | 
启动应用的命令。如果提供,则将其传递到容器入口点。 | 
entrypoint † | 
string | 
替换应用容器的入口点。 | 
args † | 
string[] | 
替换应用容器的参数。 | 
ports † | 
object | 
要在容器上公开的端口列表。如果已提供,则此列表中的第一个条目将用作默认端口。 | 
† 特定于 Kf
Docker 字段
以下字段对 application.docker 对象有效:
| 字段 | 类型 | 说明 | 
|---|---|---|
image | 
string | 
要使用的 Docker 映像。 | 
路由字段
以下字段对 application.routes 对象有效:
| 字段 | 类型 | 说明 | 
|---|---|---|
route | 
string | 
指向应用的路由,包括主机名、网域和路径。 | 
appPort | 
int | 
(可选)路由会将流量发送到的应用的自定义端口。 | 
端口字段
以下字段对 application.ports 对象有效:
| 字段 | 类型 | 说明 | 
|---|---|---|
port | 
int | 
要在应用容器中公开的端口。 | 
protocol | 
string | 
要公开的端口的协议。必须为 tcp、http 或 http2。默认:tcp | 
示例
最小应用
这是一个简明清单,它将通过基于上传来源自动检测 buildpack 并部署其实例。
---
applications:
- name: my-minimal-application
简单应用
这是更传统的 Java 应用的完整清单。
---
applications:
- name: account-manager
  # only upload src/ on push
  path: src
  # use the Java buildpack
  buildpacks:
  - java
  env:
    # manually configure the buildpack's Java version
    BP_JAVA_VERSION: 8
    ENVIRONMENT: PRODUCTION
  # use less disk and memory than default
  disk_quota: 512M
  memory: 512M
  # bump up the CPU
  cpu: 0.2
  instances: 3
  # make the app listen on three routes
  routes:
  - route: accounts.mycompany.com
  - route: accounts.datacenter.mycompany.internal
  - route: mycompany.com/accounts
  # set up a longer timeout and custom endpoint to validate
  # when the app comes up
  timeout: 300
  health-check-type: http
  health-check-http-endpoint: /healthz
  # attach two services by name
  services:
  - customer-database
  - web-cache
Docker 应用
Kf 可以部署 Docker 容器以及列出已部署应用的清单。这些 Docker 应用必须侦听 PORT 环境变量。
---
applications:
- name: white-label-app
  # use a pre-built docker image (must listen on $PORT)
  docker:
    image: gcr.io/my-company/white-label-app:123
  env:
    # add additional environment variables
    ENVIRONMENT: PRODUCTION
  disk_quota: 1G
  memory: 1G
  cpu: 2
  instances: 1
  routes:
  - route: white-label-app.mycompany.com
具有多个端口的应用
此应用有多个端口可用于公开管理控制台、网站和 SMTP 服务器。
---
applications:
- name: b2b-server
  ports:
  - port: 8080
    protocol: http
  - port: 9090
    protocol: http
  - port: 2525
    protocol: tcp
  routes:
  - route: b2b-admin.mycompany.com
    appPort: 9090
  - route: b2b.mycompany.com
    # gets the default (first) port
健康检查类型
Kf 支持三种不同的健康检查类型:
port(默认)httpprocess(或none)
port 和 http 设置 Kubernetes 就绪性和活动性探测,以确保应用在向其发送流量之前已准备就绪。
port 健康检查将确保位于 $PORT 的端口正在被侦听。在后台,Kf 使用 TCP 探测。
http 健康检查将使用 health-check-http-endpoint 中配置的值来检查应用的健康状况。在后台,Kf 使用 HTTP 探测。
process 健康检查仅检查容器上运行的进程是否处于活动状态。它不会设置 Kubernetes 就绪性或活动性探测。
已知差异
以下是 Kf 清单和 CF 清单之间的已知差异:
- Kf 不支持已弃用的 CF 清单字段。这包括清单的根级(应用除外)的所有字段和路由字段。
 - Kf 不支持以下 v2 清单字段:
docker.username
 - Kf 不支持自动检测 Docker 容器的端口。