Skip to content

Commit

Permalink
Add outputs for Azure ingress IPv4 and worker pools
Browse files Browse the repository at this point in the history
  • Loading branch information
dghubble committed Aug 28, 2018
1 parent 991a5c6 commit 019009e
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 24 deletions.
33 changes: 24 additions & 9 deletions azure/container-linux/kubernetes/lb.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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}"
}
}

Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
32 changes: 32 additions & 0 deletions azure/container-linux/kubernetes/outputs.tf
Original file line number Diff line number Diff line change
@@ -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}"
}
9 changes: 4 additions & 5 deletions azure/container-linux/kubernetes/workers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
6 changes: 0 additions & 6 deletions azure/container-linux/kubernetes/workers/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
7 changes: 4 additions & 3 deletions azure/container-linux/kubernetes/workers/workers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/cl/azure.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 019009e

Please sign in to comment.