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-04-06 09:41:46 +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"
|
|
|
|
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" {
|
|
|
|
router_id = "${var.router_id}"
|
|
|
|
count = "${var.use_neutron}" == 1 && "${var.router_id}" != null ? 1 : 0
|
|
|
|
}
|
|
|
|
|
2017-12-05 12:48:47 +00:00
|
|
|
resource "openstack_networking_network_v2" "k8s" {
|
|
|
|
name = "${var.network_name}"
|
2018-10-19 10:39:34 +00:00
|
|
|
count = "${var.use_neutron}"
|
2019-08-21 12:09:15 +00:00
|
|
|
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"
|
2018-10-19 10:39:34 +00:00
|
|
|
count = "${var.use_neutron}"
|
2019-08-18 08:30:05 +00:00
|
|
|
network_id = "${openstack_networking_network_v2.k8s[count.index].id}"
|
2018-06-14 16:40:32 +00:00
|
|
|
cidr = "${var.subnet_cidr}"
|
2017-12-05 12:48:47 +00:00
|
|
|
ip_version = 4
|
|
|
|
dns_nameservers = "${var.dns_nameservers}"
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "openstack_networking_router_interface_v2" "k8s" {
|
2018-10-19 10:39:34 +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}"
|
2019-08-18 08:30:05 +00:00
|
|
|
subnet_id = "${openstack_networking_subnet_v2.k8s[count.index].id}"
|
2017-12-05 12:48:47 +00:00
|
|
|
}
|