Add outputs for Azure ingress IPv4 and worker pools

This commit is contained in:
Dalton Hubble 2018-08-27 21:30:26 -07:00
parent 991a5c6cee
commit 019009e9ee
6 changed files with 65 additions and 24 deletions

View File

@ -10,14 +10,24 @@ resource "azurerm_dns_a_record" "apiserver" {
ttl = 300 ttl = 300
# IPv4 address of apiserver load balancer # 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 # Static IPv4 address for the apiserver frontend
resource "azurerm_public_ip" "lb-ipv4" { resource "azurerm_public_ip" "apiserver-ipv4" {
resource_group_name = "${azurerm_resource_group.cluster.name}" 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}" location = "${var.region}"
sku = "Standard" sku = "Standard"
public_ip_address_allocation = "static" public_ip_address_allocation = "static"
@ -32,8 +42,13 @@ resource "azurerm_lb" "cluster" {
sku = "Standard" sku = "Standard"
frontend_ip_configuration { frontend_ip_configuration {
name = "public" name = "apiserver"
public_ip_address_id = "${azurerm_public_ip.lb-ipv4.id}" 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" name = "apiserver"
loadbalancer_id = "${azurerm_lb.cluster.id}" loadbalancer_id = "${azurerm_lb.cluster.id}"
frontend_ip_configuration_name = "public" frontend_ip_configuration_name = "apiserver"
protocol = "Tcp" protocol = "Tcp"
frontend_port = 6443 frontend_port = 6443
@ -56,7 +71,7 @@ resource "azurerm_lb_rule" "ingress-http" {
name = "ingress-http" name = "ingress-http"
loadbalancer_id = "${azurerm_lb.cluster.id}" loadbalancer_id = "${azurerm_lb.cluster.id}"
frontend_ip_configuration_name = "public" frontend_ip_configuration_name = "ingress"
protocol = "Tcp" protocol = "Tcp"
frontend_port = 80 frontend_port = 80
@ -70,7 +85,7 @@ resource "azurerm_lb_rule" "ingress-https" {
name = "ingress-https" name = "ingress-https"
loadbalancer_id = "${azurerm_lb.cluster.id}" loadbalancer_id = "${azurerm_lb.cluster.id}"
frontend_ip_configuration_name = "public" frontend_ip_configuration_name = "ingress"
protocol = "Tcp" protocol = "Tcp"
frontend_port = 443 frontend_port = 443

View File

@ -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}"
}

View File

@ -12,7 +12,6 @@ module "workers" {
count = "${var.worker_count}" count = "${var.worker_count}"
vm_type = "${var.worker_type}" vm_type = "${var.worker_type}"
os_image = "${var.os_image}" os_image = "${var.os_image}"
disk_size = "${var.disk_size}"
priority = "${var.worker_priority}" priority = "${var.worker_priority}"
# configuration # configuration

View File

@ -50,12 +50,6 @@ variable "os_image" {
description = "Channel for a Container Linux derivative (coreos-stable, coreos-beta, coreos-alpha)" 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" { variable "priority" {
type = "string" type = "string"
default = "Regular" default = "Regular"

View File

@ -10,6 +10,7 @@ resource "azurerm_virtual_machine_scale_set" "workers" {
name = "${var.name}-workers" name = "${var.name}-workers"
location = "${var.region}" location = "${var.region}"
single_placement_group = false
sku { sku {
name = "${var.vm_type}" name = "${var.vm_type}"
@ -76,7 +77,7 @@ resource "azurerm_virtual_machine_scale_set" "workers" {
resource "azurerm_autoscale_setting" "workers" { resource "azurerm_autoscale_setting" "workers" {
resource_group_name = "${var.resource_group_name}" resource_group_name = "${var.resource_group_name}"
name = "maintain-desired" name = "${var.name}-maintain-desired"
location = "${var.region}" location = "${var.region}"
# autoscale # autoscale

View File

@ -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. 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 !!! 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 !!! warning
Do not choose a `controller_type` smaller than `Standard_DS1_v2`. Smaller instances are not sufficient for running a controller. Do not choose a `controller_type` smaller than `Standard_DS1_v2`. Smaller instances are not sufficient for running a controller.