2017-12-05 12:48:47 +00:00
|
|
|
resource "openstack_networking_router_v2" "k8s" {
|
2018-02-23 06:41:19 +00:00
|
|
|
name = "${var.cluster_name}-router"
|
2020-06-05 07:05:43 +00:00
|
|
|
count = var.use_neutron == 1 && var.router_id == null ? 1 : 0
|
2018-02-23 06:41:19 +00:00
|
|
|
admin_state_up = "true"
|
2020-06-05 07:05:43 +00:00
|
|
|
external_network_id = var.external_net
|
2017-12-05 12:48:47 +00:00
|
|
|
}
|
|
|
|
|
2020-04-06 09:41:46 +00:00
|
|
|
data "openstack_networking_router_v2" "k8s" {
|
2020-06-05 07:05:43 +00:00
|
|
|
router_id = var.router_id
|
|
|
|
count = var.use_neutron == 1 && var.router_id != null ? 1 : 0
|
2020-04-06 09:41:46 +00:00
|
|
|
}
|
|
|
|
|
2017-12-05 12:48:47 +00:00
|
|
|
resource "openstack_networking_network_v2" "k8s" {
|
2020-06-05 07:05:43 +00:00
|
|
|
name = var.network_name
|
|
|
|
count = var.use_neutron
|
|
|
|
dns_domain = var.network_dns_domain != null ? var.network_dns_domain : null
|
2017-12-05 12:48:47 +00:00
|
|
|
admin_state_up = "true"
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "openstack_networking_subnet_v2" "k8s" {
|
|
|
|
name = "${var.cluster_name}-internal-network"
|
2020-06-05 07:05:43 +00:00
|
|
|
count = var.use_neutron
|
|
|
|
network_id = openstack_networking_network_v2.k8s[count.index].id
|
|
|
|
cidr = var.subnet_cidr
|
2017-12-05 12:48:47 +00:00
|
|
|
ip_version = 4
|
2020-06-05 07:05:43 +00:00
|
|
|
dns_nameservers = var.dns_nameservers
|
2017-12-05 12:48:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
resource "openstack_networking_router_interface_v2" "k8s" {
|
2020-06-05 07:05:43 +00:00
|
|
|
count = var.use_neutron
|
2020-04-09 09:27:44 +00:00
|
|
|
router_id = "%{if openstack_networking_router_v2.k8s != []}${openstack_networking_router_v2.k8s[count.index].id}%{else}${var.router_id}%{endif}"
|
2020-06-05 07:05:43 +00:00
|
|
|
subnet_id = openstack_networking_subnet_v2.k8s[count.index].id
|
2017-12-05 12:48:47 +00:00
|
|
|
}
|