[[["易于理解","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-04。"],[],[],null,["# Set up network policies\n\nKf integrates tightly with Kubernetes and Istio to\nprovide robust network policy enforcement.\n\nBy default, Kf workloads are run in the Kubernetes cluster and resolve addresses\nusing [Kubernetes DNS](https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/).\nThis DNS resolver will first attempt to resolve addresses within the cluster,\nand only if none are found will attempt external resolution.\n\nEach Kf App gets run with an Envoy sidecar injected by [Istio](https://istio.io/)\nor the [Anthos Service Mesh](/anthos/service-mesh) (ASM).\nThis sidecar proxies all network traffic in and out of the Kubernetes Pod.\n\nEach Kubernetes Pod is executed on a Node, a physical or virtual machine\nresponsible for managing the container images that make up a Pod. Nodes exist on\na physical or virtual network.\n\nTogether, these form a hierarchy of systems you can apply network policies.\nThese are listed below from least to most granular.\n\nNetwork level policies\n----------------------\n\nWorkload protection starts with the network your GKE cluster is installed on.\n\nIf you're running Kf on a GKE cluster on GCP, Kf recommends:\n\n- Placing your GKE cluster on a [Virtual Private Cloud](/vpc/docs) (VPC) network.\n - With [Private Google Access](/vpc/docs/configure-private-google-access) enabled.\n- Using [Cloud NAT](/nat) to control egress.\n\nNode level policies\n-------------------\n\nYou can set up policies for containers running on the Node using Kubernetes NetworkPolicies.\nThese are the closest mapping to Cloud Foundry network policies that exist in Kubernetes.\n\nNetworkPolicies are backed by a Kubernetes add-on. If you set up your own GKE\ncluster, you will need to [enable NetworkPolicy enforcement](/kubernetes-engine/docs/how-to/network-policy).\n| **Note:** NetworkPolicies applied by [Project Calico](https://www.projectcalico.org/) filter on a per-connection basis. On Linux they are backed by [iptables](https://en.wikipedia.org/wiki/Iptables). Like any firewall, **they are not a substitute of authentication and authorization**.\n\nKf labels Apps with `kf.dev/networkpolicy=app` and builds with `kf.dev/networkpolicy=build`.\nThis allows you to target NetworkPolicies directly at Pods running Apps or Builds.\n\nEach Kf Space creates two NetworkPolicies to start with, one targeting Apps and\none targeting Builds. You can change the configuration on the Space's\n`spec.networkConfig.(app|build)NetworkPolicy.(in|e)gress` fields.\nThese fields can be set to one of the following values:\n\nBy default Kf uses a permissive network policy. This allows the following\nfunctionality that Kf uses:\n\n- North/South routing to the cluster ingress gateway\n- Egress to the Internet e.g. to fetch Buildpacks\n- East/West routing between Apps\n- Access to the Kubernetes DNS server\n- Access to container registries\n- Direct access to the VPC network\n- Access to Google services like Cloud Logging\n- Access to the Workload Identity server for automatic rotating credentials\n\n| **Note:** Setting a default `DenyAll` policy will break existing and new Apps and Builds unless you create additional NetworkPolicies to add back the connections listed above.\n\nService mesh policies\n---------------------\n\nIf you need fine-grained networking control, authentication, authorization, and\nobservability you can apply policies using [Anthos Service Mesh](/service-mesh/docs/overview).\n\nA service mesh is an infrastructure layer that enables managed, observable and\nsecure communication across your services, letting you create robust enterprise\napplications made up of many microservices on your chosen infrastructure.\n\nYou can see the [list of supported features here](/service-mesh/docs/supported-features)."]]