[[["易于理解","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,["# Enable external connections\n\nBy default, a database cluster only allows connections from within the\n[user cluster](/distributed-cloud/hosted/docs/latest/gdch/resources/resource-hierarchy#cluster) and the same project. To allow\nexternal connections from IP addresses outside of your Google Distributed Cloud air-gapped organization: \n\n### Console\n\n1. Sign in to the GDC console with an account bound to the `project-networkpolicy-admin` role to create firewall rules.\n2. From the main menu of the GDC console, choose **Firewall**.\n3. In the **User created rules** section, click **Create**.\n4. In **Firewall rule details**, create a name for your firewall rule.\n5. In the **Direction of traffic** dialog, choose **INGRESS**.\n6. In the **Target** dialog, choose **Service** and then select **dbs**.\n7. In the **From** dialog, choose **Outside the organization** and input the CIDR range from which you would like to allow external connectivity.\n8. Click **Create**.\n9. Wait for the **Status** column of the new rule to show **Ready**.\n10. Sign in to the GDC console with an account bound to the `project-db-admin`\n11. From the main menu of the GDC console, choose **Database Service**.\n12. Select the database cluster that you want to enable external connections to.\n13. Check the **Allow external connections** line of the **Connectivity** section of the Database cluster overview to see whether external connections are already allowed.\n14. In the **Connectivity** section of the Database cluster overview, click edit **Edit**.\n15. Select the **Allow external connections** checkbox.\n16. Click **SAVE**.\n\n### API\n\n1. Create a `ProjectNetworkPolicy` resource to allow external connections:\n\n apiVersion: networking.gdc.goog/v1\n kind: ProjectNetworkPolicy\n metadata:\n name: allow-external-dbs\n namespace: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eUSER_PROJECT\u003c/span\u003e\u003c/var\u003e\n spec:\n ingress:\n - from:\n - ipBlock:\n cidr: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eCIDR_RANGE\u003c/span\u003e\u003c/var\u003e\n policyType: Ingress\n subject:\n managedServices:\n matchTypes:\n - dbs\n subjectType: ManagedService\n ```\n\n2. Update the database cluster to enable connections external to the organization:\n\n kubectl patch dbcluster.\u003cvar translate=\"no\"\u003eDBENGINE_NAME\u003c/var\u003e.dbadmin.gdc.goog \u003cvar translate=\"no\"\u003eDBCLUSTER_NAME\u003c/var\u003e -p '{\"spec\":{\"allowExternalIncomingTraffic\":true}}' --type=merge -n \u003cvar translate=\"no\"\u003eUSER_PROJECT\u003c/var\u003e\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eUSER_PROJECT\u003c/var\u003e: the name of the user project where the database cluster was created.\n- \u003cvar translate=\"no\"\u003eCIDR_RANGE\u003c/var\u003e: the CIDR range from which you would like to allow external connectivity.\n- \u003cvar translate=\"no\"\u003eDBENGINE_NAME\u003c/var\u003e: the name of the database engine. This is one of `alloydbomni`, `postgresql` or `oracle`.\n- \u003cvar translate=\"no\"\u003eDBCLUSTER_NAME\u003c/var\u003e: the name of the database cluster."]]