By default, a database cluster only allows connections from within the user cluster and the same project. To allow external connections from IP addresses outside of your Google Distributed Cloud air-gapped organization:
Console
- Sign in to the GDC console with an account bound to the
project-networkpolicy-admin
role to create firewall rules. - From the main menu of the GDC console, choose Firewall.
- In the User created rules section, click Create.
- In Firewall rule details, create a name for your firewall rule.
- In the Direction of traffic dialog, choose INGRESS.
- In the Target dialog, choose Service and then select dbs.
- In the From dialog, choose Outside the organization and input the CIDR range from which you would like to allow external connectivity.
- Click Create.
- Wait for the Status column of the new rule to show Ready.
- Sign in to the GDC console with an account bound to the
project-db-admin
- From the main menu of the GDC console, choose Database Service.
- Select the database cluster that you want to enable external connections to.
- Check the Allow external connections line of the Connectivity section of the Database cluster overview to see whether external connections are already allowed.
- In the Connectivity section of the Database cluster overview, click edit Edit.
- Select the Allow external connections checkbox.
- Click SAVE.
API
Create a
ProjectNetworkPolicy
resource to allow external connections:apiVersion: networking.gdc.goog/v1 kind: ProjectNetworkPolicy metadata: name: allow-external-dbs namespace: USER_PROJECT spec: ingress: - from: - ipBlock: cidr: CIDR_RANGE policyType: Ingress subject: managedServices: matchTypes: - dbs subjectType: ManagedService ```
Update the database cluster to enable connections external to the organization:
kubectl patch dbcluster.DBENGINE_NAME.dbadmin.gdc.goog DBCLUSTER_NAME -p '{"spec":{"allowExternalIncomingTraffic":true}}' --type=merge -n USER_PROJECT
Replace the following:
USER_PROJECT
: the name of the user project where the database cluster was created.CIDR_RANGE
: the CIDR range from which you would like to allow external connectivity.DBENGINE_NAME
: the name of the database engine. This is one ofalloydbomni
,postgresql
ororacle
.DBCLUSTER_NAME
: the name of the database cluster.