This commit is contained in:
Janis_Hahn 2025-07-15 22:30:05 +02:00
parent 91fdd1d420
commit f43585ca95
4 changed files with 129 additions and 149 deletions

View file

@ -18,19 +18,19 @@ locals {
} }
module "stackit_ske_cluster" { module "stackit_ske_cluster" {
for_each = var.ske_clusters
source = "../ske" source = "../ske"
project_id = local.project_ids[each.value.project_key]
name = each.value.name
node_pools = each.value.node_pools
network = {
id = each.value.network_id
}
# required variables kubernetes_version_min = lookup(each.value, "kubernetes_version_min", null)
project_id = local.project_ids[var.ske_target_project_key] hibernations = lookup(each.value, "hibernations", null)
name = var.name maintenance = lookup(each.value, "maintenance", null)
node_pools = var.node_pools extensions = lookup(each.value, "extensions", null)
# optional variables
kubernetes_version_min = var.kubernetes_version_min
hibernations = var.hibernations
maintenance = var.maintenance
extensions = var.extensions
network = var.network
default_region = var.default_region default_region = var.default_region
} }

View file

@ -4,11 +4,11 @@ organization_id = "03a34540-3c1a-4794-b2c6-7111ecf824ef"
Projects_map = { Projects_map = {
"projekt-alpha" = { "projekt-alpha" = {
name = "tf_modules_test_1" name = "tf_modules_test_3"
owner_email = "janis.hahn@stackit.cloud" owner_email = "janis.hahn@stackit.cloud"
}, },
"projekt-beta" = { "projekt-beta" = {
name = "tf_modules_test_2" name = "tf_modules_test_4"
owner_email = "janis.hahn@stackit.cloud" owner_email = "janis.hahn@stackit.cloud"
} }
} }
@ -21,34 +21,34 @@ SNA_network_ranges = [
SNA_transfer_network = "172.16.0.0/24" SNA_transfer_network = "172.16.0.0/24"
name = "cluster" ske_clusters = {
ske_target_project_key = "projekt-alpha" # projekt-alpha or projekt-beta ... or other from above to ensure scalability "prod-cluster" = {
name = "clusterprod"
project_key = "projekt-alpha"
network_id = "53917a75-0014-49b0-a4d6-e62934ab479f" # WICHTIG: Hier die Netzwerk-ID connecten
kubernetes_version_min = "1.32.5"
node_pools = [ node_pools = [
{ {
name = "default-pool" name = "defaulpool"
machine_type = "c1.2" machine_type = "c1.2"
availability_zones = ["eu01-1"] availability_zones = ["eu01-1"]
minimum = 1 minimum = 1
maximum = 2 maximum = 2
cri = "containerd" cri = "containerd"
volume_type = "storage_premium_perf1" volume_type = "storage_premium_perf1"
volume_size = 20 volume_size = 21
labels = { labels = { "worker" = "default" }
"worker" = "default"
}
taints = [{ taints = [{
effect = "NoSchedule" effect = "NoSchedule"
key = "app" key = "app"
value = "database" value = "database"
}] }]
} }
] ]
kubernetes_version_min = "1.32.5" hibernations = [
hibernations = [
{ {
start = "00 18 * * 1-5" # Mo-Fr um 18:00 Uhr start = "00 18 * * 1-5" # Mo-Fr um 18:00 Uhr
end = "00 08 * * 1-5" # Mo-Fr um 08:00 Uhr end = "00 08 * * 1-5" # Mo-Fr um 08:00 Uhr
@ -56,28 +56,36 @@ hibernations = [
} }
] ]
maintenance = { maintenance = {
enable_kubernetes_version_updates = true enable_kubernetes_version_updates = true
enable_machine_image_version_updates = true enable_machine_image_version_updates = true
start = "01:00:00Z" start = "01:00:00Z"
end = "03:00:00Z" end = "03:00:00Z"
} }
extensions = { extensions = {
acl = { acl = {
enabled = true enabled = true
allowed_cidrs = ["0.0.0.0/0"] allowed_cidrs = ["0.0.0.0/0"]
} }
argus = {
enabled = true
argus_instance_id = "deine-argus-instanz-id"
} }
dns = { },
enabled = true
zones = ["example.com"]
}
}
network = { "dev-cluster" = {
id = "bae113a7-cc47-4b1e-8abd-3cdacdd53f28" name = "clusterdev"
kubernetes_version_min = "1.32.5"
project_key = "projekt-beta"
network_id = "9c3dea6a-2971-414e-8c06-04618aa2c1f7" # WICHTIG: Hier die Netzwerk-ID connecten
node_pools = [
{
name = "devpool"
machine_type = "c1.2"
availability_zones = ["eu01-2"]
minimum = 1
maximum = 1
volume_size = 21
}
]
}
} }

View file

@ -4,7 +4,6 @@ variable "organization_id" {
type = string type = string
} }
variable "ske_target_project_key" { type = string }
variable "service_account_key_path" { variable "service_account_key_path" {
type = string type = string
default = "/home/hahnjan/.stackit/sa.json" default = "/home/hahnjan/.stackit/sa.json"
@ -41,67 +40,27 @@ variable "Projects_map" {
# SKE variables # SKE variables
variable "name" { variable "ske_clusters" {
description = "Ein Präfix für den Namen des SKE-Clusters." description = "Eine Map von SKE-Clustern"
type = string type = map(object({
default = "my-ske-cluster"
}
variable "node_pools" {
description = "One or more node_pool blocks."
type = list(object({
name = string name = string
machine_type = string project_key = string
availability_zones = list(string) network_id = string
minimum = number
maximum = number
allow_system_components = optional(bool)
cri = optional(string)
labels = optional(map(string))
max_surge = optional(number)
max_unavailable = optional(number)
os_name = optional(string)
os_version_min = optional(string)
taints = optional(list(object({
effect = string
key = string
value = optional(string)
})))
volume_size = optional(number)
volume_type = optional(string)
}))
}
variable "kubernetes_version_min" { kubernetes_version_min = optional(string)
description = "The minimum Kubernetes version." hibernations = optional(list(object({
type = string
default = null
}
variable "hibernations" {
description = "A list of hibernation schedules for the cluster."
type = list(object({
start = string start = string
end = string end = string
timezone = optional(string) timezone = optional(string)
})) })))
default = null maintenance = optional(object({
}
variable "maintenance" {
description = "A single maintenance block."
type = object({
enable_kubernetes_version_updates = bool enable_kubernetes_version_updates = bool
enable_machine_image_version_updates = bool enable_machine_image_version_updates = bool
start = string start = string
end = string end = string
}) }))
default = null extensions = optional(object({
}
variable "extensions" {
description = "A single extensions block."
type = object({
acl = optional(object({ acl = optional(object({
enabled = bool enabled = bool
allowed_cidrs = list(string) allowed_cidrs = list(string)
@ -110,18 +69,31 @@ variable "extensions" {
enabled = bool enabled = bool
argus_instance_id = string argus_instance_id = string
})) }))
dns = optional(object({
enabled = bool
zones = optional(list(string))
})) }))
})
default = null
}
variable "network" { node_pools = list(object({
description = "Network block."
type = object({ name = string
id = string machine_type = string
}) availability_zones = list(string)
default = null minimum = number
maximum = number
allow_system_components = optional(bool)
cri = optional(string)
labels = optional(map(string))
max_surge = optional(number)
max_unavailable = optional(number)
os_name = optional(string)
os_version_min = optional(string)
volume_size = optional(number)
volume_type = optional(string)
taints = optional(list(object({
effect = string
key = string
value = optional(string)
})))
}))
}))
default = {}
} }

View file

@ -33,7 +33,7 @@ variable "node_pools" {
})) }))
} }
# -- Optionale Variablen -- # Optionale Variablen
variable "kubernetes_version_min" { variable "kubernetes_version_min" {
description = "The minimum Kubernetes version." description = "The minimum Kubernetes version."
type = string type = string