This is a cache of https://docs.okd.io/4.19/networking/networking_operators/external_dns_operator/nw-creating-dns-records-on-gcp.html. It is a snapshot of the page at 2026-02-14T20:34:00.429+0000.
Creating <strong>dns</strong> records on Google Cloud - Networking Operators | Networking | OKD 4.19
×

To create dns records on Google Cloud, use the External dns Operator. The dns Operator manages external name resolution for your cluster services.

Using the External dns Operator on a cluster with Google Cloud Workload Identity enabled is not supported. For more information about the Google Cloud Workload Identity, see Google Cloud Workload Identity.

Creating dns records on a public managed zone for Google Cloud

To create dns records on Google Cloud, use the External dns Operator. The dns Operator manages external name resolution for your cluster services.

Prerequisites
  • You must have administrator privileges.

Procedure
  1. Copy the gcp-credentials secret in the encoded-gcloud.json file by running the following command:

    $ oc get secret gcp-credentials -n kube-system --template='{{$v := index .data "service_account.json"}}{{$v}}' | base64 -d - > decoded-gcloud.json
  2. Export your Google credentials by running the following command:

    $ export GOOGLE_CREDENTIALS=decoded-gcloud.json
  3. Activate your account by using the following command:

    $ gcloud auth activate-service-account  <client_email as per decoded-gcloud.json> --key-file=decoded-gcloud.json
  4. Set your project by running the following command:

    $ gcloud config set project <project_id as per decoded-gcloud.json>
  5. Get a list of routes by running the following command:

    $ oc get routes --all-namespaces | grep console
    Example output
    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
  6. Get a list of managed zones, such as qe-cvs4g-private-zone test.gcp.example.com, by running the following command:

    $ gcloud dns managed-zones list | grep test.gcp.example.com
  7. Create a YAML file, for example, external-dns-sample-gcp.yaml, that defines the Externaldns object:

    Example external-dns-sample-gcp.yaml file
    apiVersion: externaldns.olm.openshift.io/v1beta1
    kind: Externaldns
    metadata:
      name: sample-gcp
    spec:
      domains:
        - filterType: Include
          matchType: Exact
          name: test.gcp.example.com
      provider:
        type: GCP
      source:
        openshiftRouteOptions:
          routerName: default
        type: OpenShiftRoute
    # ...

    where:

    metadata.name

    Specifies the External dns name.

    spec.domains.filterType

    By default, all hosted zones are selected as potential targets. You can include your hosted zone.

    spec.domains.matchType

    Specifies the domain of the target that must match the string defined by the name key.

    spec.domains.name

    Specifies the exact domain of the zone you want to update. The hostname of the routes must be subdomains of the specified domain.

    spec.provider.type

    Specifies the provider type.

    source.openshiftRouteOptions

    Specifies options for the source of dns records.

    openshiftRouteOptions.routerName

    If the source type is OpenShiftRoute, you can pass the OpenShift Ingress Controller name. External dns selects the canonical hostname of that router as the target while creating a CNAME record.

    type

    Specifies the route resource as the source for Google Cloud dns records.

  8. Check the dns records created for OKD routes by running the following command:

    $ gcloud dns record-sets list --zone=qe-cvs4g-private-zone | grep console