find a way to connect to another namespace without conflict found yet
This commit is contained in:
@@ -30,27 +30,30 @@ variable "kubernetes" {
|
||||
})
|
||||
}))
|
||||
})))
|
||||
replicas = optional(number, 1)
|
||||
namespace = optional(string)
|
||||
block_namespace_creation = optional(bool, false)
|
||||
service_port = optional(number)
|
||||
service_type = optional(string, "ClusterIP")
|
||||
service_name = optional(string)
|
||||
liveness_tcp_socket = optional(number)
|
||||
liveness_http_get = optional(string)
|
||||
liveness_http_get_path = optional(string)
|
||||
database = optional(map(string))
|
||||
redis = optional(map(string))
|
||||
enabled = optional(bool, true)
|
||||
secret_ref = optional(list(string))
|
||||
config_map_ref = optional(list(string))
|
||||
extra_manifest = optional(list(string))
|
||||
requirements = optional(map(string), {
|
||||
limits-cpu = "800m"
|
||||
limits-memory = "500Mi"
|
||||
requests-cpu = "200m"
|
||||
requests-memory = "200Mi"
|
||||
})
|
||||
replicas = optional(number, 1)
|
||||
namespace = optional(string)
|
||||
connected_namespace = optional(string, "")
|
||||
# namespace = optional(string,coalesce(connected_namespace,""))
|
||||
#block_namespace_creation = optional(bool, false)
|
||||
service_port = optional(number)
|
||||
service_type = optional(string, "ClusterIP")
|
||||
service_name = optional(string)
|
||||
liveness_tcp_socket = optional(number)
|
||||
liveness_http_get = optional(string)
|
||||
liveness_http_get_path = optional(string)
|
||||
database = optional(map(string))
|
||||
redis = optional(map(string))
|
||||
enabled = optional(bool, true)
|
||||
secret_ref = optional(list(string))
|
||||
config_map_ref = optional(list(string))
|
||||
extra_manifest = optional(list(string))
|
||||
requirements = optional(map(string))
|
||||
# requirements = optional(map(string), {
|
||||
# limits-cpu = "800m"
|
||||
# limits-memory = "500Mi"
|
||||
# requests-cpu = "200m"
|
||||
# requests-memory = "200Mi"
|
||||
# })
|
||||
environment_variables = optional(map(string), { name = "value" })
|
||||
}))
|
||||
|
||||
@@ -85,8 +88,8 @@ locals {
|
||||
data "kubernetes_all_namespaces" "allns" {}
|
||||
|
||||
resource "kubernetes_namespace" "automatic" {
|
||||
# for_each = { for key, value in var.kubernetes : key => value if value.enabled == true && !(value.block_namespace_creation) }
|
||||
for_each = { for key, value in var.kubernetes : key => value if value.enabled == true }
|
||||
# for_each = { for key, value in var.kubernetes : key => value if value.enabled == true && !(value.block_namespace_creation) }
|
||||
for_each = { for key, value in var.kubernetes : key => value if value.enabled == true && value.connected_namespace == "" }
|
||||
metadata {
|
||||
annotations = {
|
||||
name = coalesce(each.value.namespace, each.key)
|
||||
@@ -187,7 +190,7 @@ resource "kubernetes_service" "automatic_service" {
|
||||
for_each = { for key, value in var.kubernetes : key => value if value.service_port != null && value.enabled == true }
|
||||
metadata {
|
||||
name = "${each.key}-svc"
|
||||
namespace = coalesce(each.value.namespace, each.key)
|
||||
namespace = coalesce(each.value.namespace,each.value.connected_namespace, each.key)
|
||||
labels = {
|
||||
deployment_method = "Terraform"
|
||||
}
|
||||
@@ -264,7 +267,7 @@ resource "kubernetes_service" "automatic_service_redis" {
|
||||
resource "kubernetes_deployment_v1" "automatic" {
|
||||
for_each = { for key, value in var.kubernetes : key => value if value.enabled == true }
|
||||
metadata {
|
||||
namespace = coalesce(each.value.namespace, each.key)
|
||||
namespace = coalesce(each.value.namespace,each.value.connected_namespace, each.key)
|
||||
name = coalesce(each.value.name, each.key)
|
||||
|
||||
labels = {
|
||||
@@ -357,7 +360,20 @@ resource "kubernetes_deployment_v1" "automatic" {
|
||||
|
||||
}
|
||||
}
|
||||
dynamic "resources" {
|
||||
for_each = each.value.requirements != null ? [1] : []
|
||||
content {
|
||||
limits = {
|
||||
cpu = each.value.requirements.limits-cpu
|
||||
memory = each.value.requirements.limits-memory
|
||||
}
|
||||
requests = {
|
||||
cpu = each.value.requirements.requests-cpu
|
||||
memory = each.value.requirements.requests-memory
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
# resources {
|
||||
# limits = {
|
||||
|
||||
Reference in New Issue
Block a user