關於 GKE Dataplane V2 觀測功能

GKE Dataplane V2 觀測功能提供 GKE Dataplane V2 指標,以及 Google Cloud上 GKE 叢集工作負載的深入分析。GKE Dataplane V2 觀測能力可讓您:

GKE Dataplane V2 觀測能力提供下列疑難排解工具:

  • Kubernetes 叢集 Network Topology
  • Kubernetes 網路政策判定表,其中包含即時流量和連線資訊
  • 排解 Kubernetes 流量問題的指令列工具

GKE Dataplane V2 指標

GKE Dataplane V2 指標提供下列項目的流量資訊:

  • 流量:GKE 如何處理 Pod 和 Service 之間的流量。
  • 網路政策強制執行:GKE 如何強制執行 Kubernetes 網路政策的相關資訊。

您可以使用下列工具,透過 GKE Dataplane V2 指標監控 Kubernetes 工作負載及排解相關問題:

  • Google Cloud Managed Service for Prometheus,查看及分析 GKE Dataplane V2 指標。您可以修改 Google Cloud Managed Service for Prometheus 設定,新增或移除要擷取至 Google Cloud Managed Service for Prometheus 的指標。
  • Cloud Monitoring Metrics Explorer:查看 Pod 層級的流量詳細資料。
  • Cloud Monitoring:探索及使用任何指標。舉例來說,您可以建立警告,在 GKE Dataplane V2 指標超過特定門檻時觸發。
  • 自行管理的 Grafana,用於以圖表呈現 Google Cloud Managed Service for Prometheus 收集的指標。

啟用 Google Cloud Managed Service for Prometheus 後:

  • GKE 會建立 PodMonitoring 資源
  • GKE 會公開指標端點

如要透過 Google Cloud Managed Service for Prometheus 使用指標,並建立 PodMonitoring 資源,您必須在叢集上啟用 Google Cloud Managed Service for Prometheus。如未啟用 Google Cloud Managed Service for Prometheus,GKE 會公開指標端點,但不會建立 PodMonitoring 資源。

為叢集啟用 GKE Dataplane V2 指標後,Google Cloud Managed Service for Prometheus 會擷取下列 GKE Dataplane V2 指標:

GKE Dataplane V2 指標 類型 說明
prometheus.googleapis.com/pod_flow_egress_flows_count/counter cumulative Pod 的流量總數。
prometheus.googleapis.com/pod_flow_ingress_flows_count/counter cumulative 傳送至 Pod 的流量總數。

啟用 GKE Dataplane V2 指標後,每個 Kubernetes 節點上的指標通訊埠都會開啟。

您也可以使用其他指標,包括開放原始碼觀測平台 Hubble 的指標。根據預設,Google Cloud Managed Service for Prometheus 不會擷取這些額外指標,但您可以設定 Google Cloud Managed Service for Prometheus 來收集這些指標。如要收集這些指標,請設定 PodMonitoring 自訂資源 (CR)。

下表說明其他 Hubble 指標:

Hubble 指標 類型 說明
hubble_flows_processed_total cumulative 已處理的流程總數。
hubble_drop_total cumulative 捨棄的流量總數。
hubble_port_distribution_total cumulative 依通訊埠編號匯總的已處理流量總數。
hubble_tcp_flags_total cumulative 使用指定 TCP 旗標組合處理的流量總數。
hubble_icmp_total cumulative 處理的 ICMP 流量總數。

如要收集這些額外指標,您必須在叢集中建立 PodMonitoring 資源。

舉例來說,如要建立 PodMonitoring 資源來收集所有可用的 Hubble 指標,請完成下列步驟:

  1. 將下列資訊清單儲存為 pod-monitoring.yaml:

    apiVersion: monitoring.googleapis.com/v1
    kind: PodMonitoring
    metadata:
      name: hubble-metrics
      namespace: kube-system
      # The resource is created in the `kube-system` namespace because the Cilium pods that emit the metrics reside in that namespace
    spec:
      selector:
        matchLabels:
          k8s-app: cilium
      endpoints:
      - port: 9965
        interval: 30s
        path: /metrics
        metricRelabeling:
        - action: keep
          sourceLabels: [__name__]
          regex: (hubble_flows_processed_total|hubble_drop_total|hubble_port_distribution_total|hubble_tcp_flags_total|hubble_icmp_total)
    
  2. 執行下列指令,將資訊清單套用至叢集:

    kubectl apply -f pod-monitoring.yaml
    

    套用這項設定後,您就能在 Google Cloud Managed Service for Prometheus 查看其他 Hubble 指標。

