-
Notifications
You must be signed in to change notification settings - Fork 14
/
locals.tf
46 lines (35 loc) · 2.13 KB
/
locals.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Copyright © 2022-2024, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
locals {
# Systems
# Kubernetes
cluster_name = "${var.prefix}-oss"
## User defined node_pools
node_pools = var.node_pools == null ? {} : { for k, v in var.node_pools : k => merge(var.node_pool_defaults, v, ) }
node_labels = var.node_pools == null ? {} : { for k, v in local.node_pools : k => [for lk, lv in v.node_labels : "${lk}=${lv}"] }
node_taints = var.node_pools == null ? {} : { for k, v in local.node_pools : k => v.node_taints }
## Control plane nodes
control_plane_nodes = local.node_pools == null ? {} : { for k, v in local.node_pools : k => v if k == "control_plane" }
control_plane_ips = flatten(sort(flatten([for item in values(module.control_plane) : values(item)])))
## System nodes
system_nodes = local.node_pools == null ? {} : { for k, v in local.node_pools : k => v if k == "system" }
# system_node_ips = flatten(sort(flatten([for item in values(module.system) : values(item)]))) not used, ref for future use
## Nodes
nodes = local.node_pools == null ? {} : { for k, v in local.node_pools : k => v if(k != "control_plane" && k != "system") }
node_ips = flatten(sort(flatten([for item in values(merge(module.system, module.node)) : values(item)])))
## Load Balancer addresses and data items for kube-vip and MetalLB
loadbalancer_addresses = var.cluster_lb_addresses != null ? length(var.cluster_lb_addresses) > 0 ? [for v in var.cluster_lb_addresses : v] : null : null
# PostgreSQL
postgres_servers = var.postgres_servers == null ? {} : { for k, v in var.postgres_servers : k => merge(var.postgres_server_defaults, v, ) }
postgres_outputs = length(local.postgres_servers) != 0 ? { for k, v in local.postgres_servers :
k => {
"server_name" : "${local.cluster_name}-${k}-pgsql",
"fqdn" : "${local.cluster_name}-${k}-pgsql.${var.cluster_domain}",
"admin" : v.administrator_login,
"password" : v.administrator_password,
"server_port" : "5432",
"ssl_enforcement_enabled" : v.server_ssl == "off" ? false : true
"internal" : false
}
} : {}
}