本頁面說明如何設定 Google Distributed Cloud 的 Proxy 和防火牆規則。
設定 Proxy 伺服器
如果用於啟動程序和叢集節點的機器透過 Proxy 伺服器存取網際網路,您必須:
- 為叢集節點上的套件管理工具設定 Proxy
- 在叢集設定檔中設定 Proxy 詳細資料。
必要條件
Proxy 伺服器必須允許連線至下列位址:
| 地址 | 目的 |
|---|---|
*.gcr.io |
從 Artifact Registry 提取映像檔。 |
accounts.google.com |
處理 OpenID 的授權要求,並探索用於驗證權杖的公開金鑰。 |
binaryauthorization.googleapis.com |
如果使用二進位授權,則必須提供這項資訊。授權 (或拒絕) 叢集執行容器映像檔的要求。 |
cloudresourcemanager.googleapis.com |
解析與叢集連線的 Google Cloud 專案相關中繼資料。 |
compute.googleapis.com |
驗證 Cloud Logging 和 Cloud Monitoring 資源區域。 |
connectgateway.googleapis.com |
啟用將叢集的唯讀存取權授予 Cloud Customer Care 的功能,以便診斷問題。 |
dl.google.com |
下載並安裝 Google Cloud SDK。 |
gkeconnect.googleapis.com |
建立用於接收 Google Cloud 要求和發出回應的管道。如果叢集是使用 Google Cloud 區域註冊至機群,則須將REGION-gkeconnect.googleapis.com(例如us-central1-gkeconnect.googleapis.com) 加入許可清單。如未指定區域,叢集會使用全域 Connect 服務執行個體,並將gkeconnect.googleapis.com加入許可清單。如要找出叢集的機群成員資格位置,請執行 gcloud container fleet memberships list。詳情請參閱 gkeConnect.location。 |
gkehub.googleapis.com |
建立 Google Cloud端機群成員資格資源,對應您要連結 Google Cloud的叢集。 |
gkeonprem.googleapis.com |
在 bare metal 和 VMware 基礎架構上建立及管理叢集生命週期。 |
gkeonprem.mtls.googleapis.com |
在裸機和 VMware 基礎架構上建立及管理叢集生命週期。這個版本的 API 會自動與 mTLS 搭配使用。 |
iam.googleapis.com |
建立服務帳戶,用於向 Google Cloud 進行驗證及發出 API 呼叫。 |
iamcredentials.googleapis.com |
提供稽核記錄的許可控制和遙測報告。 |
kubernetesmetadata.googleapis.com |
叢集會使用這個 API 做為端點,將 Kubernetes 中繼資料傳送至Google Cloud。中繼資料對於叢集監控、偵錯和復原至關重要。 |
logging.googleapis.com |
寫入記錄項目及管理 Cloud Logging 設定。 |
monitoring.googleapis.com |
管理 Cloud Monitoring 資料和設定。 |
oauth2.googleapis.com |
透過 OAuth 權杖交換進行驗證,以存取帳戶。 |
opsconfigmonitoring.googleapis.com |
收集 Kubernetes 資源 (例如 Pod、部署項目或節點) 的中繼資料,豐富指標查詢。 |
releases.hashicorp.com |
選用。在管理員工作站上使用 Terraform 用戶端執行指令,例如 terraform apply。 |
securetoken.googleapis.com |
擷取 Workload Identity 授權的更新權杖。 |
servicecontrol.googleapis.com |
將稽核記錄項目寫入 Cloud 稽核記錄。 |
serviceusage.googleapis.com |
啟用及驗證服務和 API。 |
stackdriver.googleapis.com |
管理 Google Cloud Observability 中繼資料,例如 Stackdriver 帳戶。 |
storage.googleapis.com |
管理物件儲存庫和 bucket,例如 Artifact Registry 物件。 |
sts.googleapis.com |
將 Google 或第三方憑證交換為 Google Cloud 資源的短期存取權杖。 |
www.googleapis.com |
驗證傳入 Google Cloud 服務要求的服務權杖。 |
除了這些網址外,Proxy 伺服器也必須允許作業系統套件管理員所需的任何套件鏡像。您可以更新套件管理工具設定,改用更確定的清單,這樣比較容易管理。
為叢集節點上的套件管理工具設定 Proxy
Google Distributed Cloud 在 Ubuntu 上使用 APT 套件管理工具,在 Red Hat Enterprise Linux 上使用 DNF 套件管理工具。確認 OS 套件管理工具的 Proxy 設定正確。
如要進一步瞭解如何設定 Proxy,請參閱 OS 發行版本的說明文件。以下範例說明如何設定 Proxy 設定:
APT
下列指令示範如何設定 APT 的 Proxy:
sudo touch /etc/apt/apt.conf.d/proxy.conf
echo 'Acquire::http::Proxy "http://USERNAME:PASSWORD@DOMAIN";' \
>> /etc/apt/apt.conf.d/proxy.conf
echo 'Acquire::https::Proxy "http://USERNAME:PASSWORD@DOMAIN";' \
>> /etc/apt/apt.conf.d/proxy.conf
請將 USERNAME:PASSWORD@DOMAIN 替換成設定的詳細資料。舉例來說,如果 Proxy 不需要登入,請勿在 DOMAIN 中加入 USERNAME:PASSWORD@。
DNF
這個指令示範如何設定 DNF 的 Proxy:
echo "proxy=http://USERNAME:PASSWORD@DOMAIN" >> /etc/dnf/dnf.conf
請將 USERNAME:PASSWORD@DOMAIN 替換成設定的詳細資料。舉例來說,如果 Proxy 不需要登入,請勿在 DOMAIN 中加入 USERNAME:PASSWORD@。
在叢集設定檔中設定 Proxy 詳細資料
在叢集設定檔中,設定下列值,將叢集設為使用 Proxy:
proxy.url
指定 Proxy 網址的字串。bootstrap 和節點機器會使用這個 Proxy 存取網際網路。Proxy 網址字串開頭必須是其結構定義,例如 http:// 或 https://。
proxy.noProxy
不應透過 Proxy 伺服器的 IP 位址、主機名稱和網域名稱清單。
在多數情況下,您不需要在這個清單中新增任何項目。
noProxy用途:
使用位於相同私人網路的私人套件鏡像 (不需 Proxy 即可存取)
使用位於相同私人網路的私人登錄檔鏡像 (不需透過 Proxy 存取)
範例
以下是叢集設定檔中的 Proxy 設定範例:
proxy:
url: http://USERNAME:PASSWORD@DOMAIN
noProxy:
- example1.com
- example2.com
GKE 身分認證服務的 Proxy 設定
如果您在 Google Distributed Cloud 叢集中使用 GKE 身分認證服務進行驗證,則必須執行下列額外步驟,確保 GKE 身分認證服務在 Proxy 後方運作。
在叢集設定檔中,於 OIDC
authentication區段設定 GKE 身分認證服務的 Proxy 詳細資料。authentication: oidc: proxy: http://USERNAME:PASSWORD@DOMAIN更新 Proxy 伺服器的設定,允許連線至 OIDC 供應商的驗證網址。
Proxy 在叢集中的使用方式
一般來說,bmctl 指令及其產生的程序會使用環境變數 HTTPS_PROXY 和 NO_PROXY 定義的 Proxy 設定 (如果有定義)。否則,bmctl 會使用叢集設定檔中的 Proxy 設定。在管理員工作站、叢集節點機器上執行的其他指令,或由 bootstrap 叢集執行的指令,會使用叢集設定檔中的 Proxy 設定。
每個節點上的 OS 套件管理工具都會使用自己的設定檔進行 Proxy 設定。
覆寫 bootstrap 機器中的 Proxy 設定
您可以覆寫叢集設定檔中的 Proxy 設定,在與節點機器不同的 Proxy 後方執行管理員工作站。如要覆寫 Proxy 設定,請在啟動機器上設定下列環境變數:
export HTTPS_PROXY=http://USERNAME:PASSWORD@DOMAIN
將 USERNAME:PASSWORD@DOMAIN 替換為設定的詳細資料。
export NO_PROXY=example1.com,example2.com
將 example1.com,example2.com 替換為不應透過 Proxy 伺服器的 IP 位址、主機名稱和網域名稱。
副作用
以 root 身分執行時,bmctl 會更新啟動機器上的 Docker Proxy 設定。如果不是以 root 身分執行 bmctl,請手動設定 Docker Proxy。
防火牆規則
請按照下列各節所述設定防火牆規則,允許 Google Distributed Cloud 所需的流量。
如要瞭解 Google Distributed Cloud 的必要通訊埠需求,請參閱「通訊埠使用情形」。
叢集節點 IP 位址的防火牆規則
下表說明叢集中可用 IP 位址的防火牆規則。
寄件者 |
來源通訊埠 |
收件者 |
通訊埠 |
通訊協定 |
說明 |
|---|---|---|---|---|---|
| 叢集節點 | 1024 - 65535 | cloudresourcemanager.googleapis.comgkeconnect.googleapis.comgkehub.googleapis.com |
443 | TCP/HTTPS | 必須具備存取權,才能註冊機群。 |
| Cloud Logging 收集器,在叢集節點上執行 | 1024 - 65535 | oauth2.googleapis.comlogging.googleapis.comstackdriver.googleapis.comservicecontrol.googleapis.comstorage.googleapis.comwww.googleapis.com |
443 | TCP/HTTPS | |
| Cloud Metadata Collector,在叢集節點上執行 | 1024 - 65535 | opsconfigmonitoring.googleapis.com |
443 | TCP/HTTPS | |
| Cloud Monitoring 收集器,在叢集節點上執行 | 1024 - 65535 | oauth2.googleapis.commonitoring.googleapis.comstackdriver.googleapis.comservicecontrol.googleapis.com |
443 | TCP/HTTPS | |
| 叢集節點 | 1024 - 65535 | 地端部署本機 Docker 登錄檔 | 取決於註冊資料庫 | TCP/HTTPS | 如果 Google Distributed Cloud 已設為使用本機私人 Docker 登錄檔,而非 gcr.io,則必須提供這項資訊。 |
| 叢集節點 | 1024 - 65535 | gcr.iooauth2.googleapis.comstorage.googleapis.com任何格式為 *.googleapis.com 的 Google API 網址,用於管理員叢集啟用的服務。 |
443 | TCP/HTTPS | 從公開 Docker 登錄檔下載映像檔。如果使用私人 Docker 登錄檔,則不需提供。 |
| Connect 代理程式,在叢集節點上執行 | 1024 - 65535 | cloudresourcemanager.googleapis.comgkeconnect.googleapis.comgkehub.googleapis.comwww.googleapis.comiam.googleapis.comiamcredentials.googleapis.comoauth2.googleapis.comsecuretoken.googleapis.comsts.googleapis.comaccounts.google.com |
443 | TCP/HTTPS | 如要進一步瞭解 Connect Agent 管理的流量,請參閱「Connect Agent 總覽」。 |
| 叢集節點 | 1024 - 65535 |
gkeonprem.googleapis.comgkeonprem.mtls.googleapis.com |
443 | TCP/HTTPS | 在裸機和 VMware 基礎架構上建立及管理叢集生命週期。 |
其餘元件的防火牆規則
下表所述規則適用於上一節未列出的所有其他元件。
寄件者 |
來源通訊埠 |
收件者 |
通訊埠 |
通訊協定 |
說明 |
|---|---|---|---|---|---|
| 客戶和應用程式使用者 | 全部 | Istio Ingress 的 VIP | 80、443 | TCP | 使用者叢集 Ingress 服務的使用者流量。 |
| 管理員工作站 | 32768 - 60999 | gcr.iocloudresourcemanager.googleapis.comoauth2.googleapis.comstorage.googleapis.com為這個叢集啟用的服務所需的任何 *.googleapis.com 網址 |
443 | TCP/HTTPS | 從公開 Docker 登錄檔下載 Docker 映像檔。 |
| 管理員工作站 | 32768 - 60999 | gcr.iocloudresourcemanager.googleapis.comiam.googleapis.comoauth2.googleapis.comserviceusage.googleapis.comstorage.googleapis.com為管理員或使用者叢集啟用的服務所需的任何 *.googleapis.com 網址 |
443 | TCP/HTTPS | 預檢 (驗證)。 |