在 GCP 中指向并使用子域 [英] Point and use a subdomain in GCP

查看:18
本文介绍了在 GCP 中指向并使用子域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 AWS 上的 Route 53 中设置了一个主域 www.example.com.

I have a primary domain www.example.com setup in Route 53 on AWS.

我想将 subdomain1.example.com 指向 Google Cloud,特别是指向在 Google Compute Engine 中运行的实例组.

I want to point subdomain1.example.com to Google Cloud, specifically to an instance group running in Google Compute Engine.

这可能吗?

推荐答案

是的,这是一个很好的设计实践,称为名称服务委托.最好的方法是为 GCP 委派整个子域,因此让我们使用域 example.com 和 gcp.example.com 作为域和子域.

Yes, and this is a good design practice called nameservice delegation. The best approach is to delegate an entire subdomain for GCP, so let's use the domain example.com and gcp.example.com as the domain and subdomain.

通过这种方式,Google 将为您管理 DNS,而不是您更新 A &手动在 route53 中记录 CNAME.

This way Google will manage DNS for you rather than you updating A & CNAME records in route53 manually.

总的来说,这将采取以下步骤 (1) 在 GCP 中创建 gcp.example.com 区域 (2) 获取 gcp.example.com 的 NS 记录(3) 将 gcp.example.comNS 委托给 Google Cloud NS,然后 (4) 在 GCP 中创建资源级记录(例如,对于 VM 或 appengine 应用程序)云DNS.

Overall this will take these steps (1) creating the gcp.example.com zone in GCP (2) obtaining the NS records for gcp.example.com (3) delegating NS for gcp.example.com to Google Cloud NS and then (4) Create the resource-level records (e.g. for a VM or appengine app) in GCP Cloud DNS.

(1) 在 GCP 中创建区域

这可以在网络服务->下的控制台中完成;Cloud DNS 或云外壳.我喜欢贝壳.

This can be done in the console under Network Services -> Cloud DNS or the cloud shell. I favor the shell.

$ gcloud dns managed-zones create gcp-example --description="GCP Example Zone" \
      --dns-name="gcp.example.com"

(2) 获取新区的 NS 记录

下面是一个例子——复制特定于你的 NS 的那些

Below is an example -- copy the ones specific to your NS

gcloud dns managed-zones describe gcp-example |grep -A5 nameServers
nameServers:
- ns-cloud-d1.googledomains.com.
- ns-cloud-d2.googledomains.com.
- ns-cloud-d3.googledomains.com.
- ns-cloud-d4.googledomains.com.

(3)在AWS中添加delegate NS记录

创建update.json(确保值记录正确):

create update.json (make sure the value records are correct):

{
            "Comment": "CREATE/DELETE/UPSERT a record ",
            "Changes": [{
            "Action": "CREATE",
                        "ResourceRecordSet": {
                                    "Name": "gcp.example.com",
                                    "Type": "NS",
                                    "TTL": 300,
                                 "ResourceRecords": [ {"Value" : "ns-cloud-d1.googledomains.com."}, {"Value": "ns-cloud-d2.googledomains.com."},
                                     {"Value" : "ns-cloud-d3.googledomains.com."}, {"Value": "ns-cloud-d4.googledomains.com."}]
}}]
}

HOSTED_ZONE_ID=XXXXXX
aws route53 change-resource-record-sets --hosted-zone-id=${HOSTED_ZONE_ID} --change-batch=file://./update.json
{
    "ChangeInfo": {
        "Status": "PENDING",
        "Comment": "CREATE/DELETE/UPSERT a record ",
        "SubmittedAt": "2019-02-27T23:43:35.327Z",
        "Id": "/change/XXXXXX"
    }
}

(4) 在 GCP Cloud DNS 中,在 gcp.example.com

此时,您可以在 GCP Cloud DNS 中管理所有 GCP dns.继续创建 vm1.gcp.example.comappengine1.gcp.example.com

At this point, you can manage all of your GCP dns within GCP Cloud DNS. Go ahead and create vm1.gcp.example.com or appengine1.gcp.example.com

这篇关于在 GCP 中指向并使用子域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