Enable cross-project connections

Cross-project access for Database Service in Google Distributed Cloud (GDC) air-gapped lets workloads in another project connect to all database clusters in your project. You can share databases across project boundaries by creating an ingress firewall rule in the GDC console or a ProjectNetworkPolicy custom resource. By default, a database cluster accepts connections only from within the Kubernetes cluster and the same project.

Configure cross-project access

To let workloads in another project connect to all database clusters in your project, configure an ingress policy by using the GDC console or the API:

Console

  1. Sign in to the GDC console with an account bound to the project-networkpolicy-admin role to create firewall rules.
  2. From the main menu of the GDC console, choose Firewall.
  3. In the User created rules section, click Create.
  4. In Firewall rule details, create a name for your firewall rule.
  5. In the Direction of traffic dialog, choose INGRESS.
  6. In the Target dialog, choose Service and then select dbs.
  7. In the From dialog, choose Another project and select the project ID from which you would like to allow connectivity.
  8. Click Create.
  9. Wait for the Status column of the new rule to show Ready.

API

Create a ProjectNetworkPolicy resource to allow connections from a client project.

apiVersion: networking.gdc.goog/v1
kind: ProjectNetworkPolicy
metadata:
  name: dbs-allow-from-CLIENT_PROJECT
  namespace: USER_PROJECT
spec:
  subject:
    managedServices:
      matchTypes:
      - dbs
    subjectType: ManagedService
  ingress:
  - from:
    - projects:
        matchNames:
        - CLIENT_PROJECT
  policyType: Ingress

Replace the following:

  • CLIENT_PROJECT: the name of the project from which you would like to allow connectivity.
  • USER_PROJECT: the name of the user project where the database cluster was created.