如何設定邊緣

私有雲 v4.18.01 的邊緣

如要在安裝後設定 Edge,請合併使用 .properties 檔案和 Edge 公用程式的組合。舉例來說,如要在 Edge UI 上設定 TLS/SSL,您可以編輯 .properties 檔案來設定必要屬性。變更 .properties 檔案時,必須重新啟動受影響的 Edge 元件。

Apigee 是指以「透過設定編寫程式碼」的形式編輯 .properties 檔案的技術。基本上,具有設定的程式碼是一種鍵/值查詢工具,以 .properties 檔案中的設定為依據。在具有設定的程式碼中,金鑰稱為「權杖」。因此,如要設定 Edge,您需要在 .properties 檔案中設定權杖。

具有設定的程式碼可讓 Edge 元件設定與產品一併傳送的預設值,讓安裝團隊依據安裝拓撲覆寫這些設定,然後讓客戶覆寫他們選擇的任何屬性。

若要將此設定視為階層,則設定的順序如下:客戶設定的優先順序最高,以覆寫安裝者團隊或 Apigee 的任何設定:

  1. 客戶
  2. 安裝程式
  3. Apigee

如何使用 .properties 檔案

客戶只能修改 /opt/apigee/customer/application 目錄中的 .properties 檔案。每個元件在該目錄中都有自己的 .properties 檔案。例如 router.propertiesmanagement-server.properties

舉例來說,如要建立 .properties 檔案:

  1. 以任何使用者的身分在編輯器中建立檔案。
  2. 擁有 apigee:apigee 的權限,或者若變更執行 Edge 服務的使用者,從 apigee 使用者取得檔案給執行 Edge 服務的使用者。

如要設定元件的屬性,請編輯對應的 .properties 檔案來設定符記,然後重新啟動元件:

> /opt/apigee/apigee-service/bin/apigee-service component restart

例如,編輯 router.properties 後,請重新啟動路由器:

> /opt/apigee/apigee-service/bin/apigee-service edge-router restart

升級 Edge 時,系統會讀取 /opt/apigee/customer/application 目錄中的 .properties 檔案。這表示升級作業會保留您在元件上設定的所有屬性。

.properties 檔案的位置

Edge 元件的 .properties 檔案有三個頂層目錄:安裝擁有者和客戶。預設位置如下表所示:

警告:Edge 客戶只能修改 /opt/apigee/customer 下的 .properties 檔案。雖然您可以查看元件和安裝目錄下的檔案,但請勿修改任何檔案。

擁有者

預設權杖根目錄

元件

/opt/apigee/<prefix>-<component>/conf

其中 /<prefix>-<component> 識別出元件,例如 Edge-router 或 apigee-cassandra。

安裝

/opt/apigee/token

客戶

/opt/apigee/customer

判斷符記目前的值

在元件的 .properties 檔案設定權杖之前,您可以先使用下列指令確定其目前的值:

> /opt/apigee/apigee-service/bin/apigee-service comp configure -search token

其中 comp 是元件的名稱,而「token」是要檢查的權杖。

這個指令會搜尋 .properties 檔案階層,來判斷符記目前的值。

例如,檢查路由器的 conf_http_HTTPRequest.line.limit 權杖目前值:

> /opt/apigee/apigee-service/bin/apigee-service edge-router configure -search conf_http_HTTPRequest.line.limit

您應該會看到下列格式的輸出內容:

Found key conf_http_HTTPRequest.line.limit, with value, 4k, in /opt/apigee/edge-router/token/default.properties

在 .properties 檔案中設定權杖

如何覆寫符記的值:

  1. 編輯元件的 .properties 檔案,設定符記值。如果檔案不存在,則需建立檔案。
  2. 重新啟動元件。
  3. 請檢查權杖值。

