[[["易于理解","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,["# Create allow-all traffic network policies\n\nThis page provides instructions to configure allow-all traffic network policies in Google Distributed Cloud (GDC) air-gapped.\n\nProject network policies define either ingress or egress rules. You can define policies that allow communication within projects, between projects, and with external IP addresses.\n\nBefore you begin\n----------------\n\nTo configure allow-all traffic network policies, you must have the following:\n\n- The necessary identity and access roles. For more information, see [Prepare predefined roles and access](/distributed-cloud/hosted/docs/latest/gdch/platform/pa-user/pnp/pnp-overview#prepare-predefined-roles-and-access).\n- An existing project. For more information, see [Create a project](/distributed-cloud/hosted/docs/latest/gdch/platform/pa-user/create-a-project).\n\nCreate an allow-all traffic policy\n----------------------------------\n\nThis policy allows traffic to and from any source, including other projects and external IP addresses.\n\n### Allow all ingress traffic\n\nTo allow all incoming traffic from any source to all workloads in your project, create the following policy: \n\n kubectl --kubeconfig \u003cvar translate=\"no\"\u003eGLOBAL_API_SERVER\u003c/var\u003e apply -f - \u003c\u003cEOF\n apiVersion: networking.global.gdc.goog/v1\n kind: ProjectNetworkPolicy\n metadata:\n namespace: \u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e\n name: allow-all-ingress\n spec:\n policyType: Ingress\n ingress:\n - {}\n EOF\n\n### Allow all egress traffic\n\nTo allow all outgoing traffic to any destination from all workloads in your project, create the following policy: \n\n kubectl --kubeconfig \u003cvar translate=\"no\"\u003eGLOBAL_API_SERVER\u003c/var\u003e apply -f - \u003c\u003cEOF\n apiVersion: networking.global.gdc.goog/v1\n kind: ProjectNetworkPolicy\n metadata:\n namespace: \u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e\n name: allow-all-egress\n spec:\n policyType: Egress\n egress:\n - {}\n EOF\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eGLOBAL_API_SERVER\u003c/var\u003e: the global API server's kubeconfig path. For more information, see [Global and zonal API servers](/distributed-cloud/hosted/docs/latest/gdch/resources/multi-zone/api-servers). If you have not yet generated a kubeconfig file for the API server, see [Sign in](/distributed-cloud/hosted/docs/latest/gdch/platform/pa-user/iam/sign-in#cli) for details.\n- \u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e: the name of the project where you want to allow all traffic.\n\nCreate an allow-all-external traffic policy\n-------------------------------------------\n\nThis policy allows traffic to and from IP addresses external to the organization.\n\n### Allow all external ingress traffic\n\nTo allow all incoming traffic from external IP addresses to all workloads in a project, create the following policy: \n\n kubectl --kubeconfig \u003cvar translate=\"no\"\u003eGLOBAL_API_SERVER\u003c/var\u003e apply -f - \u003c\u003cEOF\n apiVersion: networking.global.gdc.goog/v1\n kind: ProjectNetworkPolicy\n metadata:\n namespace: \u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e\n name: allow-all-external-ingress\n spec:\n policyType: Ingress\n ingress:\n - from:\n - ipBlock:\n cidr: 0.0.0.0/0\n EOF\n\n| **Warning:** Because the `0.0.0.0/0` CIDR block does not match workloads within the organization across zones and clusters, this rule blocks traffic from those workloads.\n\n### Allow all external egress traffic\n\nTo allow all outgoing traffic from all workloads in your project to external IP addresses, create the following policy: \n\n kubectl --kubeconfig \u003cvar translate=\"no\"\u003eGLOBAL_API_SERVER\u003c/var\u003e apply -f - \u003c\u003cEOF\n apiVersion: networking.global.gdc.goog/v1\n kind: ProjectNetworkPolicy\n metadata:\n namespace: \u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e\n name: allow-all-external-egress\n spec:\n policyType: Egress\n egress:\n - to:\n - ipBlock:\n cidr: 0.0.0.0/0\n EOF\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eGLOBAL_API_SERVER\u003c/var\u003e: the global API server's kubeconfig path. For more information, see [Global and zonal API servers](/distributed-cloud/hosted/docs/latest/gdch/resources/multi-zone/api-servers). If you have not yet generated a kubeconfig file for the API server, see [Sign in](/distributed-cloud/hosted/docs/latest/gdch/platform/pa-user/iam/sign-in#cli) for details.\n- \u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e: the name of the project where you want to allow all external traffic.\n\nCreate an allow-all-projects traffic policy\n-------------------------------------------\n\nThis policy allows traffic to and from all projects within the organization.\n\n### Allow all projects ingress traffic\n\nTo allow incoming traffic from all projects to all workloads in your project, create the following policy: \n\n kubectl --kubeconfig \u003cvar translate=\"no\"\u003eGLOBAL_API_SERVER\u003c/var\u003e apply -f - \u003c\u003cEOF\n apiVersion: networking.global.gdc.goog/v1\n kind: ProjectNetworkPolicy\n metadata:\n namespace: \u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e\n name: allow-all-projects-ingress\n spec:\n policyType: Ingress\n ingress:\n - from:\n - projectSelector: {}\n EOF\n\n### Allow all projects egress traffic\n\nTo allow outgoing traffic from all workloads in your project to all projects, create the following policy: \n\n kubectl --kubeconfig \u003cvar translate=\"no\"\u003eGLOBAL_API_SERVER\u003c/var\u003e apply -f - \u003c\u003cEOF\n apiVersion: networking.global.gdc.goog/v1\n kind: ProjectNetworkPolicy\n metadata:\n namespace: \u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e\n name: allow-all-projects-egress\n spec:\n policyType: Egress\n egress:\n - to:\n - projectSelector: {}\n EOF\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eGLOBAL_API_SERVER\u003c/var\u003e: the global API server's kubeconfig path. For more information, see [Global and zonal API servers](/distributed-cloud/hosted/docs/latest/gdch/resources/multi-zone/api-servers). If you have not yet generated a kubeconfig file for the API server, see [Sign in](/distributed-cloud/hosted/docs/latest/gdch/platform/pa-user/iam/sign-in#cli) for details.\n- \u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e: the name of the project where you want to allow all projects traffic."]]