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.

34 lines
1.3 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. port_security_enabled = var.port_security_enabled
  17. }
  18. resource "openstack_networking_subnet_v2" "k8s" {
  19. name = "${var.cluster_name}-internal-network"
  20. count = var.use_neutron
  21. network_id = openstack_networking_network_v2.k8s[count.index].id
  22. cidr = var.subnet_cidr
  23. ip_version = 4
  24. dns_nameservers = var.dns_nameservers
  25. }
  26. resource "openstack_networking_router_interface_v2" "k8s" {
  27. count = var.use_neutron
  28. router_id = "%{if openstack_networking_router_v2.k8s != []}${openstack_networking_router_v2.k8s[count.index].id}%{else}${var.router_id}%{endif}"
  29. subnet_id = openstack_networking_subnet_v2.k8s[count.index].id
  30. }