add: add: optional variables in ske
This commit is contained in:
parent
dcc8079e21
commit
3bcf9cc2b6
7 changed files with 314 additions and 19 deletions
29
example/main.tf
Normal file
29
example/main.tf
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
module "stackit_ske_cluster" {
|
||||
source = "../ske" # Pfad zu deinem Modul-Ordner
|
||||
|
||||
# Erforderliche Variablen
|
||||
project_id = var.project_id
|
||||
name = var.name
|
||||
node_pools = var.node_pools
|
||||
|
||||
# Optionale Variablen
|
||||
kubernetes_version_min = var.kubernetes_version_min
|
||||
allow_privileged_containers = var.allow_privileged_containers
|
||||
hibernations = var.hibernations
|
||||
maintenance = var.maintenance
|
||||
extensions = var.extensions
|
||||
network = var.network
|
||||
default_region = var.default_region
|
||||
}
|
||||
|
||||
/*
|
||||
module "stackit_ske_cluster" {
|
||||
source = "../ske"
|
||||
|
||||
project_id = var.project_id
|
||||
name = var.name
|
||||
kubernetes_version_min = var.kubernetes_version_min
|
||||
node_pools = var.node_pools
|
||||
hibernations = var.hibernations
|
||||
}
|
||||
*/
|
||||
16
example/providers.tf
Normal file
16
example/providers.tf
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
terraform {
|
||||
required_version = ">= 1.9.0"
|
||||
required_providers {
|
||||
stackit = {
|
||||
source = "stackitcloud/stackit"
|
||||
version = "0.56.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "stackit" {
|
||||
default_region = var.default_region
|
||||
service_account_key_path = var.service_account_key_path
|
||||
enable_beta_resources = true
|
||||
}
|
||||
|
||||
57
example/test.tfvars
Normal file
57
example/test.tfvars
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
|
||||
|
||||
node_pools = [
|
||||
{
|
||||
name = "default-pool"
|
||||
machine_type = "c1.2"
|
||||
availability_zones = ["eu01-1"]
|
||||
minimum = 1
|
||||
maximum = 2
|
||||
cri = "containerd"
|
||||
volume_type = "storage_premium_perf1"
|
||||
volume_size = 20
|
||||
labels = {
|
||||
"worker" = "default"
|
||||
}
|
||||
taints = [{
|
||||
effect = "NoSchedule"
|
||||
key = "app"
|
||||
value = "database"
|
||||
}]
|
||||
}
|
||||
]
|
||||
|
||||
kubernetes_version_min = "1.29"
|
||||
|
||||
allow_privileged_containers = false
|
||||
|
||||
hibernations = [
|
||||
{
|
||||
start = "00 18 * * 1-5" # Mo-Fr um 18:00 Uhr
|
||||
end = "00 08 * * 1-5" # Mo-Fr um 08:00 Uhr
|
||||
timezone = "Europe/Berlin"
|
||||
}
|
||||
]
|
||||
|
||||
maintenance = {
|
||||
enable_kubernetes_version_updates = true
|
||||
enable_machine_image_version_updates = true
|
||||
start = "01:00:00Z"
|
||||
end = "03:00:00Z"
|
||||
}
|
||||
|
||||
extensions = {
|
||||
acl = {
|
||||
enabled = true
|
||||
allowed_cidrs = ["0.0.0.0/0"]
|
||||
}
|
||||
argus = {
|
||||
enabled = true
|
||||
argus_instance_id = "deine-argus-instanz-id"
|
||||
}
|
||||
dns = {
|
||||
enabled = true
|
||||
zones = ["example.com"]
|
||||
}
|
||||
}
|
||||
|
||||
106
example/variables.tf
Normal file
106
example/variables.tf
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
variable "project_id" {
|
||||
description = "STACKIT Cloud project ID"
|
||||
type = string
|
||||
default = "6f9528aa-27c8-4e97-a0f7-51bbf3be417c"
|
||||
}
|
||||
|
||||
variable "service_account_key_path" {
|
||||
type = string
|
||||
default = "/home/hahnjan/.stackit/sa.json"
|
||||
}
|
||||
|
||||
variable "default_region" {
|
||||
type = string
|
||||
default = "eu01"
|
||||
}
|
||||
|
||||
variable "name" {
|
||||
description = "Ein Präfix für den Namen des SKE-Clusters."
|
||||
type = string
|
||||
default = "my-ske-cluster"
|
||||
}
|
||||
|
||||
variable "node_pools" {
|
||||
description = "One or more node_pool blocks."
|
||||
type = list(object({
|
||||
name = string
|
||||
machine_type = string
|
||||
availability_zones = list(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" {
|
||||
description = "The minimum Kubernetes version."
|
||||
type = string
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "allow_privileged_containers" {
|
||||
description = "Flag to specify if privileged mode for containers is enabled or not."
|
||||
type = bool
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "hibernations" {
|
||||
description = "A list of hibernation schedules for the cluster."
|
||||
type = list(object({
|
||||
start = string
|
||||
end = string
|
||||
timezone = optional(string)
|
||||
}))
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "maintenance" {
|
||||
description = "A single maintenance block."
|
||||
type = object({
|
||||
enable_kubernetes_version_updates = bool
|
||||
enable_machine_image_version_updates = bool
|
||||
start = string
|
||||
end = string
|
||||
})
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "extensions" {
|
||||
description = "A single extensions block."
|
||||
type = object({
|
||||
acl = optional(object({
|
||||
enabled = bool
|
||||
allowed_cidrs = list(string)
|
||||
}))
|
||||
argus = optional(object({
|
||||
enabled = bool
|
||||
argus_instance_id = string
|
||||
}))
|
||||
dns = optional(object({
|
||||
enabled = bool
|
||||
zones = optional(list(string))
|
||||
}))
|
||||
})
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "network" {
|
||||
description = "Network block."
|
||||
type = object({
|
||||
id = string
|
||||
})
|
||||
default = null
|
||||
}
|
||||
8
main.tf
8
main.tf
|
|
@ -10,7 +10,7 @@ terraform {
|
|||
}
|
||||
|
||||
provider "stackit" {
|
||||
default_region = var.default_region
|
||||
default_region = var.default_region
|
||||
service_account_key_path = var.service_account_key_path
|
||||
private_key_path = var.private_key_path
|
||||
enable_beta_resources = true
|
||||
|
|
@ -21,10 +21,12 @@ module "project" {
|
|||
source = "./project"
|
||||
|
||||
# -- variables for project module
|
||||
organization_id = var.organization_id
|
||||
sna_net = var.sna_net
|
||||
organization_id = var.organization_id
|
||||
sna_net = var.sna_net
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
14
ske/main.tf
14
ske/main.tf
|
|
@ -1,8 +1,14 @@
|
|||
resource "stackit_ske_cluster" "this" {
|
||||
project_id = var.project_id
|
||||
name = var.name
|
||||
kubernetes_version_min = var.kubernetes_version_min
|
||||
node_pools = var.node_pools
|
||||
project_id = var.project_id
|
||||
name = var.name
|
||||
node_pools = var.node_pools
|
||||
kubernetes_version_min = var.kubernetes_version_min
|
||||
allow_privileged_containers = var.allow_privileged_containers
|
||||
hibernations = var.hibernations
|
||||
maintenance = var.maintenance
|
||||
extensions = var.extensions
|
||||
network = var.network
|
||||
region = var.default_region
|
||||
}
|
||||
|
||||
resource "stackit_ske_kubeconfig" "admin" {
|
||||
|
|
|
|||
103
ske/variables.tf
103
ske/variables.tf
|
|
@ -1,22 +1,101 @@
|
|||
variable "project_id" {
|
||||
type = string
|
||||
description = "STACKIT project ID to which the cluster is associated."
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "name" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "kubernetes_version_min" {
|
||||
type = string
|
||||
description = "The cluster name."
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "node_pools" {
|
||||
description = "One or more node_pool blocks."
|
||||
type = list(object({
|
||||
name = string
|
||||
machine_type = string
|
||||
availability_zones = list(string)
|
||||
volume_size = number
|
||||
minimum = number
|
||||
maximum = number
|
||||
name = string
|
||||
machine_type = string
|
||||
availability_zones = list(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)
|
||||
}))
|
||||
}
|
||||
|
||||
# -- Optionale Variablen --
|
||||
variable "kubernetes_version_min" {
|
||||
description = "The minimum Kubernetes version."
|
||||
type = string
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "allow_privileged_containers" {
|
||||
description = "Flag to specify if privileged mode for containers is enabled or not."
|
||||
type = bool
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "hibernations" {
|
||||
description = "A list of hibernation schedules for the cluster."
|
||||
type = list(object({
|
||||
start = string
|
||||
end = string
|
||||
timezone = optional(string)
|
||||
}))
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "maintenance" {
|
||||
description = "A single maintenance block."
|
||||
type = object({
|
||||
enable_kubernetes_version_updates = bool
|
||||
enable_machine_image_version_updates = bool
|
||||
start = string
|
||||
end = string
|
||||
})
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "extensions" {
|
||||
description = "A single extensions block."
|
||||
type = object({
|
||||
acl = optional(object({
|
||||
enabled = bool
|
||||
allowed_cidrs = list(string)
|
||||
}))
|
||||
argus = optional(object({
|
||||
enabled = bool
|
||||
argus_instance_id = string
|
||||
}))
|
||||
dns = optional(object({
|
||||
enabled = bool
|
||||
zones = optional(list(string))
|
||||
}))
|
||||
})
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "network" {
|
||||
description = "Network block."
|
||||
type = object({
|
||||
id = string
|
||||
})
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "default_region" {
|
||||
description = "The resource region."
|
||||
type = string
|
||||
default = null
|
||||
}
|
||||
Loading…
Reference in a new issue