我正在尝试使用带有私有池的云构建来在 gitlab 自托管实例上运行构建。全部都在同一个 VPC 中,但我的云构建在触发时无法解析 gitlab 实例的主机,尽管位于同一网络中。
错误:无法解析主机“主机名”
有任何建议或需要任何信息请告诉。
尝试使用托管在同一 VPC 中的云构建私有池。
您可以使用以下 Terraform 代码添加或设置 DNS 对等互连,以使 DNS 可供服务生产者使用。
## 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"
# }
这样,您的私有云构建工作人员就可以使用私有云 DNS 区域,并且服务项目中的 VM 实例可以使用私有连接。
对于云构建触发器,您可以按照以下步骤操作:
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 private DNS zone and the private connection
entrypoint: bash
options:
workerPool: >-
projects/WORKERPOOL_PROJECT_ID/locations/REGION/workerPools/WORKERPOOL_ID
希望它有效!