From 3732c3a9b1423ca08fe8ffc0d4d08c0f6434f1c6 Mon Sep 17 00:00:00 2001 From: mcayland Date: Wed, 21 Aug 2019 13:09:15 +0100 Subject: [PATCH] terraform/openstack: add network_dns_domain variable (#5093) This allows the user to optionally specify the dns_domain attribute on the generated internal kubernetes network. --- contrib/terraform/openstack/README.md | 1 + contrib/terraform/openstack/kubespray.tf | 13 +++++++------ contrib/terraform/openstack/modules/network/main.tf | 1 + .../openstack/modules/network/variables.tf | 2 ++ contrib/terraform/openstack/variables.tf | 6 ++++++ 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/contrib/terraform/openstack/README.md b/contrib/terraform/openstack/README.md index a1e5ea271..1e9975588 100644 --- a/contrib/terraform/openstack/README.md +++ b/contrib/terraform/openstack/README.md @@ -225,6 +225,7 @@ For your cluster, edit `inventory/$CLUSTER/cluster.tfvars`. |---------|-------------| |`cluster_name` | All OpenStack resources will use the Terraform variable`cluster_name` (default`example`) in their name to make it easier to track. For example the first compute resource will be named`example-kubernetes-1`. | |`network_name` | The name to be given to the internal network that will be generated | +|`network_dns_domain` | (Optional) The dns_domain for the internal network that will be generated | |`dns_nameservers`| An array of DNS name server names to be used by hosts in the internal subnet. | |`floatingip_pool` | Name of the pool from which floating IPs will be allocated | |`external_net` | UUID of the external network that will be routed to | diff --git a/contrib/terraform/openstack/kubespray.tf b/contrib/terraform/openstack/kubespray.tf index 7388abcbc..18d9d302d 100644 --- a/contrib/terraform/openstack/kubespray.tf +++ b/contrib/terraform/openstack/kubespray.tf @@ -5,12 +5,13 @@ provider "openstack" { module "network" { source = "./modules/network" - external_net = "${var.external_net}" - network_name = "${var.network_name}" - subnet_cidr = "${var.subnet_cidr}" - cluster_name = "${var.cluster_name}" - dns_nameservers = "${var.dns_nameservers}" - use_neutron = "${var.use_neutron}" + external_net = "${var.external_net}" + network_name = "${var.network_name}" + subnet_cidr = "${var.subnet_cidr}" + cluster_name = "${var.cluster_name}" + dns_nameservers = "${var.dns_nameservers}" + network_dns_domain = "${var.network_dns_domain}" + use_neutron = "${var.use_neutron}" } module "ips" { diff --git a/contrib/terraform/openstack/modules/network/main.tf b/contrib/terraform/openstack/modules/network/main.tf index 73141b823..0ab9d4630 100644 --- a/contrib/terraform/openstack/modules/network/main.tf +++ b/contrib/terraform/openstack/modules/network/main.tf @@ -8,6 +8,7 @@ resource "openstack_networking_router_v2" "k8s" { resource "openstack_networking_network_v2" "k8s" { name = "${var.network_name}" count = "${var.use_neutron}" + dns_domain = var.network_dns_domain != null ? "${var.network_dns_domain}" : null admin_state_up = "true" } diff --git a/contrib/terraform/openstack/modules/network/variables.tf b/contrib/terraform/openstack/modules/network/variables.tf index c19b7e2d7..99a7dd41d 100644 --- a/contrib/terraform/openstack/modules/network/variables.tf +++ b/contrib/terraform/openstack/modules/network/variables.tf @@ -2,6 +2,8 @@ variable "external_net" {} variable "network_name" {} +variable "network_dns_domain" {} + variable "cluster_name" {} variable "dns_nameservers" { diff --git a/contrib/terraform/openstack/variables.tf b/contrib/terraform/openstack/variables.tf index 60c2577e6..a8c2cf548 100644 --- a/contrib/terraform/openstack/variables.tf +++ b/contrib/terraform/openstack/variables.tf @@ -103,6 +103,12 @@ variable "network_name" { default = "internal" } +variable "network_dns_domain" { + description = "dns_domain for the internal network" + type = "string" + default = null +} + variable "use_neutron" { description = "Use neutron" default = 1