2017-12-05 20:48:47 +08:00
|
|
|
resource "openstack_networking_router_v2" "k8s" {
|
2018-02-23 14:41:19 +08:00
|
|
|
name = "${var.cluster_name}-router"
|
2020-04-06 17:41:46 +08:00
|
|
|
count = "${var.use_neutron}" == 1 && "${var.router_id}" == null ? 1 : 0
|
2018-02-23 14:41:19 +08:00
|
|
|
admin_state_up = "true"
|
|
|
|
external_network_id = "${var.external_net}"
|
2017-12-05 20:48:47 +08:00
|
|
|
}
|
|
|
|
|
2020-04-06 17:41:46 +08: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 20:48:47 +08:00
|
|
|
resource "openstack_networking_network_v2" "k8s" {
|
|
|
|
name = "${var.network_name}"
|
2018-10-19 18:39:34 +08:00
|
|
|
count = "${var.use_neutron}"
|
2019-08-21 20:09:15 +08:00
|
|
|
dns_domain = var.network_dns_domain != null ? "${var.network_dns_domain}" : null
|
2017-12-05 20:48:47 +08:00
|
|
|
admin_state_up = "true"
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "openstack_networking_subnet_v2" "k8s" {
|
|
|
|
name = "${var.cluster_name}-internal-network"
|
2018-10-19 18:39:34 +08:00
|
|
|
count = "${var.use_neutron}"
|
2019-08-18 16:30:05 +08:00
|
|
|
network_id = "${openstack_networking_network_v2.k8s[count.index].id}"
|
2018-06-15 00:40:32 +08:00
|
|
|
cidr = "${var.subnet_cidr}"
|
2017-12-05 20:48:47 +08:00
|
|
|
ip_version = 4
|
|
|
|
dns_nameservers = "${var.dns_nameservers}"
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "openstack_networking_router_interface_v2" "k8s" {
|
2018-10-19 18:39:34 +08:00
|
|
|
count = "${var.use_neutron}"
|
2020-04-09 17:27:44 +08: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 16:30:05 +08:00
|
|
|
subnet_id = "${openstack_networking_subnet_v2.k8s[count.index].id}"
|
2017-12-05 20:48:47 +08:00
|
|
|
}
|