應用程式資訊清單可讓開發人員以宣告式方式記錄應用程式的執行環境。可讓應用程式以一致且可重現的方式部署。
格式
資訊清單是應用程式根目錄中的 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 |
應用程式應取得的磁碟空間量。預設值為 1 GiB。 |
memory |
quantity |
提供給應用程式的 RAM 容量。預設為 1 GiB。 |
cpu † |
quantity |
提供給應用程式的 CPU 量。預設值為 0.1 (1/10 個 CPU)。 |
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。 |
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 |
範例
最小應用程式
這是一個簡單的資訊清單,會根據上傳的來源自動偵測建構包,並部署一個建構包例項,藉此建構應用程式。
---
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
(預設)http
process
(或是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 容器的連接埠。