88 lines
2.1 KiB
HCL
88 lines
2.1 KiB
HCL
variable "component" {
|
|
type = string
|
|
}
|
|
variable "instance" {
|
|
type = string
|
|
}
|
|
variable "namespace" {
|
|
type = string
|
|
}
|
|
variable "labels" {
|
|
type = map(string)
|
|
description = "Service labels"
|
|
}
|
|
variable "selector" {
|
|
type = map(string)
|
|
description = "Service selector labels (default same as labels)"
|
|
default = {}
|
|
}
|
|
variable "annotations" {
|
|
type = map(string)
|
|
default = {}
|
|
}
|
|
variable "svc_type" {
|
|
type = string
|
|
default = "ClusterIP"
|
|
validation {
|
|
condition = contains(["ClusterIP", "ExternalName", "NodePort", "LoadBalancer"], var.svc_type)
|
|
error_message = "Only ClusterIP, ExternalName, NodePort or LoadBalancer is allowed"
|
|
}
|
|
}
|
|
|
|
variable "ip_family" {
|
|
type = string
|
|
default = "PreferDualStack"
|
|
validation {
|
|
condition = contains(["SingleStack", "PreferDualStack"], var.ip_family)
|
|
error_message = "Only SingleStack or PreferDualStack is allowed"
|
|
}
|
|
}
|
|
|
|
variable "port_mapper" {
|
|
description = "List information for port mapping in the service"
|
|
type = list(object({
|
|
name = optional(string)
|
|
port = number
|
|
protocol = string
|
|
target = string
|
|
}))
|
|
default = [{
|
|
"name" = "80-TCP",
|
|
"port" = 80,
|
|
"protocol" = "TCP"
|
|
"target" = "80-TCP"
|
|
}]
|
|
validation {
|
|
condition = alltrue(
|
|
[for port_map in var.port_mapper : contains(["TCP", "UDP"], port_map.protocol)]
|
|
)
|
|
error_message = "Only numeric on containerPort and TCP or UDP on protocol is allowed"
|
|
}
|
|
# validation {
|
|
# condition = (var.svc_type == "NodePort") == alltrue(
|
|
# [for port_map in var.port_mapper : port_map.port >= 30000 && port_map.port <= 32767]
|
|
# )
|
|
# error_message = "The range of valid ports is 30000-32767 for a NodePort type"
|
|
# }
|
|
}
|
|
|
|
variable "target_host" {
|
|
type = string
|
|
default = ""
|
|
}
|
|
|
|
variable "lb_policy" {
|
|
type = string
|
|
default = "Cluster"
|
|
validation {
|
|
condition = contains(["Cluster", "Local"], var.lb_policy)
|
|
error_message = "Only Cluster or Local is allowed"
|
|
}
|
|
}
|
|
|
|
variable "owner_references" {
|
|
type = list(object({}))
|
|
description = "Adding owner references"
|
|
default = []
|
|
}
|