平面模式网络模型分为两种类型:静态模式网络和动态模式网络(使用边界网关协议)。当节点跨越单个第 2 层网域时,可以使用静态平面模式。对于跨多个第 2 层网域的节点,请将平面 IP 地址模式与 BGP 搭配使用。
在平面模式网络模型中,pod 具有跨集群的唯一 IP 地址。确保分配的 pod CIDR 唯一,并且不与任何其他子网重叠。例如,IP 地址不能与用于其他集群中的节点或其他 pod CIDR 的 IP 地址重叠。这些 IP 地址可以从外部访问,因此任何节点上的 pod 都可以与所有其他节点上的所有 pod 通信。从 pod 到任何外部 IP 地址的通信不需要进行网络地址转换 (NAT)。如需详细了解平面模式网络模型及其与默认孤岛网络模型的对比情况,请参阅平面模式与孤岛模式网络模型。
如果您有大型 IP 地址空间,并且可以为集群分配唯一的 pod CIDR,请使用平面模式网络模型。您可以使用 ClusterCIDRConfig 动态配置 pod CIDR。您可以在创建集群后添加或删除 ClusterCIDRConfig。 如需详细了解 ClusterCIDRConfig 及其用法示例,请参阅了解 ClusterCIDRConfig 自定义资源。
在 IPv4 的静态平面网络模式下,Pod IP 地址可达性基于地址解析协议 (ARP) 数据包。因此,仅当 Pod 位于同一第 2 层网域中时,才能访问 Pod IP 地址。这些节点必须属于同一第 2 层网域。您为 Pod 指定的 IP 地址(使用 ClusterCIDRConfig)必须与集群节点位于同一子网中。
配置的 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"]],["最后更新时间 (UTC):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)."]]