mirror of
https://github.com/kubernetes-sigs/kubespray.git
synced 2026-02-01 01:28:11 -03:30
Add support to use exisitng fips with terraform openstack (#11558)
This commit is contained in:
@@ -89,11 +89,15 @@ variable "k8s_node_fips" {
|
||||
}
|
||||
|
||||
variable "k8s_masters_fips" {
|
||||
type = map
|
||||
type = map(object({
|
||||
address = string
|
||||
}))
|
||||
}
|
||||
|
||||
variable "k8s_nodes_fips" {
|
||||
type = map
|
||||
type = map(object({
|
||||
address = string
|
||||
}))
|
||||
}
|
||||
|
||||
variable "bastion_fips" {
|
||||
@@ -136,8 +140,9 @@ variable "k8s_masters" {
|
||||
type = map(object({
|
||||
az = string
|
||||
flavor = string
|
||||
floating_ip = bool
|
||||
etcd = bool
|
||||
floating_ip = bool
|
||||
reserved_floating_ip = optional(string)
|
||||
image_id = optional(string)
|
||||
root_volume_size_in_gb = optional(number)
|
||||
volume_type = optional(string)
|
||||
@@ -150,6 +155,7 @@ variable "k8s_nodes" {
|
||||
az = string
|
||||
flavor = string
|
||||
floating_ip = bool
|
||||
reserved_floating_ip = optional(string)
|
||||
extra_groups = optional(string)
|
||||
image_id = optional(string)
|
||||
root_volume_size_in_gb = optional(number)
|
||||
|
||||
@@ -15,7 +15,7 @@ resource "openstack_networking_floatingip_v2" "k8s_master" {
|
||||
}
|
||||
|
||||
resource "openstack_networking_floatingip_v2" "k8s_masters" {
|
||||
for_each = var.number_of_k8s_masters == 0 && var.number_of_k8s_masters_no_etcd == 0 ? { for key, value in var.k8s_masters : key => value if value.floating_ip } : {}
|
||||
for_each = var.number_of_k8s_masters == 0 && var.number_of_k8s_masters_no_etcd == 0 ? { for key, value in var.k8s_masters : key => value if value.floating_ip && (lookup(value, "reserved_floating_ip", "") == "") } : {}
|
||||
pool = var.floatingip_pool
|
||||
depends_on = [null_resource.dummy_dependency]
|
||||
}
|
||||
@@ -40,7 +40,7 @@ resource "openstack_networking_floatingip_v2" "bastion" {
|
||||
}
|
||||
|
||||
resource "openstack_networking_floatingip_v2" "k8s_nodes" {
|
||||
for_each = var.number_of_k8s_nodes == 0 ? { for key, value in var.k8s_nodes : key => value if value.floating_ip } : {}
|
||||
for_each = var.number_of_k8s_nodes == 0 ? { for key, value in var.k8s_nodes : key => value if value.floating_ip && (lookup(value, "reserved_floating_ip", "") == "") } : {}
|
||||
pool = var.floatingip_pool
|
||||
depends_on = [null_resource.dummy_dependency]
|
||||
}
|
||||
|
||||
@@ -1,10 +1,33 @@
|
||||
locals {
|
||||
k8s_masters_reserved_fips = {
|
||||
for key, value in var.k8s_masters : key => {
|
||||
address = value.reserved_floating_ip
|
||||
} if value.floating_ip && (lookup(value, "reserved_floating_ip", "") != "")
|
||||
}
|
||||
k8s_masters_create_fips = {
|
||||
for key, value in openstack_networking_floatingip_v2.k8s_masters : key => {
|
||||
address = value.address
|
||||
}
|
||||
}
|
||||
k8s_nodes_reserved_fips = {
|
||||
for key, value in var.k8s_nodes : key => {
|
||||
address = value.reserved_floating_ip
|
||||
} if value.floating_ip && (lookup(value, "reserved_floating_ip", "") != "")
|
||||
}
|
||||
k8s_nodes_create_fips = {
|
||||
for key, value in openstack_networking_floatingip_v2.k8s_nodes : key => {
|
||||
address = value.address
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# If k8s_master_fips is already defined as input, keep the same value since new FIPs have not been created.
|
||||
output "k8s_master_fips" {
|
||||
value = length(var.k8s_master_fips) > 0 ? var.k8s_master_fips : openstack_networking_floatingip_v2.k8s_master[*].address
|
||||
}
|
||||
|
||||
output "k8s_masters_fips" {
|
||||
value = openstack_networking_floatingip_v2.k8s_masters
|
||||
value = merge(local.k8s_masters_create_fips, local.k8s_masters_reserved_fips)
|
||||
}
|
||||
|
||||
# If k8s_master_fips is already defined as input, keep the same value since new FIPs have not been created.
|
||||
@@ -17,7 +40,7 @@ output "k8s_node_fips" {
|
||||
}
|
||||
|
||||
output "k8s_nodes_fips" {
|
||||
value = openstack_networking_floatingip_v2.k8s_nodes
|
||||
value = merge(local.k8s_nodes_create_fips, local.k8s_nodes_reserved_fips)
|
||||
}
|
||||
|
||||
output "bastion_fips" {
|
||||
|
||||
Reference in New Issue
Block a user