在 Proxy 的保護下安裝

本頁面說明如何設定 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) 註冊至 Fleet,您需要將該區域加入許可清單。如果未指定區域,叢集會使用全域 Connect 服務執行個體,您需要將 gkeconnect.googleapis.com 加入許可清單。如要尋找叢集的機群成員位置,請執行 gcloud container fleet memberships list。 詳情請參閱 gkeConnect.location
gkehub.googleapis.com 建立 Google Cloud端機群成員資格資源,對應您要連線的叢集 Google Cloud。
gkeonprem.googleapis.com 在裸機和 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 管理物件儲存空間和值區,例如 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 套件管理工具。確認作業系統套件管理員的 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 網址的字串。啟動程序和節點機器會使用這個 Proxy 存取網際網路。Proxy 網址字串的開頭必須是其架構, 例如 http://https://

proxy.noProxy

不應透過 Proxy 伺服器連線的 IP 位址、主機名稱和網域名稱清單。

在多數情況下,您不需要在這個清單中新增任何項目。

noProxy 應用情境:

  • 使用位於相同私人網路中的私人套件鏡像 (不需要 Proxy 即可存取)

  • 使用位於相同私人網路的私人登錄檔鏡像 (不需要 Proxy 即可存取)

範例

以下是叢集設定檔中的 Proxy 設定範例:

  proxy:
     url: http://USERNAME:PASSWORD@DOMAIN
     noProxy:
     - example1.com
     - example2.com

GKE Identity Service 的 Proxy 設定

如果您在 Google Distributed Cloud 叢集中使用 GKE Identity Service 進行驗證,則必須執行下列額外步驟,確保 GKE Identity Service 在透過 Proxy 時能正常運作。

  1. 在叢集設定檔中,於 OIDC authentication 區段中設定 GKE Identity Service 設定的 Proxy 詳細資料。

      authentication:
        oidc:
          proxy: http://USERNAME:PASSWORD@DOMAIN
    
  2. 更新 Proxy 伺服器的設定,允許連線至 OIDC 提供者的驗證網址。

叢集內如何使用 Proxy

一般來說,bmctl 指令和其產生的程序會使用環境變數 HTTPS_PROXYNO_PROXY 定義的 Proxy 設定 (如有定義)。否則,bmctl 會使用叢集設定檔中的 Proxy 設定。在管理工作站、叢集節點機器上執行的其他指令,或由啟動叢集執行的指令,會使用叢集設定檔中的 Proxy 設定。

每個節點上的 OS 套件管理工具會使用自己的設定檔進行 Proxy 設定。

覆寫啟動機器的 Proxy 設定

您可以覆寫叢集設定檔中的 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 位址、主機名稱和網域名稱。

副作用

以根身分執行 bmctl 時,系統會更新啟動機器的 Docker Proxy 設定。如果沒有以根身分執行 bmctl,請手動設定 Docker 代理伺服器

防火牆規則

請按照下列各節所述設定防火牆規則,允許 Google Distributed Cloud 必要的流量。

如要瞭解 Google Distributed Cloud 的必要通訊埠需求,請參閱「通訊埠使用情形」。

叢集節點 IP 位址的防火牆規則

下表說明叢集中可用 IP 位址的防火牆規則。

寄件者

來源通訊埠

收件者

通訊埠

通訊協定

說明

叢集節點 1024 - 65535 cloudresourcemanager.googleapis.com
gkeconnect.googleapis.com
gkehub.googleapis.com
443 TCP/HTTPS 必須有存取權才能註冊機群
Cloud Logging 收集器 (在叢集節點上執行) 1024 - 65535 oauth2.googleapis.com
logging.googleapis.com
stackdriver.googleapis.com
servicecontrol.googleapis.com
storage.googleapis.com
www.googleapis.com
443 TCP/HTTPS
Cloud Metadata Collector,在叢集節點上執行 1024 - 65535 opsconfigmonitoring.googleapis.com 443 TCP/HTTPS
Cloud Monitoring 收集器 (在叢集節點上執行) 1024 - 65535 oauth2.googleapis.com
monitoring.googleapis.com
stackdriver.googleapis.com
servicecontrol.googleapis.com
443 TCP/HTTPS
叢集節點 1024 - 65535 地端本機 Docker 登錄檔 視註冊機構而定 TCP/HTTPS 如果 Google Distributed Cloud 設定為使用本機私人 Docker 登錄檔,而非 gcr.io,則必須提供這項資訊。
叢集節點 1024 - 65535 gcr.io
oauth2.googleapis.com
storage.googleapis.com
管理員叢集啟用服務所需的任何 Google API 網址,格式為 *.googleapis.com
443 TCP/HTTPS 從公開 Docker 登錄檔下載映像檔。如果使用私密 Docker 登錄檔,則不需要此步驟。
在叢集節點上執行的 Connect Agent 1024 - 65535 cloudresourcemanager.googleapis.com
gkeconnect.googleapis.com
gkehub.googleapis.com
www.googleapis.com
iam.googleapis.com
iamcredentials.googleapis.com
oauth2.googleapis.com
securetoken.googleapis.com
sts.googleapis.com
accounts.google.com
443 TCP/HTTPS 如要進一步瞭解 Connect Agent 管理的流量,請參閱 Connect Agent 總覽
叢集節點 1024 - 65535 gkeonprem.googleapis.com
gkeonprem.mtls.googleapis.com
443 TCP/HTTPS 在裸機和 VMware 基礎架構上建立及管理叢集生命週期。

其餘元件的防火牆規則

下表列出的規則適用於上一節未列出的所有其他元件。

寄件者

來源通訊埠

收件者

通訊埠

通訊協定

說明

客戶和應用程式使用者 全部 Istio Ingress 的 VIP 80、443 TCP 使用者叢集 Ingress 服務的使用者流量。
管理員工作站 32768 - 60999 gcr.io
cloudresourcemanager.googleapis.com
oauth2.googleapis.com
storage.googleapis.com
為這個叢集啟用的服務所需的任何 *.googleapis.com 網址
443 TCP/HTTPS 從公開 Docker 登錄檔下載 Docker 映像檔。
管理員工作站 32768 - 60999 gcr.io
cloudresourcemanager.googleapis.com
iam.googleapis.com
oauth2.googleapis.com
serviceusage.googleapis.com
storage.googleapis.com
管理員或使用者叢集啟用服務所需的任何 *.googleapis.com 網址
443 TCP/HTTPS 預檢 (驗證)。