在 Kong Gateway DB-less 模式設定 Service 與 Route
Service 定義 upstream 連線,Route 將符合條件的要求送往 Service。DB-less 模式以單一宣告式 YAML/JSON 檔描述完整 entity 狀態,載入時會整體取代。範例使用 path HTTP Route 與 v3 格式。目前文件指出 v3.14 起 Route 預設只接受 HTTPS,因此明確列出 HTTP 與 HTTPS。資料庫模式、Kubernetes Ingress Controller、Konnect 和認證 plugin 不在範圍內。
Service 定義 upstream 連線,Route 將符合條件的要求送往 Service。DB-less 模式以單一宣告式 YAML/JSON 檔描述完整 entity 狀態,載入時會整體取代。範例使用 path HTTP Route 與 v3 格式。目前文件指出 v3.14 起 Route 預設只接受 HTTPS,因此明確列出 HTTP 與 HTTPS。資料庫模式、Kubernetes Ingress Controller、Konnect 和認證 plugin 不在範圍內。
DB-less entity 存在記憶體。節點沒有中央資料庫協調,因此每個節點都要取得預期設定;entity 必須放得進 cache,plugin 相容性也不同。範例將 /orders 對應到 orders_api,strip_path=true 會移除符合的 prefix,因此 /orders/42 會以 /42 抵達 upstream。使用 Gateway 可連線的 upstream。
設定與檢查
_format_version: "3.0"
services:
- name: orders_api
url: http://orders.internal.example:8080
routes:
- name: orders_path
service:
name: orders_api
paths:
- /orders
protocols:
- http
- https
strip_path: truekong config parse kong.yml 只檢查語法,不會載入檔案,也不會證明 DNS、連線或執行期行為。設定 database=off 與指向完整檔案的 declarative_config,或使用 KONG_DATABASE、KONG_DECLARATIVE_CONFIG。套用前檢查整份檔案,保留最後一份完整可用設定,並套用至每個獨立節點。對真實 proxy listener 發送要求並查看記錄。限制 Admin API,勿公開管理連接埠。
限制
文件範例未執行。宣告 HTTPS 不會設定 TLS 或憑證。請核對安裝版本。
[DB-less](https://developer.konghq.com/gateway/db-less-mode/)
[Gateway Services](https://developer.konghq.com/gateway/entities/service/)
[Routes](https://developer.konghq.com/gateway/entities/route/)
[CLI](https://developer.konghq.com/gateway/cli/reference/)
[設定管理](https://developer.konghq.com/gateway/manage-kong-conf/)