From 019009e9ee05835b5d5a36d4d19ed17c408c2b12 Mon Sep 17 00:00:00 2001 From: Dalton Hubble Date: Mon, 27 Aug 2018 21:30:26 -0700 Subject: [PATCH] Add outputs for Azure ingress IPv4 and worker pools --- azure/container-linux/kubernetes/lb.tf | 33 ++++++++++++++----- azure/container-linux/kubernetes/outputs.tf | 32 ++++++++++++++++++ azure/container-linux/kubernetes/workers.tf | 9 +++-- .../kubernetes/workers/variables.tf | 6 ---- .../kubernetes/workers/workers.tf | 7 ++-- docs/cl/azure.md | 2 +- 6 files changed, 65 insertions(+), 24 deletions(-) create mode 100644 azure/container-linux/kubernetes/outputs.tf diff --git a/azure/container-linux/kubernetes/lb.tf b/azure/container-linux/kubernetes/lb.tf index 9e005231..c15b5906 100644 --- a/azure/container-linux/kubernetes/lb.tf +++ b/azure/container-linux/kubernetes/lb.tf @@ -10,14 +10,24 @@ resource "azurerm_dns_a_record" "apiserver" { ttl = 300 # IPv4 address of apiserver load balancer - records = ["${azurerm_public_ip.lb-ipv4.ip_address}"] + records = ["${azurerm_public_ip.apiserver-ipv4.ip_address}"] } -# Static IPv4 address for the cluster load balancer -resource "azurerm_public_ip" "lb-ipv4" { +# Static IPv4 address for the apiserver frontend +resource "azurerm_public_ip" "apiserver-ipv4" { resource_group_name = "${azurerm_resource_group.cluster.name}" - name = "${var.cluster_name}-lb-ipv4" + name = "${var.cluster_name}-apiserver-ipv4" + location = "${var.region}" + sku = "Standard" + public_ip_address_allocation = "static" +} + +# Static IPv4 address for the ingress frontend +resource "azurerm_public_ip" "ingress-ipv4" { + resource_group_name = "${azurerm_resource_group.cluster.name}" + + name = "${var.cluster_name}-ingress-ipv4" location = "${var.region}" sku = "Standard" public_ip_address_allocation = "static" @@ -32,8 +42,13 @@ resource "azurerm_lb" "cluster" { sku = "Standard" frontend_ip_configuration { - name = "public" - public_ip_address_id = "${azurerm_public_ip.lb-ipv4.id}" + name = "apiserver" + public_ip_address_id = "${azurerm_public_ip.apiserver-ipv4.id}" + } + + frontend_ip_configuration { + name = "ingress" + public_ip_address_id = "${azurerm_public_ip.ingress-ipv4.id}" } } @@ -42,7 +57,7 @@ resource "azurerm_lb_rule" "apiserver" { name = "apiserver" loadbalancer_id = "${azurerm_lb.cluster.id}" - frontend_ip_configuration_name = "public" + frontend_ip_configuration_name = "apiserver" protocol = "Tcp" frontend_port = 6443 @@ -56,7 +71,7 @@ resource "azurerm_lb_rule" "ingress-http" { name = "ingress-http" loadbalancer_id = "${azurerm_lb.cluster.id}" - frontend_ip_configuration_name = "public" + frontend_ip_configuration_name = "ingress" protocol = "Tcp" frontend_port = 80 @@ -70,7 +85,7 @@ resource "azurerm_lb_rule" "ingress-https" { name = "ingress-https" loadbalancer_id = "${azurerm_lb.cluster.id}" - frontend_ip_configuration_name = "public" + frontend_ip_configuration_name = "ingress" protocol = "Tcp" frontend_port = 443 diff --git a/azure/container-linux/kubernetes/outputs.tf b/azure/container-linux/kubernetes/outputs.tf new file mode 100644 index 00000000..2f58898e --- /dev/null +++ b/azure/container-linux/kubernetes/outputs.tf @@ -0,0 +1,32 @@ +# Outputs for Kubernetes Ingress + +output "ingress_static_ipv4" { + value = "${azurerm_public_ip.ingress-ipv4.ip_address}" + description = "IPv4 address of the load balancer for distributing traffic to Ingress controllers" +} + +# Outputs for worker pools + +output "region" { + value = "${azurerm_resource_group.cluster.location}" +} + +output "resource_group_name" { + value = "${azurerm_resource_group.cluster.name}" +} + +output "subnet_id" { + value = "${azurerm_subnet.worker.id}" +} + +output "security_group_id" { + value = "${azurerm_network_security_group.worker.id}" +} + +output "backend_address_pool_id" { + value = "${azurerm_lb_backend_address_pool.worker.id}" +} + +output "kubeconfig" { + value = "${module.bootkube.kubeconfig}" +} diff --git a/azure/container-linux/kubernetes/workers.tf b/azure/container-linux/kubernetes/workers.tf index 46bfb5e7..12c7a754 100644 --- a/azure/container-linux/kubernetes/workers.tf +++ b/azure/container-linux/kubernetes/workers.tf @@ -9,11 +9,10 @@ module "workers" { security_group_id = "${azurerm_network_security_group.worker.id}" backend_address_pool_id = "${azurerm_lb_backend_address_pool.worker.id}" - count = "${var.worker_count}" - vm_type = "${var.worker_type}" - os_image = "${var.os_image}" - disk_size = "${var.disk_size}" - priority = "${var.worker_priority}" + count = "${var.worker_count}" + vm_type = "${var.worker_type}" + os_image = "${var.os_image}" + priority = "${var.worker_priority}" # configuration kubeconfig = "${module.bootkube.kubeconfig}" diff --git a/azure/container-linux/kubernetes/workers/variables.tf b/azure/container-linux/kubernetes/workers/variables.tf index a33a5beb..181fe892 100644 --- a/azure/container-linux/kubernetes/workers/variables.tf +++ b/azure/container-linux/kubernetes/workers/variables.tf @@ -50,12 +50,6 @@ variable "os_image" { description = "Channel for a Container Linux derivative (coreos-stable, coreos-beta, coreos-alpha)" } -variable "disk_size" { - type = "string" - default = "40" - description = "Size of the disk in GB" -} - variable "priority" { type = "string" default = "Regular" diff --git a/azure/container-linux/kubernetes/workers/workers.tf b/azure/container-linux/kubernetes/workers/workers.tf index 9f01bc48..13e1ecf5 100644 --- a/azure/container-linux/kubernetes/workers/workers.tf +++ b/azure/container-linux/kubernetes/workers/workers.tf @@ -8,8 +8,9 @@ locals { resource "azurerm_virtual_machine_scale_set" "workers" { resource_group_name = "${var.resource_group_name}" - name = "${var.name}-workers" - location = "${var.region}" + name = "${var.name}-workers" + location = "${var.region}" + single_placement_group = false sku { name = "${var.vm_type}" @@ -76,7 +77,7 @@ resource "azurerm_virtual_machine_scale_set" "workers" { resource "azurerm_autoscale_setting" "workers" { resource_group_name = "${var.resource_group_name}" - name = "maintain-desired" + name = "${var.name}-maintain-desired" location = "${var.region}" # autoscale diff --git a/docs/cl/azure.md b/docs/cl/azure.md index cc4ded1c..543e36f3 100644 --- a/docs/cl/azure.md +++ b/docs/cl/azure.md @@ -267,7 +267,7 @@ Reference the DNS zone with `"${azurerm_dns_zone.clusters.name}"` and its resour Check the list of valid [machine types](https://azure.microsoft.com/en-us/pricing/details/virtual-machines/linux/) and their [specs](https://docs.microsoft.com/en-us/azure/virtual-machines/linux/sizes-general). Use `az vm list-skus` to get the identifier. !!! warning - Unlike AWS and GCP, Azure requires its *virtual* networks to have unique, non-overlapping IPv4 CIDRs (yeah, go figure). Instead of each cluster just using `10.0.0.0/16` for instances, each Azure cluster's `host_cidr` must be non-overlapping (e.g. 10.0.0.0/20 for the 1st cluster, 10.0.16.0/20 for the 2nd cluster, etc). + Unlike AWS and GCP, Azure requires its *virtual* networks to have non-overlapping IPv4 CIDRs (yeah, go figure). Instead of each cluster just using `10.0.0.0/16` for instances, each Azure cluster's `host_cidr` must be non-overlapping (e.g. 10.0.0.0/20 for the 1st cluster, 10.0.16.0/20 for the 2nd cluster, etc). !!! warning Do not choose a `controller_type` smaller than `Standard_DS1_v2`. Smaller instances are not sufficient for running a controller.