部署多租戶 JSON 配置

如同其他的 IBM® Voice Gateway 環境,您可以利用 JSON 進階配置內容,透過 Docker 將多租戶 JSON 配置部署在內部,或是透過 Kubernetes 型 IBM® Cloud Kubernetes Service 部署在公用雲端。1.0.0.2 版及更新版本支援 JSON 配置。

在您部署環境之後,即可在所配置的租戶 URI 找到每一個租戶,並且可在 SIP 或 SIP URI(例如 sip:12345556789@myhost.com)存取該租戶。由於 Voice Gateway 會根據 SIP To 標頭欄位和 Request-URI 值,來驗證入埠 SIP 要求,只有與所配置租戶的通話,才會連接。

開始之前

請熟悉 Voice Gateway 部署選項,並在 Voice Gateway 入門中,試著進行基本部署。

瞭解如何使用 JSON 配置,並建立一個租戶配置 JSON 檔。如需相關資訊,請參閱在多租戶 JSON 配置中配置租戶

下列指示假設您的租戶配置 JSON 檔 tenantConfig.json 位於您 Voice Gateway 配置的相同本端目錄中。

使用 Docker 引擎來部署

  1. docker-compose.yml 檔中,將目錄裝載成 Docker 磁區,以包含租戶配置。裝載目錄可確保當您重新部署 Voice Gateway 時,配置仍持續保存。如需 Docker 磁區的相關資訊,請參閱 Docker 說明文件

    如果要裝載本端目錄,請以 host_directory:container_directory 格式,在 SIP Orchestrator 儲存器的 volumes 索引鍵上,指定目錄對映。在下列範例中,$PWD 會解析為現行工作目錄,並將它裝載至 SIP Orchestrator 儲存器上的 /vgwConf/ 路徑。

     services:
       sip.orchestrator:
         ...
         volumes:
           - $PWD:/vgwConf/
    
  2. Voice Gateway 配置中的 MULTI_TENANT_CONFIG_FILE Docker 環境變數上,指定租戶配置檔的路徑。

    MULTI_TENANT_CONFIG_FILE=/vgwConf/tenantConfig.json
    
  3. 在指令行上,移至含有您配置的目錄,並執行 docker-compose up 指令,以重新部署 Voice Gateway。

部署在 IBM Cloud Kubernetes Service 上

  1. 從租戶配置建立一個 Kubernetes 密碼。Kubernetes 密碼可維護您租戶配置中的認證與其他機密性資訊的安全,使其不會逐項儲存在您的 IBM Cloud Private 部署中。

    在指令行上,切換至您的部署目錄,並執行下列指令,以便從 tenantConfig.json 檔建立密碼。

    kubectl create secret generic tenantconfig --from-file=tenantConfig.json
    
  2. deploy.json 檔中,指定租戶配置檔的參照以及您所建立的密碼。

    提示:如需完整範例,請參閱 sample.voice.gateway GitHub 儲存庫中的 deploy-multitenant.json 檔。

    • 在部署配置中,以您在建立時所指定的名稱和檔案,來配置密碼:
      "volumes": [{
      ...
      {
      "name": "tenantconfig",
      "secret": {
       "secretName": "tenantconfig",
       "items": [{
         "key": "tenantConfig.json",
         "path": "tenantConfig.json"
         }]
       }
      }]
      
    • 在 SIP Orchestrator 儲存器 (vgw-sip-orchestrator) 配置中,在 MULTI_TENANT_CONFIG_FILE 變數上指定租戶配置檔的路徑。此外,亦將您的租戶配置密碼裝載成磁區。
      "name": "vgw-sip-orchestrator",
      "image": "ibmcom/voice-gateway-so:latest",
      ...
       "env": [
       ...
       {
         "name": "MULTI_TENANT_CONFIG_FILE",
         "value": "/tenantconfig/tenantConfig.json"
      }],
      "resources": {},
      "volumeMounts": [{
         "name": "tenantconfig",
         "mountPath": "/tenantconfig/tenantConfig.json",
         "subPath": "tenantConfig.json"
      }]
      
  3. 執行下列指令,從 tenantConfig.json 檔建立 Kubernetes 密碼。

    kubectl create secret generic tenantconfig --from-file=tenantConfig.json
    
  4. 執行 kubectl create 指令,以重新部署 Voice Gateway。
    kubectl create -f deploy.json