Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Por padrão, um cluster de banco de dados só permite conexões de dentro do cluster de usuário e do mesmo projeto. Para permitir conexões externas de endereços IP fora da sua organização isolada do Google Distributed Cloud:
Console
Faça login no console do GDC com uma conta vinculada à função
project-networkpolicy-admin para criar regras de firewall.
No menu principal do console do GDC, escolha Firewall.
Na seção Regras criadas pelo usuário, clique em Criar.
Em Detalhes da regra de firewall, crie um nome para a regra.
Na caixa de diálogo Direção do tráfego, escolha ENTRADA.
Na caixa de diálogo Destino, escolha Serviço e selecione dbs.
Na caixa de diálogo De, escolha Fora da organização e insira o intervalo
CIDR de onde você quer permitir a conectividade externa.
Clique em Criar.
Aguarde até que a coluna Status da nova regra mostre Pronto.
Faça login no console do GDC com uma conta vinculada ao
project-db-admin
No menu principal do console do GDC, escolha Serviço de banco de dados.
Selecione o cluster de banco de dados que você quer ativar para conexões externas.
Verifique a linha Permitir conexões externas na seção Conectividade da visão geral do cluster de banco de dados para saber se as conexões externas já estão permitidas.
Na seção Conectividade da visão geral do cluster de banco de dados, clique em
editEditar.
Marque a caixa de seleção Permitir conexões externas.
Clique em SALVAR.
API
Crie um recurso ProjectNetworkPolicy para permitir conexões externas:
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-09-04 UTC."],[],[],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."]]