# Kubernetes deployment configuration fragment
# Conditional: when deployment_target == "kubernetes" or deployment_target == "both"

[[elements]]
default = "default"
help = "Namespace for deploying resources"
name = "k8s_namespace"
nickel_path = ["provisioning", "deployment", "kubernetes", "namespace"]
prompt = "Kubernetes namespace"
required = true
type = "text"
validation_pattern = "^[a-z0-9-]+$"
when = "deployment_target == kubernetes || deployment_target == both"

[[elements]]
default = false
help = "Automatically create the namespace during deployment"
name = "k8s_create_namespace"
nickel_path = ["provisioning", "deployment", "kubernetes", "create_namespace"]
prompt = "Create namespace if it doesn't exist?"
required = true
type = "confirm"
when = "deployment_target == kubernetes || deployment_target == both"

[[elements]]
default = "ClusterIP"
help = "Kubernetes Service type"
name = "k8s_service_type"
nickel_path = ["provisioning", "deployment", "kubernetes", "service", "type"]
options = ["ClusterIP", "NodePort", "LoadBalancer"]
prompt = "Service type"
required = true
type = "select"
when = "deployment_target == kubernetes || deployment_target == both"

[[elements]]
default = false
help = "Create an Ingress resource for external access"
name = "k8s_enable_ingress"
nickel_path = ["provisioning", "deployment", "kubernetes", "ingress", "enabled"]
prompt = "Enable Ingress?"
required = true
type = "confirm"
when = "deployment_target == kubernetes || deployment_target == both"

[[elements]]
default = "nginx"
help = "Ingress controller class (e.g., nginx, traefik)"
name = "k8s_ingress_class"
nickel_path = ["provisioning", "deployment", "kubernetes", "ingress", "class_name"]
prompt = "Ingress class name"
required = true
type = "text"
when = "(deployment_target == kubernetes || deployment_target == both) && k8s_enable_ingress == true"

[[elements]]
help = "Hostname for Ingress (e.g., api.example.com)"
name = "k8s_ingress_host"
nickel_path = ["provisioning", "deployment", "kubernetes", "ingress", "rules", 0, "host"]
placeholder = "api.example.com"
prompt = "Ingress hostname"
required = true
type = "text"
when = "(deployment_target == kubernetes || deployment_target == both) && k8s_enable_ingress == true"

[[elements]]
default = false
help = "Automatically scale pods based on CPU/memory usage"
name = "k8s_enable_hpa"
nickel_path = ["provisioning", "deployment", "kubernetes", "hpa", "enabled"]
prompt = "Enable Horizontal Pod Autoscaler?"
required = true
type = "confirm"
when = "deployment_target == kubernetes || deployment_target == both"

[[elements]]
custom_type = "u16"
default = "1"
help = "Minimum number of pods (1-100)"
maximum = "100"
minimum = "1"
name = "k8s_hpa_min_replicas"
nickel_path = ["provisioning", "deployment", "kubernetes", "hpa", "min_replicas"]
prompt = "Minimum replicas"
required = true
type = "custom"
when = "(deployment_target == kubernetes || deployment_target == both) && k8s_enable_hpa == true"

[[elements]]
custom_type = "u16"
default = "10"
help = "Maximum number of pods (1-100)"
maximum = "100"
minimum = "1"
name = "k8s_hpa_max_replicas"
nickel_path = ["provisioning", "deployment", "kubernetes", "hpa", "max_replicas"]
prompt = "Maximum replicas"
required = true
type = "custom"
when = "(deployment_target == kubernetes || deployment_target == both) && k8s_enable_hpa == true"

[[elements]]
custom_type = "u16"
default = "80"
help = "Target CPU utilization percentage (1-100)"
maximum = "100"
minimum = "1"
name = "k8s_hpa_cpu_target"
nickel_path = ["provisioning", "deployment", "kubernetes", "hpa", "target_cpu_utilization"]
prompt = "Target CPU utilization (%)"
required = true
type = "custom"
when = "(deployment_target == kubernetes || deployment_target == both) && k8s_enable_hpa == true"

[[elements]]
default = "100m"
help = "CPU request (e.g., '100m', '1')"
name = "k8s_cpu_request"
nickel_path = ["provisioning", "services", "api", "resources", "cpu_request"]
prompt = "CPU request"
required = false
type = "text"
when = "deployment_target == kubernetes || deployment_target == both"

[[elements]]
default = "500m"
help = "CPU limit (e.g., '500m', '2')"
name = "k8s_cpu_limit"
nickel_path = ["provisioning", "services", "api", "resources", "cpu_limit"]
prompt = "CPU limit"
required = false
type = "text"
when = "deployment_target == kubernetes || deployment_target == both"

[[elements]]
default = "128Mi"
help = "Memory request (e.g., '128Mi', '1Gi')"
name = "k8s_memory_request"
nickel_path = ["provisioning", "services", "api", "resources", "memory_request"]
prompt = "Memory request"
required = false
type = "text"
when = "deployment_target == kubernetes || deployment_target == both"

[[elements]]
default = "512Mi"
help = "Memory limit (e.g., '512Mi', '2Gi')"
name = "k8s_memory_limit"
nickel_path = ["provisioning", "services", "api", "resources", "memory_limit"]
prompt = "Memory limit"
required = false
type = "text"
when = "deployment_target == kubernetes || deployment_target == both"
