You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
1.2 KiB

  1. resource "openstack_networking_router_v2" "k8s" {
  2. name = "${var.cluster_name}-router"
  3. count = var.use_neutron == 1 && var.router_id == null ? 1 : 0
  4. admin_state_up = "true"
  5. external_network_id = var.external_net
  6. }
  7. data "openstack_networking_router_v2" "k8s" {
  8. router_id = var.router_id
  9. count = var.use_neutron == 1 && var.router_id != null ? 1 : 0
  10. }
  11. resource "openstack_networking_network_v2" "k8s" {
  12. name = var.network_name
  13. count = var.use_neutron
  14. dns_domain = var.network_dns_domain != null ? var.network_dns_domain : null
  15. admin_state_up = "true"
  16. }
  17. resource "openstack_networking_subnet_v2" "k8s" {
  18. name = "${var.cluster_name}-internal-network"
  19. count = var.use_neutron
  20. network_id = openstack_networking_network_v2.k8s[count.index].id
  21. cidr = var.subnet_cidr
  22. ip_version = 4
  23. dns_nameservers = var.dns_nameservers
  24. }
  25. resource "openstack_networking_router_interface_v2" "k8s" {
  26. count = var.use_neutron
  27. router_id = "%{if openstack_networking_router_v2.k8s != []}${openstack_networking_router_v2.k8s[count.index].id}%{else}${var.router_id}%{endif}"
  28. subnet_id = openstack_networking_subnet_v2.k8s[count.index].id
  29. }