0

尝试为我的域更新托管区域资源记录类型 A 的外部 IP 时使用命令行 Google Cloud DNS 时出错...使用基于浏览器的 gce 控制台可以正常工作...在部署我的应用程序时使用英语使用 Kubernetes,它给了我一个新的 IP,我需要链接到我现有的域 DNS,这样人们就可以访问我的应用程序,将他们的浏览器指向我的域(example.com)......问题是每次我重新部署时都需要执行此操作我的应用程序因此需要自动化

注意 - Cloud DNS 区域已经存在并且可以正常工作。我正在尝试更新外部 IP 地址以匹配新的 Kubernetes 部署的 LoadBalancer Ingress

kubectl describe svc --namespace=ruptureofthemundaneplane | grep Ingress
LoadBalancer Ingress:   104.196.108.178

这是当前状态

gcloud dns record-sets list --zone  zone-cubalibre --project ruptureofthemundaneplane 
NAME                           TYPE   TTL  DATA
example.com.            A      60   104.196.108.147
example.com.            NS     60   ns-cloud-a1.googledomains.com.,ns-cloud-a2.googledomains.com.,ns-cloud-a3.googledomains.com.,ns-cloud-a4.googledomains.com.
example.com.            SOA    60   ns-cloud-a1.googledomains.com. cloud-dns-hostmaster.google.com. 1 21600 3600 1209600 300
admin.example.com.      CNAME  60   example.com.
www.admin.example.com.  CNAME  60   example.com.
www.example.com.        CNAME  60   example.com.

这里只是 A 类记录

gcloud dns record-sets list    --project ruptureofthemundaneplane   --zone zone-cubalibre   --name "example.com." --type "A"
NAME                 TYPE  TTL  DATA
example.com.  A     60   104.196.108.147

我需要用新值 104.196.108.178 替换 IP 104.196.108.147 ...所以我发出

gcloud dns record-sets transaction start --zone zone-cubalibre  --project ruptureofthemundaneplane 

在这里,我使用我的新 IP 地址添加交易

gcloud dns record-sets transaction add  "104.196.108.178"  --name "example.com." --ttl 60 --type "A"  --project ruptureofthemundaneplane   --zone zone-cubalibre 

这是系统生成的yaml文件

cat transaction.yaml 
---
additions:
- kind: dns#resourceRecordSet
  name: example.com.
  rrdatas:
  - ns-cloud-a1.googledomains.com. cloud-dns-hostmaster.google.com. 2 21600 3600 1209600
    300
  ttl: 60
  type: SOA
- kind: dns#resourceRecordSet
  name: example.com.
  rrdatas:
  - 104.196.108.178
  ttl: 60
  type: A
deletions:
- kind: dns#resourceRecordSet
  name: example.com.
  rrdatas:
  - ns-cloud-a1.googledomains.com. cloud-dns-hostmaster.google.com. 1 21600 3600 1209600
    300
  ttl: 60
  type: SOA

为了完整起见,我要求系统显示事务缓存

gcloud dns record-sets transaction  describe     --project ruptureofthemundaneplane   --zone zone-cubalibre  

... 输出

additions:
- kind: dns#resourceRecordSet
  name: example.com.
  rrdatas:
  - ns-cloud-a1.googledomains.com. cloud-dns-hostmaster.google.com. 2 21600 3600 1209600
    300
  ttl: 60
  type: SOA
- kind: dns#resourceRecordSet
  name: example.com.
  rrdatas:
  - 104.196.108.178
  ttl: 60
  type: A
deletions:
- kind: dns#resourceRecordSet
  name: example.com.
  rrdatas:
  - ns-cloud-a1.googledomains.com. cloud-dns-hostmaster.google.com. 1 21600 3600 1209600
    300
  ttl: 60
  type: SOA

最后我用这个提交交易

gcloud dns record-sets transaction execute    --project ruptureofthemundaneplane    --zone zone-cubalibre 
ERROR: (gcloud.dns.record-sets.transaction.execute) 
The resource 'entity.change.additions[1]' named 'example.com. (A)' already exists (code: 409)

有什么建议么 ?我想避免预定义静态 IP,因为它不可扩展…… 当我在 aws 上使用 kube-up.sh 进行部署时,等效的 Amazon aws 命令可以工作……如果 kubernetes 在其所有云中实现了通用解决方案,那将是一个不错的选择主机供应商......人们是否使用其他一些自动化手段来实现这一目标?lang x 中的一些 SDK 库?

4

1 回答 1

3

Cloud DNS 操作适用于整个 RRrecord-setdns#resourceRecordSet),而不是单个 RR。即使在后一种情况下,您的示例也不会做您想要的,因为您最终会得到一个包含旧 IP 地址和新 IP 地址的 RRset,这只会“大部分工作”。

无论如何,它记录,并且每个 RTYPE 只允许一个 RRset,因此您的事务需要先删除现有的ARRset,然后添加新的 RRset。

于 2016-07-15T14:40:37.683 回答