4.7. 在 Google Cloud 上创建 DNS 记录
您可以使用 External DNS Operator 在 Google Cloud 上创建 DNS 记录。
不支持在启用了 Google Cloud Workload Identity 的集群上使用 External DNS Operator。有关 Google Cloud Workload Identity 的更多信息,请参阅 Google Cloud Workload Identity。
4.7.1. 在 Google Cloud 公共管理区上创建 DNS 记录 复制链接链接已复制到粘贴板!
您可以使用 External DNS Operator 在 Google Cloud 公共管理区上创建 DNS 记录。
先决条件
- 您必须具有管理员特权。
流程
运行以下命令,将
gcp-credentialssecret 复制到encoded-gcloud.json文件中:$ oc get secret gcp-credentials -n kube-system --template='{{$v := index .data "service_account.json"}}{{$v}}' | base64 -d - > decoded-gcloud.json运行以下命令导出 Google 凭证:
$ export GOOGLE_CREDENTIALS=decoded-gcloud.json使用以下命令激活您的帐户:
$ gcloud auth activate-service-account <client_email as per decoded-gcloud.json> --key-file=decoded-gcloud.json运行以下命令来设置项目:
$ gcloud config set project <project_id as per decoded-gcloud.json>运行以下命令来获取路由列表:
$ oc get routes --all-namespaces | grep console输出示例
openshift-console console console-openshift-console.apps.test.gcp.example.com console https reencrypt/Redirect None openshift-console downloads downloads-openshift-console.apps.test.gcp.example.com downloads http edge/Redirect None运行以下命令,获取受管区域的列表,如
qe-cvs4g-private-zone test.gcp.example.com:$ gcloud dns managed-zones list | grep test.gcp.example.com创建一个 YAML 文件,如
external-dns-sample-gcp.yaml,该文件定义ExternalDNS对象:external-dns-sample-gcp.yaml文件示例apiVersion: externaldns.olm.openshift.io/v1beta1 kind: ExternalDNS metadata: name: sample-gcp1 spec: domains: - filterType: Include2 matchType: Exact3 name: test.gcp.example.com4 provider: type: GCP5 source: openshiftRouteOptions:6 routerName: default7 type: OpenShiftRoute8 运行以下命令,检查为 OpenShift Container Platform 路由创建的 DNS 记录:
$ gcloud dns record-sets list --zone=qe-cvs4g-private-zone | grep console