GCP plugin for Flux WIF does not support anything other than the public IP endpoint.
Describe the bug
Flux support for Workload Identity Federation was added recently and documented here (For GCP) - https://fluxcd.io/flux/integrations/gcp/#for-google-kubernetes-engine
We wanted to use it to manage GKE clusters remotely. It's used by creating a ConfigMap with the following information -
data:
provider: gcp
cluster: projects/<GCP_PROJECT_ID>/locations/<REGION>/clusters/<GCP_CLUSTER_NAME>
This only uses the public IP endpoint of the GKE cluster. If you want to connect to the cluster in other ways, for example - internal IP or DNS, then tough luck. This can cause issues due to public IP whitelisting rules on the control-plane.
We tried to get around this by manually setting the address via data.address but you get the following error (in our case, we set it to the DNS endpoint of the control plane)-
GKE endpoint 'PUBLIC_IP_ENDPOINT' does not match specified address: 'https://gke-SOME_HASH.europe-west2.gke.goog'
Looking at the source code on flux/pkg
https://github.com/fluxcd/pkg/blob/2f71d01eaa4ceb8630debd343ab7656075315fb0/auth/gcp/implementation.go#L46
The implementation gets the Endpoint field from the Cluster struct which by default just points to the public IPv4 address. Looking at https://pkg.go.dev/google.golang.org/api/container/v1#Cluster, we
can get the other endpoints from Cluster.ControlPlaneEndpointsConfig which has both IP (public and private) and DNS endpoints and let the user decide which they want to use via a field.
The above is for the GCP implementation only and I'm not sure how it behaves for the other cloud providers.
Steps to reproduce
- Create 2 GKE clusters, A and B.
- Install Flux with the WIF feature gate enabled on cluster A
- Add a ConfigMap with the following WIF config
data:
provider: gcp
cluster: projects/<GCP_PROJECT_ID>/locations/<REGION>/clusters/B
- Create a HelmRelease/Kustomization with
kubeConfig.configMapRef.nameset to the above configmap. - If Cluster-A can't talk to the public IP address of Cluster-B, the above fails.
Expected behavior
Flux would allow us to choose which endpoint of the GKE cluster to connect to. Available options -
- Public IP
- Internal IP
- DNS Endpoint
Suggestion -
- Allow users to specify
data.address - When the check happens which compares data.address to the cluster endpoint, compare instead to ALL the endpoints and use the
data.addressto connect to the cluster
Screenshots and recordings
No response
OS / Distro
COS_CONTAINERD (cos-121-18867-294-38)
Flux version
v2.7.5
Flux check
► checking prerequisites ✔ Kubernetes 1.33.5-gke.2019000 >=1.32.0-0 ► checking version in cluster ✔ distribution: flux-v2.7.5 ✔ bootstrapped: true ► checking controllers ✔ helm-controller: deployment ready ► ghcr.io/fluxcd/helm-controller:v1.4.5 ✔ kustomize-controller: deployment ready ► ghcr.io/fluxcd/kustomize-controller:v1.7.3 ✔ notification-controller: deployment ready ► ghcr.io/fluxcd/notification-controller:v1.7.5 ✔ source-controller: deployment ready ► ghcr.io/fluxcd/source-controller:v1.7.4 ► checking crds ✔ alerts.notification.toolkit.fluxcd.io/v1beta3 ✔ buckets.source.toolkit.fluxcd.io/v1 ✔ externalartifacts.source.toolkit.fluxcd.io/v1 ✔ gitrepositories.source.toolkit.fluxcd.io/v1 ✔ helmcharts.source.toolkit.fluxcd.io/v1 ✔ helmreleases.helm.toolkit.fluxcd.io/v2 ✔ helmrepositories.source.toolkit.fluxcd.io/v1 ✔ kustomizations.kustomize.toolkit.fluxcd.io/v1 ✔ ocirepositories.source.toolkit.fluxcd.io/v1 ✔ providers.notification.toolkit.fluxcd.io/v1beta3 ✔ receivers.notification.toolkit.fluxcd.io/v1 ✔ all checks passed
Git provider
No response
Container Registry provider
No response
Additional context
No response
Code of Conduct
- [x] I agree to follow this project's Code of Conduct
Fix will land in Flux 2.8, end of Feb 2026
Thanks for the quick response mate
What fluxcd/pkg#1071 Fixed (and What It Didn't)
PR #1071 removed the address matching validation from the GCP provider. Previously, if you set address in the ConfigMap to anything other than the cluster's public IP endpoint, Flux would reject it with "GKE endpoint does not match specified address".
Removed code (auth/gcp/provider.go):
// Compare specified address and address from the cluster resource.
endpoint := clusterResource.Endpoint
if host != "" {
canonicalAddress, _ := auth.ParseClusterAddress(host)
canonicalEndpoint, _ := auth.ParseClusterAddress(endpoint)
if canonicalAddress != canonicalEndpoint {
return nil, fmt.Errorf("GKE endpoint '%s' does not match specified address: '%s'", endpoint, host)
}
}
This fix allows specifying a DNS endpoint or any alternative address. However, the PR did not change how CAData is handled. The provider still fetches the cluster's self-signed CA from MasterAuth.ClusterCaCertificate and uses it for TLS verification — which is incorrect for DNS endpoints that use Google Trust Services certificates.
Might be a Root Cause
The issue might be in the GCP provider's NewRESTConfig function (auth/gcp/provider.go):
host = o.ClusterAddress // DNS endpoint from ConfigMap
caData = o.CAData // empty
if host == "" || caData == "" {
// Fetches cluster details from GKE API
clusterResource, _ := p.impl().GetCluster(ctx, cluster, client)
// Sets caData to the cluster's self-signed CA
caData, _ = base64.StdEncoding.DecodeString(
clusterResource.MasterAuth.ClusterCaCertificate)
}
When address is provided but caData is not:
hostis set to the DNS endpoint (*.gke.goog)caDatais empty, so the provider fetches the cluster's self-signed CA from the GKE API- The DNS endpoint serves a certificate signed by Google Trust Services (a public CA)
- The self-signed cluster CA cannot verify the Google Trust Services certificate
- TLS handshake fails with
x509: certificate signed by unknown authority
This is a mismatch: the IP-based endpoint uses the cluster's self-signed CA, but the DNS endpoint uses a publicly-signed certificate from Google Trust Services.
Expected Behaviour
When dnsLookup: "true" is set, the GCP provider should not use the cluster's self-signed CA (MasterAuth.ClusterCaCertificate). Instead, it should rely on the system's trusted root CA bundle, which includes Google Trust Services and can verify the DNS endpoint's certificate.
Suggested Fix
In NewRESTConfig, when the DNS endpoint is being used (i.e., dnsLookup is enabled or the host is a *.gke.goog address), skip setting CAData from the cluster resource and let the system root CAs handle verification:
// Only use cluster CA for IP-based endpoints, not DNS endpoints
if !isDNSEndpoint(host) {
caData, err = base64.StdEncoding.DecodeString(
clusterResource.MasterAuth.ClusterCaCertificate)
}
When
dnsLookup: "true"
What is dnsLookup? There's no such thing in github.com/fluxcd/pkg: https://github.com/search?q=repo%3Afluxcd%2Fpkg%20dnsLookup&type=code
In any case, you can either provide a CA yourself (along the address that you are already providing), or get the one from the GKE cluster resource.
Furthermore, if anything, your comment is a feature requst. Not a bug. If you have good reasons to pursue the feature, please open a dedicated issue.