Skip to content
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

Support use of Private Service Connect endpoint in GKE google_container_cluster resource #15064

Comments

@ncapps
Copy link

ncapps commented Jul 6, 2023

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment. If the issue is assigned to the "modular-magician" user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If the issue is assigned to a user, that user is claiming responsibility for the issue. If the issue is assigned to "hashibot", a community member has claimed the issue already.

Description

Creating a VPC network peering connection between the cluster VPC and the control plane VPC is not allowed in some enterprise uses cases. An alternative solution is connect the cluster VPC and control plane VPC using a Private Service Connect (PSC) endpoint.

The Terraform resource, google_container_cluster, should allow creating a private cluster without specifying the master_ipv4_cidr_block. This use case is supported with the gcloud container clusters create command.

gcloud container clusters create private-cluster \
    --enable-master-authorized-networks \
    --enable-ip-alias \
    --enable-private-nodes \
    --enable-private-endpoint \
    --network="shared-vpc" \
    --subnetwork="shared-vpc-subnet" \
    --private-endpoint-subnetwork="shared-vpc-subnet-nodes"

Using Terraraform, we currently cannot create a private cluster without providing a value for master_ipv4_cidr_block.

This configuration results in a Terraform build phase error.

private_cluster_config {
    enable_private_endpoint     = true
    enable_private_nodes        = true
    private_endpoint_subnetwork = "projects/project-id/regions/region/subnetworks/shared-vpc-subnet-nodes"
}

Error message:

module.kubernetes-engine.google_container_cluster.cluster: Creating...
╷
│ Error: master_ipv4_cidr_block must be set if enable_private_nodes is true

New or Affected Resource(s)

  • google_container_cluster

Potential Terraform Configuration

  • Add support for creating a private cluster (standard) that utilizes Private Service Connect endpoints to connect the cluster VPC with the control plane VPC.
resource "google_container_cluster" "cluster" {
...
    private_cluster_config {
        enable_private_endpoint     = true
        enable_private_nodes        = true
        private_endpoint_subnetwork = "projects/project-id/regions/region/subnetworks/shared-vpc-subnet-nodes"
    }
}

References

  • b/290344299
@ncapps
Copy link
Author

ncapps commented Jul 13, 2023

I will work on a fix for this issue.

@sanmaym
Copy link

sanmaym commented Sep 2, 2023

@ncapps @rileykarson Can I get some clarification on this PR ? Are you trying to create a GKE cluster with private nodes which operates with PSC instead of VPC Peering? Is that possible today? My understanding was that its only supported for public GKE clusters and GKE cluster with private nodes was not supported yet

@ncapps
Copy link
Author

ncapps commented Sep 5, 2023

Hi @sanmaym, Yes - we are creating GKE clusters with private nodes that use PSC. We have been using this configuration for over a year now. We needed to provision and manage the clusters using gcloud until this change was applied to the Google Terraform provider.

@github-actions
Copy link

github-actions bot commented Oct 6, 2023

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.