Hello Everyone,
We have a situation wherein the CloudBuild private pool is not able to reach the Private Cloud DNS Zone.
Description of the environment-
A cloudbuild private worker pool is configured to run builds as per triggers configured in cloudbuild. The worker pool has a ip range of 10.193.164.0/22. The subnet is connected to a VPC network using Private Service Connection. A VM is hosted on the same VPC network which exposes couple of APIs. There is a private DNS zone setup in Cloud DNS which provides the DNS resolution for the network.
Issue-
CloudBuild private pool is able to access the API exposed by the VM using the ip address of the VM. However, when the hostname is used, the DNS resolution fails and cloudbuild worker pool is unable to access the VM.
Ask-
Is there a way to configure Cloud Build private pool so that it can leverage Cloud DNS to resolve the VM name?
Thank You,
Diganta Koner
Solved! Go to Solution.
@digantakoner Thank you for the information. I have tested it with the following terraform code example, and it works. The private cloudBiuld worker can use my private DNS zone and is able to connect to the VMs in my VPC network.
## Uncomment this block after adding a valid DNS suffix # resource "google_service_networking_peered_dns_domain" "default" { # name = "example-com" # network = google_compute_network.peering_network.name # dns_suffix = "example.com." # service = "servicenetworking.googleapis.com" # }
Here are the cloud build trigger steps I tested for the connection.
steps:
- name: gcr.io/cloud-builders/git
args:
- '-c'
- |
apt-get update
apt-get install dnsutils -y
echo "dig test.example.com ..."
dig test.example.com
curl test.example.com
id: check the private DNS zone and the private connection
entrypoint: bash
options:
workerPool: >-
projects/myporject/locations/us-east4/workerPools/myproject-mynetwork-cloud-build-worker-pool