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¶
- Two GKE clusters in different regions with Workload Identity enabled:
- Standard GKE (manual): Enable
--workload-pool=<PROJECT_ID>.svc.id.googon the cluster and--workload-metadata=GKE_METADATAon the node pool. - Autopilot GKE: Node-pool metadata is managed automatically (do not run
node-pools update), but verify--workload-pool=<PROJECT_ID>.svc.id.googis set on the cluster. - A Cloud DNS managed zone. Enable
dns.googleapis.comin the DNS project andiamcredentials.googleapis.comfor the Workload Identity setup. See the Cloud DNS prerequisites. - A Google service account with
roles/dns.adminin the DNS project. On that Google service account, grantroles/iam.workloadIdentityUsertoserviceAccount:<GKE_PROJECT_ID>.svc.id.goog[k8gb/k8gb-external-dns]for each GKE project. See the Workload Identity setup.
Deployment¶
-
Deploy K8GB on the first cluster:
-
Deploy K8GB on the second cluster:
-
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-projectif DNS zone is in a different project - Geo Tags: Must be unique per cluster (
europe-west1,us-central1) - TXT Ownership: Each cluster needs unique
txtPrefixandtxtOwnerId
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-corednsLoadBalancer stuck<pending>(LoadBalancerMixedProtocolNotSupported): The mixed TCP/UDP Service requires GKE1.34.1-gke.2190000or later and theHttpLoadBalancingadd-on. Before1.36.2-gke.1498000, mixed-protocol load balancing supports IPv4 external load balancers only. See the GKE requirements.- The examples set
coredns.service.loadBalancerClasstonetworking.gke.io/l4-regional-externalat install time. Recreate an existing target-pool Service to switch to this class. - For a temporary UDP-only smoke test, confirm that port index
1is TCP before applying the patch below (TCP queries to the Service will time out): ACCESS_TOKEN_SCOPE_INSUFFICIENTink8gb-external-dnslogs:- Standard GKE: Ensure
--workload-pool=<PROJECT_ID>.svc.id.googis set on the cluster and--workload-metadata=GKE_METADATAis set on the node pool. - Autopilot GKE: Ensure
--workload-pool=<PROJECT_ID>.svc.id.googis set on the cluster (do not update node pools). - Verify
k8gb-external-dnsServiceAccount hasiam.gke.io/gcp-service-account=<GSA_EMAIL>and restartdeployment/k8gb-external-dns. - Testing without owning a domain:
- For an undelegated public Cloud DNS zone such as
k8gb.test, update both cluster values files. SetparentZoneandextdns.domainFilterstok8gb.test, and setloadBalancedZonetogcp-test.k8gb.test. - Update
spec.ingress.rules[].hostin the failover and round-robin manifests tofailover.gcp-test.k8gb.testandroundrobin.gcp-test.k8gb.test, respectively. - Set
k8gb.edgeDNSServerson 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:
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¶
- Google Cloud DNS Provider Documentation - Complete reference
- K8GB Introduction - How K8GB works