vultr / terraform-provider-vultr

Terraform Vultr provider
https://www.terraform.io/docs/providers/vultr/
Mozilla Public License 2.0
193 stars 65 forks source link

[Feature] - Get the VPC that a VKE cluster creates #455

Open jeffdeville opened 9 months ago

jeffdeville commented 9 months ago

Is your feature request related to a problem? Please describe.

I would like to attach a managed db to my k8s cluster. But to do that, I need to know the VPC-ID created to house it. As it stands, I'll have to create the cluster, grab the VPCID manually from the dashboard, and build it in a separate step.

Describe the solution you'd like Ideally, It would be possible to either specify a VPC_ID into which the VKE cluster would be installed, or obtain the VPC_ID for the cluster as an output. Both of course would provide maximum flexibility, but either would meet my needs.

Describe alternatives you've considered 👆

optik-aper commented 8 months ago

@jeffdeville Thanks for the request here, but since this functionality isn't supported by the API, we can't build it in to the provider. If you wanted to submit a ticket to the Vultr team to add that support it will get updated here once complete.

PaulSonOfLars commented 7 months ago

Alternatively, it might be a good solution to be able to pass in your own VPC ID (or VPC2) at kubernetes cluster creation. This would avoid the "magic" of having a new VPC being created in the background, which might be unexpected.

Even better would be the ability to provide custom IP ranges for the nodes, cluster, and service CIDRs. And maybe even to use non-RFC 1918 addresses for pods and services, such that the cluster resources don't overlap the VPC (Similar to what google suggest for GKE)

tempusfrangit commented 3 months ago

@jeffdeville The solution I came up with (which works) is:

data "vultr_vpc" "k8s_vpc" {
  filter {
    name   = "description"
    values = ["VKE-Network-${var.k8s_cluster_id}"]
  }
}

resource "vultr_database" "redis" {
  region                  = var.region
  label                   = var.label
  plan                    = var.plan
  database_engine         = "redis"
  database_engine_version = 7
  vpc_id                  = data.vultr_vpc.k8s_vpc.id
}

The VPC ID can be referenced if you filter based upon the description, which is (as of the time of this writing) a known quantity. I did create the VKE Cluster with terraform, which might impact some behaviors.

I agree making this easier would be preferable, but there are some work-arounds (you could also just edit the VPC to a known/fixed value)