17.6. Google Cloud での DNS レコードの作成
外部 DNS Operator を使用して、Google Cloud で DNS レコードを作成できます。
Google Cloud Workload Identity が有効になっているクラスターで外部 DNS Operator を使用することはサポートされていません。Google Cloud Workload Identity の詳細は、Google Cloud Workload Identity での 手動モードの使用 を 参照してください。
17.6.1. Google Cloud のパブリックマネージドゾーンでの DNS レコードの作成 リンクのコピーリンクがクリップボードにコピーされました!
外部 DNS Operator を使用して、Google Cloud のパブリック管理ゾーンに DNS レコードを作成できます。
前提条件
- 管理者権限を持っている。
手順
次のコマンドを実行して、
encoded-gcloud.jsonファイル内のgcp-credentialsシークレットをコピーします。$ 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次のコマンドを実行して、マネージドゾーンのリストを取得します。
$ gcloud dns managed-zones list | grep test.gcp.example.com出力例
qe-cvs4g-private-zone test.gcp.example.comExternalDNSオブジェクトを定義する YAML ファイル (例:external-dns-sample-gcp.yaml) を作成します。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 - 1
- 外部 DNS 名を指定します。
- 2
- デフォルトでは、すべてのホストされたゾーンがターゲット候補として選択されます。ホストされたゾーンを含めることができます。
- 3
- ターゲットのドメインは、
nameキーで定義された文字列と一致する必要があります。 - 4
- 更新するゾーンのドメインを正確に指定します。ルートのホスト名は、指定されたドメインのサブドメインである必要があります。
- 5
- プロバイダータイプを定義します。
- 6
- DNS レコードのソースのオプションを定義できます。
- 7
- ソースタイプが
OpenShiftRouteの場合、OpenShift Ingress Controller 名を渡すことができます。外部 DNS は、CNAME レコードの作成時に、そのルーターの正規のホスト名をターゲットとして選択します。 - 8
routeリソースを Google Cloud DNS レコードのソースとして定義します。
次のコマンドを実行して、OpenShift Container Platform ルートに対して作成された DNS レコードを確認します。
$ gcloud dns record-sets list --zone=qe-cvs4g-private-zone | grep console