<a id="usm-network-gcp"></a>

# Configure Google Cloud Private Networking for USM Agents

This page describes how to set up Google Cloud Private Service Connect connectivity for
the USM Agent to send Confluent Platform metadata to Confluent Cloud. You configure this
connectivity by creating a gateway and an access point in your Confluent Cloud
environment. For general Confluent Cloud Private Service Connect setup that’s not
specific to USM, see [Use Google Cloud Private Service Connect for Serverless Products on Confluent Cloud](../../networking/gcp-platt.md#cloud-networking-privatelink-gc-esku).

Unified Stream Manager (USM) requires a secure, private network connection between your
Confluent Platform cluster and Confluent Cloud that uses Google Cloud Private Service Connect. With Private
Service Connect, your Confluent Cloud resources are only accessible from private
endpoints in your VPC, so all metadata is transmitted over a private channel
without exposure to the public internet.

You can create a new private network or use an existing one.

If your Confluent Platform cluster runs outside Google Cloud, such as in a datacenter, a factory,
or a store, connect it to a Google Cloud VPC by using Cloud Interconnect or Cloud VPN.
The USM Agent then reaches Confluent Cloud through that VPC.

## Private networking resources

Confluent Cloud uses the following private networking resources for registering Confluent Platform clusters.
These resources are regional and can be accessed from any availability zone.

* **Ingress Private Service Connect Gateway**: A reservation to establish a
  Private Service Connect connection from your virtual private cloud (VPC) to
  regional services in a Confluent Cloud environment.
* **Ingress Private Service Connect Access Point**: A registration of a VPC
  Private Service Connect endpoint that’s allowed to connect to a Confluent Cloud
  environment. An access point belongs to a specific gateway.

You can create the gateway and access point by using the Confluent Cloud Console,
Confluent REST API, Confluent CLI, or Terraform.

The process consists of the following steps:

1. [In Confluent Cloud, create a gateway](#usm-gcp-gate).
2. [In Google Cloud, create a Private Service Connect endpoint that connects to the gateway’s service attachment](#usm-gcp-endpoint).
3. [In Confluent Cloud, create an access point for your endpoint](#usm-gcp-access).
4. [Set up your DNS resolution](#usm-gcp-dns).

The setup wizard in the Confluent Cloud guides you through this process.

If you have an existing Google Cloud Private Service Connect connection for your Confluent Cloud account and have
configured a private network using these [Google Cloud Private Service Connect instructions](../../networking/gcp-platt.md#cloud-networking-privatelink-gc-esku), you can select that
existing network from the wizard and proceed to the next section.

## Requirements and considerations

* USM requires private networking. Public networking isn’t supported.
* USM supports a limited set of Google Cloud regions. The **Region** list in the
  **Configure gateway** panel shows the regions that you can select.
* You can connect to several Confluent Cloud environments in the same region from a single VPC
  by creating a separate gateway for each environment.
* Cross-region Google Cloud access point resources are not supported.

<a id="usm-gcp-gate"></a>

## Create an Ingress Private Service Connect Gateway in Confluent Cloud

To establish a private network connection, first create a gateway in the
Confluent Cloud wizard. This process generates the unique **Service Attachment URI**
that you need to create the Private Service Connect endpoint in your Google Cloud
project.

### Confluent Cloud Console

1. On the **Select network configuration** page of the wizard, click **Add network configuration**.
2. In the **Configure gateway** panel, enter the following information:
   * **Gateway name**: A descriptive name for your network connection.
   * **Cloud provider**: Select **Google Cloud**.
   * **Region**: Select the Google Cloud region that matches your VPC.
3. Click **Submit**.
4. The next panel displays the **Service Attachment URI**. Copy this
   value to use it in the next step in the Google Cloud console.
5. Keep this Confluent Cloud browser tab open. Confluent Cloud provisions the gateway, and its state changes to `CREATED`.

   A gateway can have one of the following states:
   * `CREATED`: You provisioned the gateway and can now add an access point.
   * `READY`: You created the access point, and it can accept connections.
   * `EXPIRED`: You didn’t provision a valid access point in the allotted time. Create a new gateway to continue.

### Confluent REST API

1. Send a request to create a gateway resource:

   **REST request**
   ```rest
   POST https://api.confluent.cloud/networking/v1/gateways
   ```

   **REST request body**
   ```json
   {
     "spec": {
       "display_name": "<A custom name for the gateway>",
       "config": {
         "kind": "GcpIngressPrivateServiceConnectGatewaySpec",
         "region": "<Google Cloud region of the gateway>"
       },
       "environment": {
         "id": "<The ID of the environment to add the gateway to>"
       }
     }
   }
   ```

   For more information, see [Gateways](https://docs.confluent.io/cloud/current/api.html#tag/Gateways-(networkingv1))
   in the Confluent REST API reference.

### Confluent CLI

Use the following Confluent CLI command to create a Google Cloud gateway:

```bash
confluent network gateway create <gateway-name> <flags>
```

The following command-specific flags are supported:

* `--cloud`: Required. The cloud provider. Set to `gcp`.
* `--region`: Required. The Google Cloud region of the gateway.
* `--type`: Required. The type of gateway configuration. Set to
  `ingress-private-service-connect`.

For more information, see [confluent network gateway create](https://docs.confluent.io/confluent-cli/current/command-reference/network/gateway/confluent_network_gateway_create.html).

The following is an example Confluent CLI command to create a gateway:

```bash
confluent network gateway create my-ingress-gateway \
  --cloud gcp \
  --region us-central1 \
  --type ingress-private-service-connect
```

### Terraform

Use the [confluent_gateway](https://registry.terraform.io/providers/confluentinc/confluent/latest/docs/resources/confluent_gateway)
resource from the Confluent Terraform Provider to create a gateway.

An example snippet of Terraform configuration for a gateway:

```terraform
resource "confluent_gateway" "gcp_ingress" {
  display_name = "my-gateway"
  environment {
    id = "env-123abc"
  }
  gcp_ingress_private_service_connect_gateway {
    region = "us-central1"
  }
}
```

<a id="usm-gcp-endpoint"></a>

## Create a Private Service Connect endpoint in Google Cloud

In a new browser tab, log in to the Google Cloud console. Use the **Service Attachment
URI** that you copied in [Create an Ingress Private Service Connect Gateway in Confluent Cloud](#usm-gcp-gate) to create and configure the
[Private Service Connect endpoint](https://cloud.google.com/vpc/docs/about-accessing-vpc-hosted-services-endpoints).

1. In the Google Cloud console, go to the [Private Service Connect](https://console.cloud.google.com/net-services/psc) page.
2. On the **Connected endpoints** tab, click **Connect endpoint**.

   For details of the process, see [Access published services through endpoints](https://cloud.google.com/vpc/docs/configure-private-service-connect-services).
3. Specify the following values:
   * **Target**: Select **Published service**.
   * **Target service**: Enter the **Service Attachment URI** from
     [Create an Ingress Private Service Connect Gateway in Confluent Cloud](#usm-gcp-gate). You can also use the value from the **Network
     overview** of the gateway in the Confluent Cloud Console.
   * **Endpoint name**: A name for the Private Service Connect endpoint.
   * **Network**: The VPC network where the endpoint is created.
   * **Subnetwork**: A subnet in the same region as your gateway. Subnets are
     regional resources in Google Cloud.
   * **IP address**: The IP address to assign to the endpoint. Note this
     address because you use it when you set up DNS resolution.
4. Click **Add endpoint**.
5. After the endpoint is created, note the **Connection ID** of the endpoint.
   You use this value in the next step.

Even if the endpoint shows as accepted in Google Cloud, you must still create an access
point for it in Confluent Cloud. Without the access point, requests to Confluent Cloud are
dropped.

<a id="usm-gcp-access"></a>

## Create an Ingress Private Service Connect Access Point

Return to Confluent Cloud and create an access point resource.
An access point represents a Private Service Connect endpoint in your VPC.

You don’t need to provide the service attachment. Confluent checks which
service attachment is associated with the gateway that has a pending endpoint
with the given connection ID.

### Confluent Cloud Console

1. In the **Access points** tab, click **Create access point**.
   1. [Create a Private Service Connect endpoint in Google Cloud](#usm-gcp-endpoint) using
      the Service Attachment URI shown on the sliding panel.
   2. In **Private Service Connect connection ID**, specify the
      connection ID of the endpoint you created in the previous step.
   3. In the **Access point name** field, enter a name for the access point.
   4. Click **Create access point**.

      After the endpoint connection is accepted, the statuses for the gateway and the access point change to `READY`.

### Confluent REST API

1. Send a request to create an access point resource:

   **REST request**
   ```rest
   POST https://api.confluent.cloud/networking/v1/access-points
   ```

   **REST request body**
   ```json
   {
     "spec": {
       "display_name": "<A custom name for the access point>",
       "config": {
         "kind": "GcpIngressPrivateServiceConnectEndpoint",
         "private_service_connect_connection_id": "<The Google Cloud ID of your Private Service Connect endpoint>"
       },
       "environment": {
         "id": "<The ID of the environment that has the gateway for this access point>"
       },
       "gateway": {
         "id": "<The ID of the gateway to add the access point to>"
       }
     }
   }
   ```

   For more information, see [Access Points](https://docs.confluent.io/cloud/current/api.html#tag/Access-Points-(networkingv1))
   in the Confluent REST API reference.

### Confluent CLI

Use the following Confluent CLI command to create an access point:

```bash
confluent network access-point private-link ingress-endpoint create <access-point-name> <flags>
```

The following command-specific flags are supported:

* `--cloud`: Required. The cloud provider. Set to `gcp`.
* `--gateway`: Required. The ID of the gateway to add the access point to.
* `--psc-connection-id`: Required. The Google Cloud ID of your Private Service
  Connect endpoint.

For more information, see [confluent network access-point private-link ingress-endpoint create](https://docs.confluent.io/confluent-cli/current/command-reference/network/access-point/private-link/ingress-endpoint/confluent_network_access-point_private-link_ingress-endpoint_create.html).

The following is an example Confluent CLI command to create an access point:

```bash
confluent network access-point private-link ingress-endpoint create my-ingress-access-point \
  --cloud gcp \
  --gateway gw-123abc \
  --psc-connection-id 1234567890123456
```

### Terraform

Use the [confluent_access_point](https://registry.terraform.io/providers/confluentinc/confluent/latest/docs/resources/confluent_access_point)
resource from the Confluent Terraform Provider to create an access point.

An example snippet of Terraform configuration for an access point:

```terraform
resource "confluent_access_point" "gcp_ingress_1" {
  display_name = "my_access_point"
  environment {
    id = "env-123abc"
  }
  gateway {
    id = "gw-123abc"
  }
  gcp_ingress_private_service_connect_endpoint {
    private_service_connect_connection_id = "1234567890123456"
  }
  depends_on = [
    confluent_gateway.gcp_ingress
  ]
}
```

In the Google Cloud console, go to the Private Service Connect endpoint and verify that
the connection status is **Accepted**.

#### IMPORTANT
If you delete the Private Service Connect endpoint that you created in Google Cloud,
also delete the corresponding access point in Confluent Cloud. Google Cloud can reuse the
connection ID, which creates a security risk if the access point remains.

<a id="usm-gcp-dns"></a>

## Set up DNS resolution

Confluent Cloud requires that you set up private DNS records for each access point
pointing its DNS domain to the Private Service Connect endpoint you created.

For access points, when connecting to Confluent Cloud using access-point-specific
hostnames, you must allow public DNS resolution from your network or VPC.
Confluent Cloud advertises these hostnames in the public DNS resolver, and these
hostnames then redirect to match the domains that you input to your private
DNS resolver.

DNS resolution happens in two steps:

1. The Confluent Cloud Global DNS Resolver returns a CNAME for your hostnames,
   removing the `glb` subdomain and converting your access point ID to be a
   subdomain.

   For example, with the given hostname:
   ```text
   api-<accessPointId>.<region>.gcp.accesspoint.glb.confluent.cloud
   ```

   The CNAME returned is:
   ```text
   api.<accessPointId>.<region>.gcp.accesspoint.confluent.cloud
   ```
2. The CNAME then resolves to your Private Service Connect endpoint based on
   the private DNS configuration.

To use Cloud DNS as your private DNS resolver:

1. In Confluent Cloud, verify that the status of the gateway is `READY`.
2. In Confluent Cloud, open the newly created gateway to get the DNS domain value of
   Confluent Cloud.

   Take the FrontDoor URL shown in the Confluent Cloud Console and remove `.glb`
   and the `api-` prefix. Use the resulting
   `<accessPointId>.<region>.gcp.accesspoint.confluent.cloud` as the
   **DNS name** for your Cloud DNS private zone.

   For example, if the FrontDoor URL is
   `api-ap123.us-central1.gcp.accesspoint.glb.confluent.cloud`,
   the Cloud DNS name is
   `ap123.us-central1.gcp.accesspoint.confluent.cloud`.
3. In the [Cloud DNS](https://console.cloud.google.com/net-services/dns/zones)
   page in the Google Cloud console, create a private zone with the following settings:
   1. Click **Create zone**.
   2. Specify the following values:
      * **Zone type**: Select **Private**.
      * **Zone name**: A name for this DNS zone.
      * **DNS name**: Enter the Confluent Cloud DNS domain value that you copied in the previous step.
      * **Networks**: Select the VPC networks where clients or applications are present.
   3. Click **Create**.
4. Create a DNS record for the zone you created in the previous step.

   This record is regional DNS and is used for all the target Confluent Cloud resources
   in the region.
   1. Go to the DNS zone you created, and in the **Record sets** section, click **Add standard**.
   2. Specify the following values:
      * **DNS name**: `*`

        Enter `*` as the subdomain name.

        If you are creating DNS resolution for Schema Registry for a single VPC connecting
        to several Schema Registry clusters in the same region across different
        environments, enter the id of the Schema Registry, `lsrc-xxxxx` to connect to a
        specific Schema Registry.
      * **Resource record type**: Select `A`.
      * **TTL** and **TTL unit**: `1` `Minutes`.
      * **IPv4 address**: Enter the IP address that you assigned to the Private
        Service Connect endpoint in [Create a Private Service Connect endpoint in Google Cloud](#usm-gcp-endpoint).

      #### NOTE
      In Confluent Cloud with private linking, Kafka broker names you retrieve from the
      metadata are not static. Do not hardcode the broker names in DNS records.
   3. Click **Create**.
5. Verify that the private zone is in use by the VPC networks where the
   USM Agent runs.

## What’s next

* [Configure a Service Account for the USM Agent](usm-service-account.md#usm-sa)

## Related content

* [Unified Stream Manager in Confluent Cloud](../overview.md#cloud-usm-overview)
* [Register Your Confluent Platform Cluster](overview.md#cloud-usm-register)
* [Set Up a Payment Method](payment-method.md#usm-payment)
* [Configure AWS Private Networking for USM Agents](usm-network.md#usm-network)
* [Configure Azure Private Networking for USM Agents](usm-network-azure.md#usm-network-azure)
* [Configure a Service Account for the USM Agent](usm-service-account.md#usm-sa)
* [Deploy the USM Agent](deploy-agent.md#usm-agent)
* [Complete the Cluster Registration](complete-registration.md#complete-registration)
