From bcc318e44a89de9379086858752d1fdaa47bfa0d Mon Sep 17 00:00:00 2001
From: simoncolincap <66997279+simoncolincap@users.noreply.github.com>
Date: Thu, 5 Dec 2024 15:04:04 +0000
Subject: [PATCH] =?UTF-8?q?OPS-7301=20Implement=20getting=20the=20full=20K?=
=?UTF-8?q?ubernetes=20IP=20range=20from=20IONOS=20CI=E2=80=A6=20(#39)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
modules/ionos-cidr-workaround/README.md | 7 ++++---
modules/ionos-cidr-workaround/locals.tf | 1 +
modules/ionos-cidr-workaround/output.tf | 10 +++++++++-
3 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/modules/ionos-cidr-workaround/README.md b/modules/ionos-cidr-workaround/README.md
index 9eaf695..3ad9edb 100644
--- a/modules/ionos-cidr-workaround/README.md
+++ b/modules/ionos-cidr-workaround/README.md
@@ -18,9 +18,10 @@ No modules.
| Name | Description |
|------|-------------|
-| [nicIndex](#output\_nicIndex) | n/a |
-| [node\_lan\_ips](#output\_node\_lan\_ips) | n/a |
-| [prefix](#output\_prefix) | n/a |
+| [nicIndex](#output\_nicIndex) | Index of the NIC used by the provided LAN in the Kubernetes nodes. |
+| [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. |
+| [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). |
+| [prefix](#output\_prefix) | CIDR block used by the Kubernetes cluster, for example '10.0.0.0/24'. |
## Requirements
| Name | Version |
diff --git a/modules/ionos-cidr-workaround/locals.tf b/modules/ionos-cidr-workaround/locals.tf
index 4f13f8a..c60db8c 100644
--- a/modules/ionos-cidr-workaround/locals.tf
+++ b/modules/ionos-cidr-workaround/locals.tf
@@ -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)]
}
\ No newline at end of file
diff --git a/modules/ionos-cidr-workaround/output.tf b/modules/ionos-cidr-workaround/output.tf
index 9be5fdc..af5ebd8 100644
--- a/modules/ionos-cidr-workaround/output.tf
+++ b/modules/ionos-cidr-workaround/output.tf
@@ -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
-}
\ No newline at end of file
+ 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)."
+}