例如,若要設定邊緣路由器的要求行限制:

  1. 編輯 /opt/apigee/customer/application/router.properties 檔案,設定 conf_http_HTTPRequest.line.limit 權杖:

    conf_http_HTTPRequest.line.limit=8k
  2. 重新啟動 Edge 路由器:

    > /opt/apigee/apigee-service/bin/apigee-service Edge-router restart
  3. 查看符記值:

    > /opt/apigee/apigee-service/bin/apigee-service Edge-routerconfigure -search conf_http_HTTPRequest.line.limit

設定可接受多個值的符記

部分權杖會以半形逗號分隔值清單。舉例來說,conf_security_rbac.restricted.resources 權杖會取得受限制的 URI 清單,因此只有 sysadmin 才能呼叫這些 URI。如要查看 conf_security_rbac.restricted.resources 的值,請執行下列操作:

> cd /opt/apigee/edge-management-server
> grep -ri "conf_security_rbac.restricted.resources" *

輸出結果包含以下內容:

token/default.properties:conf_security_rbac.restricted.resources=/environments,/environments/*,/environments/*/virtualhosts,/environments/*/virtualhosts/*,/pods,/environments/*/servers,/rebuildindex,/users/*/status

如要設定取得值清單的權杖,請在 .properties 檔案中將任何新值附加至權杖目前的值。因此,如要將 URI /myuri/* 加入 conf_security_rbac.restricted.resources,請編輯 /opt/apigee/customer/application/management-server.properties 檔案,如下所示:

conf_security_rbac.restricted.resources=/environments,/environments/*,/environments/*/virtualhosts,/environments/*/virtualhosts/*,/pods,/environments/*/servers,/rebuildindex,/users/*/status,/myuri/*

找出權杖

在多數情況下,本指南會找出您需要設定的憑證。但是,如果需要判斷用來覆寫屬性的符記,請在元件的 source 資料夾中執行 grep

舉例來說,如果您知道在先前的 Edge 版本中,設定了 session.maxAge 屬性且想要知道用於設定該屬性的權杖值,則 /opt/apigee/edge-ui/source 目錄中的屬性 grep

> grep -ri "session.maxAge" /opt/apigee/edge-ui/source

您應該會看到以下形式的結果:

/opt/apigee/edge-ui/source/conf/application.conf:session.maxAge={T}conf_application_session.maxage{/T}

{T}{/T} 標記之間的字串是您在 .properties 檔案中設定的權杖。

設定目前已加上註解的權杖

部分符記在 Edge 設定檔中已加註。如果您嘗試設定已加上註解的符記,系統會忽略該設定。

如要設定標記註解的符記,請使用特殊語法,格式如下:

conf/file.extension+propertyName=propertyValue

舉例來說,您想要在訊息處理器上設定名為 HTTPClient.proxy.host 的屬性。然後,屬性的 grep 可以確定其符記:

> cd /opt/apigee/edge-message-processor
> grep -ri "HTTPClient.proxy.host" *

grep 指令會傳回包含權杖值的結果。請注意屬性名稱的註解方式,如屬性名稱上的 # 前置字串所示:

source/conf/http.properties:#HTTPClient.proxy.host={T}conf_http_HTTPClient.proxy.host{/T}
token/default.properties:conf_http_HTTPClient.proxy.host=
conf/http.properties:#HTTPClient.proxy.host=

如要設定屬性,請編輯 /opt/apigee/customer/application/message-processor.properties,將屬性設為:

conf/http.properties+HTTPClient.proxy.host=myhost.name.com

請注意,屬性名稱的前置字串是 conf/http.properties+,也就是含有該屬性的設定檔位置和名稱,後面接著「+」。

重新啟動「訊息處理器」後,檢視 /opt/apigee/edge-message-processor/conf/http.properties 檔案:

> cat /opt/apigee/edge-message-processor/conf/http.properties

在檔案結尾,您將看到屬性集,格式如下:

conf/http.properties:HTTPClient.proxy.host=myhost.name.com