扁平模式網路模型分為兩種:靜態模式網路和動態模式網路 (使用邊界閘道通訊協定)。當節點跨越單一第 2 層網域時,可以使用靜態平面模式。如要跨越多個第 2 層網域的節點,請使用 BGP 的扁平 IP 模式。
在扁平模式網路模型中,Pod 在叢集間具有不重複的 IP 位址。確認指派的 Pod CIDR 是獨一無二,且不會與任何其他子網路重疊。舉例來說,IP 位址不得與節點使用的 IP 位址重疊,也不得與其他叢集中的其他 Pod CIDR 重疊。這些 IP 位址可從外部存取,因此任何節點上的 Pod 都能與所有其他節點上的 Pod 通訊。Pod 與任何外部 IP 位址之間的通訊都不需要網路位址轉譯 (NAT)。如要進一步瞭解扁平模式網路模型,以及與預設島嶼模式網路模型的比較,請參閱「扁平模式與島嶼模式網路模型」。
如果 IP 位址空間很大,且可以為叢集指派專屬的 Pod CIDR,請使用扁平模式網路模型。您可以使用 ClusterCIDRConfigs 動態設定 Pod CIDR。叢集建立後,您可以新增或刪除 ClusterCIDRConfigs。如要進一步瞭解 ClusterCIDRConfig,以及如何使用這項資源的範例,請參閱「瞭解 ClusterCIDRConfig 自訂資源」。
在 IPv4 的靜態扁平網路模式中,Pod IP 位址可連線能力是以位址解析通訊協定 (ARP) 封包為準。因此,只有當 Pod 位於相同的第 2 層網域時,才能連線至 Pod 的 IP 位址。節點必須屬於同一個第 2 層網域。您為 Pod 指定的 IP 位址 (使用 ClusterCIDRConfigs) 必須與叢集節點位於相同的子網路。設定的 Pod CIDR 必須來自節點的子網路。舉例來說,如果叢集中的節點使用 222.1.0.0/16 子網路,請為 Pod 選取子網路中較小的子網路,例如 222.1.2.0/24。確認叢集中的其他資源未使用為 Pod 分配的 IP 位址範圍。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-01 (世界標準時間)。"],[],[],null,["Overview\n\nFlat-mode network models are of two types: static mode network and dynamic mode\nnetwork (using Border Gateway Protocol). Static flat-mode can be used when nodes\nspan a single Layer 2 domain. For nodes spanning across multiple Layer 2\ndomains, use flat IP mode with BGP.\n\nIn a flat-mode network model, pods have unique IP addresses across clusters.\nEnsure that the pod CIDRs assigned are unique and don't overlap with any other\nsubnets. For example, IP addresses can't overlap with IP addresses used for the\nnodes or the other pod CIDRs in other clusters. These IP addresses can be\naccessed externally and hence pods on any node can communicate with all pods on\nall other nodes. Communication from the pod to any external IP address doesn't\nrequire network address translation (NAT). For more information about the flat\nmode network model and how it compares with the default, island network model,\nsee\n[Flat vs island mode network models](/kubernetes-engine/distributed-cloud/bare-metal/docs/reference/flat-vs-island-network).\n\nUse a flat-mode network model when you have a large IP address space and you can\nassign a unique pod CIDR for a cluster. You can configure the pod CIDRs using\nthe ClusterCIDRConfigs dynamically. You can add or delete ClusterCIDRConfigs\nafter the cluster is created. For more information on ClusterCIDRConfig and examples on\nusing it, see [Understand the ClusterCIDRConfig custom resource](/kubernetes-engine/distributed-cloud/bare-metal/docs/reference/cluster-cidr-config).\n\nFor more information on flat-mode with BGP, see\n[Implement flat-mode network model with BGP support](/kubernetes-engine/distributed-cloud/bare-metal/docs/how-to/flat-bgp-network).\n\nUnderstanding the Pod IP address reachability\n\nIn static flat network mode for IPv4, Pod IP address reachability is based on\nAddress Resolution Protocol (ARP) packets. Therefore, Pods IP addresses are\nreachable only when the Pods are in the same Layer 2 domain. The nodes must\nbelong to the same Layer 2 domain. The IP addresses you specify for your Pods\n(using ClusterCIDRConfigs) must be in the same subnet as the cluster nodes.\nPods CIDRs configured must be from the nodes' subnet. For example, 222.1.0.0/16\nsubnet is used by the nodes in a cluster then select a smaller subnet within the\nsubnet for the pods, 222.1.2.0/24. Ensure that no other resource in your cluster\nis using an IP address from the range allocated for your pods.\n\nFollowing section describes the configuration for flat-mode networks for IPv4.\n\nHow to implement a static flat-mode network\n\nBy default, Google Distributed Cloud cluster is created in island-mode networking. This\nsection describes how to set up flat-mode networking for your cluster.\n\nTo deploy a cluster with a flat-mode network model, make the following changes\nto the cluster configuration file:\n\nFlat-mode networking can be enabled for a cluster during cluster creation only.\nTo create a new cluster with flat-mode networking, use the following steps:\n\n1. Edit the cluster configuration file to add `clusterNetwork.flatIPv4` and set\n it to `true`.\n\n When you enable flat-mode networking, the pod CIDR specified in the cluster\n configuration file (`clusterNetwork.pods.cidrBlocks`) is ignored.\n2. Append a ClusterCIDRConfig manifest to the cluster configuration file.\n\n In the ClusterCIDRConfig manifest, include the following information:\n - `metadata.namespace`: the namespace of your cluster.\n\n - `spec.ipv4.cidr`: the range of IP addresses in CIDR block format to use\n for Pods in your cluster. This range must come from the same subnet as\n the cluster nodes.\n\n - `perNodeMaskSize`: Cluster creation preflight checks verify that the\n `perNodeMaskSize` value is sufficient to provision the number of pods\n specified in `maxPodsPerNode`.\n\n - `nodeSelector`: If no node labels match the `nodeSelector` value, the\n node reconciliation remains pending and cluster creation doesn't\n complete.\n\nThe following excerpt of a cluster configuration file shows how to implement\nflat-mode networking without BGP support. The CIDRs that appear in this excerpt\nare only examples and you will need to replace them with your own CIDRs. When\nreplacing the CIDRs with your own, ensure that they satisfy the criteria for pod\nreachability as specified in\n[Understanding the pod IP address reachability](#understanding_the_pod_ip_address_reachability). \n\n ---\n apiVersion: baremetal.cluster.gke.io/v1\n kind: Cluster\n metadata:\n name: flat-mode\n namespace: cluster-flat-mode\n spec:\n ... (other cluster config omitted)\n\n ...\n # Cluster networking configuration\n clusterNetwork:\n flatIPv4: true\n services:\n cidrBlocks:\n - 10.96.0.0/12\n ... (other cluster config omitted)\n\n ...\n ---\n apiVersion: baremetal.cluster.gke.io/v1alpha1\n kind: ClusterCIDRConfig\n metadata:\n name: cluster-wide-1\n namespace: cluster-flat-mode\n spec:\n ipv4:\n cidr: \"222.1.0.0/16\"\n perNodeMaskSize: 24\n\nLimitations\n\nThe static flat-mode network for Google Distributed Cloud comes with the following\nlimitations:\n\n- Pods using flat-mode networks would be reachable within the single Layer 2\n domain. Any other machine which is not in the cluster, but in the same Layer\n 2 domain can also reach the Pods. This limitation exists for IPv6 as well\n when dualstack clusters are created and when IPv6 is in flat-mode without\n BGP.\n For more information, see\n [Understanding the pod IP address reachability](#understanding_the_pod_ip_address_reachability).\n\n- The Google Distributed Cloud IPAM controller tracks the IP address availability\n within the configured pod CIDRs. It does not track the IPs already in use by\n other devices. Hence, any other IPs in the Layer 2 domain must not interfere\n with the POD CIDRs. For more information, see\n [Understanding the pod IP address reachability](#understanding_the_pod_ip_address_reachability)."]]