-
Notifications
You must be signed in to change notification settings - Fork 74
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
[Feature]: hcloud_server_network: assign IP from supplied subnet #672
Comments
Push for that one. That exactly is the issue I encountered. This is the code I use, to assign to private IPs:
This is, from my point of view, not working as expected.. |
Yep, that's something that would make the lifecycle of kube-hetzner clusters easier to manage too. As right now we have to pre-compute the IPs for subnets (one for each nodepool). The problem with the current approach we have, is that users cannot delete a nodepool once created (they can only scale its count to 0), otherwise it would mess-up all the previous subnets. |
I thought I got around this issue by assigning IP's, but I'm still getting multiple instances of servers being put into the wrong subnet (with wrong IP). resource "hcloud_server_network" "server_network" {
count = var.server_count
server_id = hcloud_server.server[count.index].id
network_id = var.network_id
ip = cidrhost(var.subnet_cidr_block, count.index + 1)
} I create a network and multiple subnets based on CIDR blocks, that same variable is then passed to the module creating the servers, along with a Terraform 1.4.6 |
Hey @mikhailbot, the first IP in every subnet is reserved for the subnet gateway: https://docs.hetzner.com/cloud/networks/faq/#are-any-ip-addresses-reserved
You can try to assign Hope I could help you. If you have further questions, please open a new issue :) |
Thanks for info @apricote! Couple things though, first I figured out my IP assignment issue was a stray Regarding subnets yes I moved things up to start at |
This issue has been marked as stale because it has not had recent activity. The bot will close the issue if no further action occurs. |
I'll take the risk and I'll ask the obvious question that nobody has asked (or I couldn't find?). Can't you implement an endpoint to attach/detach resources to/from a subnet? |
I have already opened a feature request with the responsible team when I created this issue. Added a +1 to it for you too. |
What whould you like to see?
When assigning a server to a network through the
hcloud_server_network
resource, it is not possible to authoritavely choose the subnet that will be used. From out current docs:This happens because the API does not support "attaching to a subnet", it only supports attaching to a Network with an optional IP. This IP would be used to determine the subnet the server is put into.
If a users wants the server to be "put into the subnet", they would need to explicitly calculate an IP from that subnet and pass that to the resource. While this is easy to do in simple setups, it can add dev cost in larger setups.
I am not really sure how we can implement this, besides generating random IPs from the subnet and trying to attach the server as this IP, but this always has the potential to conflict because that IP is already in use. Getting all assigned IPs and just assigning the next one has an even larger potential for conflicts, because that same IP will be chosen by all
hcloud_server_network
resources that are evaluated at the same time.The text was updated successfully, but these errors were encountered: