0

我需要使用 GKE 集群的域来访问集群和应用程序的入口,类似于 azure AKS http 插件,它提供了一个通用创建的域(不是自定义域) https://docs.microsoft.com/en -us/azure/aks/http-application-routing 谷歌云上也有解决方案吗?

我们的 GKE 创建/删除流程是 IaC 工具的一部分,我们正在自动化集群和我们的开发/测试/暂存应用程序部署。通用域创建和将托管 dns 区域绑定到集群资源为我们提供了极大的灵活性。否则,我们必须创建自定义域和托管 dns 区域,它们将是静态的,并给配置工具带来不必要的复杂性。

4

2 回答 2

0
于 2020-12-11T15:01:42.330 回答
0

There is not generic domain options in gke so I have to purchase a domain and update NS according to created managed dns zone NS and they will be automated sync when I update ingress in gke by external-dns

I can say I solve this problem with this steps,

1- Create a managed zone which has domain name belongs own and be sure it has permission to access domain from dns zones which you create. Mean is giving access the google project which your dns zone exist

Note: when you create the cluster be sure giving scopes for readwrite perm for managed dns zone

gcloud container clusters create “external-dns” \
    —num-nodes 1 \
    —scopes “https://www.googleapis.com/auth/ndev.clouddns.readwrite

Create a DNS zone which will contain the managed DNS records.

$ gcloud dns managed-zones create “xxx.test-dev” \
    —dns-name “xxx.test.dev.” \
    —description “Automatically managed zone by kubernetes.io/external-dns test.dev domain name”

2- Please deploy the resources to gke which name is external-dns

https://github.com/kubernetes-sigs/external-dns/blob/master/docs/tutorials/gke.md#deploy-externaldns

And check the logs with

kubectl logs $(kubectl get pods --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}' | grep dns)

Or

kubectl logs $(kubectl get pods --no-headers -o custom-columns=":metadata.name" | grep dns)

And if you see something like everything is going smoothly

time="2021-01-20T11:37:46Z" level=info msg="Add records: xxx.test.dev. A [34.89.xx.xx] 300"
time="2021-01-20T11:37:46Z" level=info msg="Add records: xxx.test.dev. TXT [\"heritage=external-dns,external-dns/owner=my-identifier,external-dns/resource=ingress/default/ingress-test\"] 300"
time="2021-01-20T11:38:47Z" level=info msg="All records are already up to date"

Note created TXT record alongside A record. TXT record signifies that the corresponding A record is managed by ExternalDNS. This makes ExternalDNS safe for running in environments where there are other records managed via other means. Let’s check that we can resolve this DNS name. We’ll ask the nameservers assigned to your zone first.

$ dig +short @ns-cloud-e1.googledomains.com. xxx.test.dev.
104.155.xx.xx

And you can check the ip of the domain is correct or has a problem

host https://xxx.test.dev/        
Host https://xxx.test.dev/ not found: 3(NXDOMAIN)

It can be complained bed domain for a while but then you will get the correct response

host xxx.test.dev
xxx.test.dev has address 35.197.xx.xx
于 2021-01-20T15:59:53.940 回答