Skip to content

Commit

Permalink
OPS-7301 Implement getting the full Kubernetes IP range from IONOS CI… (
Browse files Browse the repository at this point in the history
  • Loading branch information
simoncolincap authored Dec 5, 2024
1 parent 3c78123 commit bcc318e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
7 changes: 4 additions & 3 deletions modules/ionos-cidr-workaround/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ No modules.

| Name | Description |
|------|-------------|
| <a name="output_nicIndex"></a> [nicIndex](#output\_nicIndex) | n/a |
| <a name="output_node_lan_ips"></a> [node\_lan\_ips](#output\_node\_lan\_ips) | n/a |
| <a name="output_prefix"></a> [prefix](#output\_prefix) | n/a |
| <a name="output_nicIndex"></a> [nicIndex](#output\_nicIndex) | Index of the NIC used by the provided LAN in the Kubernetes nodes. |
| <a name="output_node_lan_ips"></a> [node\_lan\_ips](#output\_node\_lan\_ips) | List of the IPs assigned to the currently deployed Kubernetes nodes. When using this keep in mind that some of the IPs will change during maintenance. |
| <a name="output_nodes_full_ip_range"></a> [nodes\_full\_ip\_range](#output\_nodes\_full\_ip\_range) | List of all the IPs in the range used by the Kubernetes cluster (IPs 10 to 255 in the prefix CIDR block). |
| <a name="output_prefix"></a> [prefix](#output\_prefix) | CIDR block used by the Kubernetes cluster, for example '10.0.0.0/24'. |
## Requirements

| Name | Version |
Expand Down
1 change: 1 addition & 0 deletions modules/ionos-cidr-workaround/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ locals {
node_servers = data.ionoscloud_servers.k8s_nodes[*].servers[*]
# it gets a list of all the nics that are attached to the provided servers and extracts the ips as a list of only the nics, that are conneted via the provided lan
node_lan_ips = flatten([for server_idx, server in local.node_servers : [ for nic in flatten(server[*].nics[*]) : nic.ips if nic.lan == tonumber(var.lan_id) ]])
nodes_full_ip_range = [for x in range(10,256) : cidrhost(local.prefix, x)]
}
10 changes: 9 additions & 1 deletion modules/ionos-cidr-workaround/output.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
output "nicIndex" {
value = local.nicIndex
description = "Index of the NIC used by the provided LAN in the Kubernetes nodes."
}

output "prefix" {
value = local.prefix
description = "CIDR block used by the Kubernetes cluster, for example '10.0.0.0/24'."
}

output "node_lan_ips" {
value = local.node_lan_ips
}
description = "List of the IPs assigned to the currently deployed Kubernetes nodes. When using this keep in mind that some of the IPs will change during maintenance."
}

output "nodes_full_ip_range" {
value = local.nodes_full_ip_range
description = "List of all the IPs in the range used by the Kubernetes cluster (IPs 10 to 255 in the prefix CIDR block)."
}

0 comments on commit bcc318e

Please sign in to comment.