Skip to content

K8GB with Google Cloud DNS - Example

This example demonstrates how to configure K8GB with Google Cloud DNS across two GKE clusters in different regions.

📖 For detailed setup instructions, architecture explanation, and troubleshooting, see Google Cloud DNS Provider Documentation

Quick Overview

This example deploys K8GB across two GKE clusters: - Primary cluster: europe-west1 (failover primary) - Secondary cluster: us-central1 (failover secondary) - DNS Zone: gcp-test.k8gb.io (load-balanced zone hosted by CoreDNS) - Parent Zone: k8gb.io (Cloud DNS managed zone for delegation)

Prerequisites

  1. Two GKE clusters in different regions with Workload Identity enabled:
  2. Standard GKE (manual): Enable --workload-pool=<PROJECT_ID>.svc.id.goog on the cluster and --workload-metadata=GKE_METADATA on the node pool.
  3. Autopilot GKE: Node-pool metadata is managed automatically (do not run node-pools update), but verify --workload-pool=<PROJECT_ID>.svc.id.goog is set on the cluster.
  4. A Cloud DNS managed zone. Enable dns.googleapis.com in the DNS project and iamcredentials.googleapis.com for the Workload Identity setup. See the Cloud DNS prerequisites.
  5. A Google service account with roles/dns.admin in the DNS project. On that Google service account, grant roles/iam.workloadIdentityUser to serviceAccount:<GKE_PROJECT_ID>.svc.id.goog[k8gb/k8gb-external-dns] for each GKE project. See the Workload Identity setup.

Deployment

  1. Deploy K8GB on the first cluster:

    # Configure kubectl for europe-west1 cluster
    gcloud container clusters get-credentials my-cluster-eu \
      --region=europe-west1 --project=my-gke-project
    
    # Install K8GB
    helm upgrade --install k8gb k8gb/k8gb \
      --namespace=k8gb --create-namespace \
      --values=k8gb-cluster-gcp-europe-west1.yaml
    

  2. Deploy K8GB on the second cluster:

    # Configure kubectl for us-central1 cluster
    gcloud container clusters get-credentials my-cluster-us \
      --region=us-central1 --project=my-gke-project
    
    # Install K8GB
    helm upgrade --install k8gb k8gb/k8gb \
      --namespace=k8gb --create-namespace \
      --values=k8gb-cluster-gcp-us-central1.yaml
    

  3. Deploy test application and GSLB resources:

    # Create test namespace (do this on both clusters)
    kubectl apply -f ../../../deploy/gslb/test-namespace-ingress.yaml
    
    # Deploy podinfo via Helm (do this on both clusters)
    helm repo add podinfo https://stefanprodan.github.io/podinfo
    helm upgrade --install frontend --namespace test-gslb \
      -f ../../../deploy/test-apps/podinfo/podinfo-values.yaml \
      --set ui.message="$(kubectl config current-context)" \
      podinfo/podinfo --version 6.9.2
    
    # Apply GSLB configurations (do this on both clusters)
    kubectl apply -f test-gslb-failover.yaml
    kubectl apply -f test-gslb-roundrobin.yaml
    

Configuration Files

This example includes: - k8gb-cluster-gcp-europe-west1.yaml - Configuration for EU cluster - k8gb-cluster-gcp-us-central1.yaml - Configuration for US cluster - test-gslb-failover.yaml - Failover strategy example - test-gslb-roundrobin.yaml - Round-robin strategy example

Key Configuration Notes

  • Workload Identity: Configured by default in the example YAML files
  • Static Credentials: Commented out alternative (uncomment env/volumes sections if needed)
  • Cross-Project Setup: Use extraArgs.google-project if DNS zone is in a different project
  • Geo Tags: Must be unique per cluster (europe-west1, us-central1)
  • TXT Ownership: Each cluster needs unique txtPrefix and txtOwnerId

See provider_gcp.md for detailed configuration parameters.

Verification

# Check K8GB status
kubectl get gslb -n test-gslb
kubectl describe gslb test-gslb-failover -n test-gslb

# Verify NS delegation records in Cloud DNS
gcloud dns record-sets list --zone="k8gb-io" --filter="name~'gcp-test.k8gb.io'"

# Test DNS resolution
nslookup failover.gcp-test.k8gb.io 8.8.8.8
nslookup roundrobin.gcp-test.k8gb.io 8.8.8.8

For detailed verification steps and troubleshooting, see: - Verification - Troubleshooting

Common GKE Gotchas

  • k8gb-coredns LoadBalancer stuck <pending> (LoadBalancerMixedProtocolNotSupported): The mixed TCP/UDP Service requires GKE 1.34.1-gke.2190000 or later and the HttpLoadBalancing add-on. Before 1.36.2-gke.1498000, mixed-protocol load balancing supports IPv4 external load balancers only. See the GKE requirements.
  • The examples set coredns.service.loadBalancerClass to networking.gke.io/l4-regional-external at install time. Recreate an existing target-pool Service to switch to this class.
  • For a temporary UDP-only smoke test, confirm that port index 1 is TCP before applying the patch below (TCP queries to the Service will time out):
    kubectl patch svc k8gb-coredns -n k8gb --type=json -p='[{"op":"remove","path":"/spec/ports/1"}]'
    
  • ACCESS_TOKEN_SCOPE_INSUFFICIENT in k8gb-external-dns logs:
  • Standard GKE: Ensure --workload-pool=<PROJECT_ID>.svc.id.goog is set on the cluster and --workload-metadata=GKE_METADATA is set on the node pool.
  • Autopilot GKE: Ensure --workload-pool=<PROJECT_ID>.svc.id.goog is set on the cluster (do not update node pools).
  • Verify k8gb-external-dns ServiceAccount has iam.gke.io/gcp-service-account=<GSA_EMAIL> and restart deployment/k8gb-external-dns.
  • Testing without owning a domain:
  • For an undelegated public Cloud DNS zone such as k8gb.test, update both cluster values files. Set parentZone and extdns.domainFilters to k8gb.test, and set loadBalancedZone to gcp-test.k8gb.test.
  • Update spec.ingress.rules[].host in the failover and round-robin manifests to failover.gcp-test.k8gb.test and roundrobin.gcp-test.k8gb.test, respectively.
  • Set k8gb.edgeDNSServers on both clusters to the authoritative nameservers Cloud DNS assigned to the test zone. k8gb uses these servers to look up the peer cluster's glue records.
  • Query each cluster's CoreDNS external IP directly:
    dig @<COREDNS_EXTERNAL_IP> failover.gcp-test.k8gb.test A +norecurse
    

Testing Failover

# Scale down the primary cluster application
kubectl scale deployment frontend-podinfo --replicas=0 -n test-gslb

# Wait for health check to detect failure (~30-60 seconds)
# Verify DNS now points to secondary cluster
nslookup failover.gcp-test.k8gb.io 8.8.8.8

Additional Resources