GKE Dataplane V2 觀測工具

GKE Dataplane V2 觀測功能提供代管 Hubble 解決方案,可為使用 GKE Dataplane V2 部署的 Kubernetes 工作負載,提供網路觀測功能和安全性深入分析。

啟用後,GKE Dataplane V2 觀測能力會將下列元件部署至叢集:

  • Hubble Relay:這項服務會從各個節點收集 Pod 的網路遙測資料。

  • Hubble CLI:指令列介面工具,可提供叢集內的即時流量資訊。

為叢集啟用 GKE Dataplane V2 觀測能力後,即可部署下列元件:

  • Hubble UI:這項網頁式工具可用來查看及分析 Hubble Relay 收集的網路遙測資料。您必須啟用 GKE Dataplane V2 觀測功能,才能部署 Hubble UI。

GKE Dataplane V2 指標和觀測能力的運作方式

GKE Dataplane V2 觀測能力會使用下列元件和工具收集指標,並提供網路流量的深入分析:

  • GKE Dataplane V2:GKE Dataplane V2 指標和觀測功能會使用以 eBPF 為基礎的 GKE Dataplane V2 資料路徑,根據特定工作負載,收集 Pod 的流量和網路政策強制執行指標。

  • Google Cloud Managed Service for Prometheus:GKE Dataplane V2 指標會設定 Google Cloud Managed Service for Prometheus 代理程式,將匯總指標擷取至 Google Cloud Managed Service for Prometheus。這項可擴充的監控解決方案能擷取及儲存大量資料,並可讓您建構 Google Cloud Observability。

  • Hubble:GKE Dataplane V2 觀測功能使用 Hubble,這是一項開放原始碼觀測能力專案。Hubble 可為使用 eBPF Dataplane 部署的 Kubernetes 工作負載,提供網路觀測能力和安全性深入分析。

    Hubble 流量事件會在下列情況發生:

    • 首先,系統會建立網路連線

    • 首先會看到 TCP 旗標,代表 TCP 連線的狀態

    • 自上次流量事件後,至少經過五秒才傳輸封包

    Hubble 指標:計算 Kubernetes 叢集中的流量事件數量,可用於識別哪些 Pod 正在互相通訊。

  • 啟用指標和觀測功能:您可以分別啟用 GKE Dataplane V2 和觀測功能。如要在開放原始碼 Hubble UI 中啟用網路拓撲視覺化功能,您必須啟用 GKE Dataplane V2 觀測功能。

  • Autopilot 叢集:

    • 指標預設為啟用

    • 觀測能力工具預設為停用

    • 您必須建立 ClusterPodMonitoring 資源,才能在 Google Cloud Managed Service for Prometheus 收集指標

  • Standard 叢集:

    • 指標預設為停用

    • 觀測能力工具預設為停用

    • 如果已啟用 Google Cloud Managed Service for Prometheus,系統會自動建立 PodMonitoring 資源

    • PodMonitoring 資源標示為「ensure exists」。如要停止將指標傳送至 Google Cloud Managed Service for Prometheus,請編輯 PodMonitoring 資源,停用所有指標

GKE Dataplane V2 觀測能力端點

GKE Dataplane V2 觀測能力元件會公開下列兩個觀測能力端點:

  • 指標端點:以 Prometheus 格式公開流量指標的 HTTP 端點。anetd Pod 會在通訊埠 9965 的每個叢集節點上公開指標端點。

  • Flows 通訊埠:gRPC 端點。hubble-relay Pod 會將 flows 通訊埠端點公開為通訊埠 443 上的 Kubernetes ClusterIP 服務。hubble-relay Pod 是 Kubernetes ClusterIP Service 的後端,所有傳送至 Kubernetes ClusterIP Service 的要求都會轉送至 hubble-relay Pod。您可以使用 Hubble CLI 或 Hubble UI 存取流量通訊埠。

限制

  • GKE Dataplane V2 觀測能力的叢集節點數量上限為 5000 個。
  • GKE Dataplane V2 指標和觀測能力僅適用於Google Cloud 中已啟用 GKE Dataplane V2 的叢集。
  • 由於指標是以流量為基礎,因此無法準確呈現網路流量中傳輸的資料量。
  • 啟用 Dataplane V2 指標後,anetd Pod 記憶體可能會因 Hubble 指標收集而持續增加。這是預期行為,因為指標會儲存在記憶體中,直到 Pod 重新啟動為止。

後續步驟