-
Notifications
You must be signed in to change notification settings - Fork 987
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for GCP GKE DNS-based endpoint to connect to GKE cluster #2637
Comments
I knew this was going to be in here already. We have a VPN so we can use kubectl to attack production cluster. I have recently set up de dns-based enpoint and find out the provider won't work without the vpn, my workaround right know is the following.
|
I'm not sure what exactly is the ask here. The |
@alexsomesan Please be so kind provide me some example of Terraform code that shows how to get data from the existed GKE cluster and how to use DNS-endpoint (from the obtained data) to deploy k8s resources. I was not able to find any documentation that clarify this in great details. As a result, I assume that this feature should be implemented. |
There's a bit too little information to go on here. Before I can put together an example we need to clarify some aspects.
|
I'd like to disable both internal and external IP endpoints and fully switch to DNS-endpoint. |
Example of error when attempting to create a new namespace in a GKE cluster when DNS Endpoints is enabled... Provider config:
Error: When using Versions: GKE DNS Endpoint is a new feature released in Nov. 2024 that allows access to the GKE control plane using a DNS hostname instead of an IP address. |
@macninjaface Can you try without the cluster_ca_certificate? |
FWIW this worked perfectly fine using the DNS endpoint. No need for token or CA cert. provider kubernetes {
host = "https://${google_container_cluster.default.control_plane_endpoints_config[0].dns_endpoint_config[0].endpoint}"
exec {
api_version = "client.authentication.k8s.io/v1beta1"
args = []
command = "gke-gcloud-auth-plugin"
}
} |
Confirming this works! Thanks! |
Yes this works, the only problem with this solution is that the gke-gcloud-auth-plugin should be available in the PATH In my case this also seems to be working, which is more convenient for me, as we don't need any additional binary, especially in the context of a cicd where I'm using the official terraform docker image data "google_client_config" "default" {}
provider "kubernetes" {
host = "https://${module.gke.dns_endpoint}"
token = data.google_client_config.default.access_token
} |
One additional note I would like to add, since I stumbled upon this myself: the provider configuration works fine without the protocol if you specify the
However, if you omit
|
Description
Every GKE cluster has a control plane that handles Kubernetes API requests. It'll be handly if Terraform provider Kubernets would be able to use GKE DNS-based endpoint to connect to GKE DNS-based endpoint to deploy k8s resources.
Accordingly to the official documentation DNS-based endpoint:
The DNS-based endpoint gives a unique DNS or fully qualified domain name (FQDN) for each cluster control plane. This DNS name can be used to access your control plane. The DNS name resolves to an endpoint that is accessible from any network reachable by Google Cloud APIs, including on-premises or other cloud networks. Enabling the DNS-based endpoint eliminates the need for a bastion host or proxy nodes to access the control plane from other VPC networks or external locations.
You can find more benefits here.
This feature will be added soon into Terraform provider Google (see references).
Potential Terraform Configuration
References
Community Note
The text was updated successfully, but these errors were encountered: