Private Service Connect interface is recommended for private connectivity since it reduces the chance of IP exhaustion and allows for transitive peering.
Private Service Connect interface is supported on Vertex AI custom jobs and persistent resources.
Overview
Private Service Connect interface is supported on Vertex AI Training custom jobs and persistent resources. To use Private Service Connect interface, you need to set up a VPC network, subnetwork, and network attachment in your user project. See Set up a Private Service Connect interface. The network attachment name must be included in the request to create a custom job or persistent resource to enable Private Service Connect interface.
Vertex AI Private Service Connect egress connectivity to other networks
Vertex AI has integrated the egress network connectivities that are supported by Private Service Connect (see Connecting to workloads in other networks), with the following exceptions:
Egress to a customer's Private Google Access isn't supported. Instead Private Service Connect egress would resolve locally for Private Google Access.
Egress to Cloud NAT is supported only when VPC Service Control is enabled.
Limitations
Private Service Connect interfaces don't support external IP addresses.
Network attachments can't be deleted unless the producer (Vertex AI) deletes the allocated resources. To initiate the delete process, you must contact Vertex AI support.
Pricing
Pricing for Private Service Connect interfaces is described in the "Using a Private Service Connect interface for access to a producer or consumer VPC network" section in the All networking pricing page.
Before you begin
Set up your resources for Private Service Connect interface on your user project.
Create a custom training job with a Private Service Connect interface
You can create a custom training job with Private Service Connect interface by using the Vertex AI SDK for Python or the REST API.
Python
To create a custom training job with PSC-I using the Vertex AI SDK for Python, configure
the job using the aiplatform_v1beta1/services/job_service
definition.
Python
project
: Your project ID. You can find these IDs in the Google Cloud console welcome page.location
: See list of available locations.bucket
: Replacebucket
with the name of a bucket you have access to.display_name
: The display name of the persistent resource.machine_type
: Specify the compute resources.replica_count
: The number of worker replicas to use for each trial.service_attachment
: The name of the service attachment resource. Populated if Private Service Connect is enabled.image_uri
: The URI of a Docker container image with your training code. Learn how to create a custom container image.network_attachment
: The name or full path of the network attachment you created when setting up your resources for Private Service Connect.
REST
To create a custom training job, send a POST request by using the customJobs.create method.
Before using any of the request data, make the following replacements:
- LOCATION: The region where the container or Python package will be run.
- PROJECT_ID: Your project ID.
- JOB_NAME: A display name for the
CustomJob
. - REPLICA_COUNT: The number of worker replicas to use. In most cases,
set this to
1
for your first worker pool. - If your training application runs in a custom container, specify the following:
- IMAGE_URI: the URI of a Docker container image with your training code. Learn how to create a custom container image.
- NETWORK_ATTACHMENT: The name or full path of the network attachment you created when you set up the Private Service Connect interface.
HTTP method and URL:
POST https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/customJobs
Request JSON body:
"display_name": JOB_NAME, "job_spec": { "worker_pool_specs": [ { "machine_spec": { "machine_type": "n1-standard-4", }, "replica_count": REPLICA_COUNT, "container_spec": { "image_uri": IMAGE_URI, }, }, ], "psc_interface_config": { "network_attachment": NETWORK_ATTACHMENT }, "enable_web_access": 1 }
To send your request, choose one of these options:
curl
Save the request body in a file named request.json
,
and execute the following command:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/customJobs"
PowerShell
Save the request body in a file named request.json
,
and execute the following command:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/customJobs" | Select-Object -Expand Content
You should receive a JSON response similar to the following: