2018-08-20 03:48:22 +02:00
|
|
|
# DNS record for the apiserver load balancer
|
|
|
|
resource "azurerm_dns_a_record" "apiserver" {
|
2019-05-28 06:43:08 +02:00
|
|
|
resource_group_name = var.dns_zone_group
|
2018-08-20 03:48:22 +02:00
|
|
|
|
|
|
|
# DNS Zone name where record should be created
|
2019-05-28 06:43:08 +02:00
|
|
|
zone_name = var.dns_zone
|
2018-08-20 03:48:22 +02:00
|
|
|
|
|
|
|
# DNS record
|
2019-05-28 06:43:08 +02:00
|
|
|
name = var.cluster_name
|
2018-08-20 03:48:22 +02:00
|
|
|
ttl = 300
|
|
|
|
|
|
|
|
# IPv4 address of apiserver load balancer
|
2019-05-28 06:43:08 +02:00
|
|
|
records = [azurerm_public_ip.apiserver-ipv4.ip_address]
|
2018-08-20 03:48:22 +02:00
|
|
|
}
|
|
|
|
|
2018-08-28 06:30:26 +02:00
|
|
|
# Static IPv4 address for the apiserver frontend
|
|
|
|
resource "azurerm_public_ip" "apiserver-ipv4" {
|
2019-05-28 06:43:08 +02:00
|
|
|
resource_group_name = azurerm_resource_group.cluster.name
|
2018-08-20 03:48:22 +02:00
|
|
|
|
2019-01-28 02:52:35 +01:00
|
|
|
name = "${var.cluster_name}-apiserver-ipv4"
|
2019-05-28 06:43:08 +02:00
|
|
|
location = var.region
|
2019-01-28 02:52:35 +01:00
|
|
|
sku = "Standard"
|
|
|
|
allocation_method = "Static"
|
2018-08-28 06:30:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Static IPv4 address for the ingress frontend
|
|
|
|
resource "azurerm_public_ip" "ingress-ipv4" {
|
2019-05-28 06:43:08 +02:00
|
|
|
resource_group_name = azurerm_resource_group.cluster.name
|
2018-08-28 06:30:26 +02:00
|
|
|
|
2019-01-28 02:52:35 +01:00
|
|
|
name = "${var.cluster_name}-ingress-ipv4"
|
2019-05-28 06:43:08 +02:00
|
|
|
location = var.region
|
2019-01-28 02:52:35 +01:00
|
|
|
sku = "Standard"
|
|
|
|
allocation_method = "Static"
|
2018-08-20 03:48:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Network Load Balancer for apiservers and ingress
|
|
|
|
resource "azurerm_lb" "cluster" {
|
2019-05-28 06:43:08 +02:00
|
|
|
resource_group_name = azurerm_resource_group.cluster.name
|
2018-08-20 03:48:22 +02:00
|
|
|
|
2019-05-28 06:43:08 +02:00
|
|
|
name = var.cluster_name
|
|
|
|
location = var.region
|
2018-08-20 03:48:22 +02:00
|
|
|
sku = "Standard"
|
|
|
|
|
|
|
|
frontend_ip_configuration {
|
2018-08-28 06:30:26 +02:00
|
|
|
name = "apiserver"
|
2019-05-28 06:43:08 +02:00
|
|
|
public_ip_address_id = azurerm_public_ip.apiserver-ipv4.id
|
2018-08-28 06:30:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
frontend_ip_configuration {
|
|
|
|
name = "ingress"
|
2019-05-28 06:43:08 +02:00
|
|
|
public_ip_address_id = azurerm_public_ip.ingress-ipv4.id
|
2018-08-20 03:48:22 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "azurerm_lb_rule" "apiserver" {
|
2019-05-28 06:43:08 +02:00
|
|
|
resource_group_name = azurerm_resource_group.cluster.name
|
2018-08-20 03:48:22 +02:00
|
|
|
|
|
|
|
name = "apiserver"
|
2019-05-28 06:43:08 +02:00
|
|
|
loadbalancer_id = azurerm_lb.cluster.id
|
2018-08-28 06:30:26 +02:00
|
|
|
frontend_ip_configuration_name = "apiserver"
|
2018-08-20 03:48:22 +02:00
|
|
|
|
|
|
|
protocol = "Tcp"
|
|
|
|
frontend_port = 6443
|
|
|
|
backend_port = 6443
|
2019-05-28 06:43:08 +02:00
|
|
|
backend_address_pool_id = azurerm_lb_backend_address_pool.controller.id
|
|
|
|
probe_id = azurerm_lb_probe.apiserver.id
|
2018-08-20 03:48:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
resource "azurerm_lb_rule" "ingress-http" {
|
2019-05-28 06:43:08 +02:00
|
|
|
resource_group_name = azurerm_resource_group.cluster.name
|
2018-08-20 03:48:22 +02:00
|
|
|
|
|
|
|
name = "ingress-http"
|
2019-05-28 06:43:08 +02:00
|
|
|
loadbalancer_id = azurerm_lb.cluster.id
|
2018-08-28 06:30:26 +02:00
|
|
|
frontend_ip_configuration_name = "ingress"
|
2020-04-01 05:28:27 +02:00
|
|
|
disable_outbound_snat = true
|
2018-08-20 03:48:22 +02:00
|
|
|
|
|
|
|
protocol = "Tcp"
|
|
|
|
frontend_port = 80
|
|
|
|
backend_port = 80
|
2019-05-28 06:43:08 +02:00
|
|
|
backend_address_pool_id = azurerm_lb_backend_address_pool.worker.id
|
|
|
|
probe_id = azurerm_lb_probe.ingress.id
|
2018-08-20 03:48:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
resource "azurerm_lb_rule" "ingress-https" {
|
2019-05-28 06:43:08 +02:00
|
|
|
resource_group_name = azurerm_resource_group.cluster.name
|
2018-08-20 03:48:22 +02:00
|
|
|
|
|
|
|
name = "ingress-https"
|
2019-05-28 06:43:08 +02:00
|
|
|
loadbalancer_id = azurerm_lb.cluster.id
|
2018-08-28 06:30:26 +02:00
|
|
|
frontend_ip_configuration_name = "ingress"
|
2020-04-01 05:28:27 +02:00
|
|
|
disable_outbound_snat = true
|
2018-08-20 03:48:22 +02:00
|
|
|
|
|
|
|
protocol = "Tcp"
|
|
|
|
frontend_port = 443
|
|
|
|
backend_port = 443
|
2019-05-28 06:43:08 +02:00
|
|
|
backend_address_pool_id = azurerm_lb_backend_address_pool.worker.id
|
|
|
|
probe_id = azurerm_lb_probe.ingress.id
|
2018-08-20 03:48:22 +02:00
|
|
|
}
|
|
|
|
|
2020-04-01 05:28:27 +02:00
|
|
|
# Worker outbound TCP/UDP SNAT
|
|
|
|
resource "azurerm_lb_outbound_rule" "worker-outbound" {
|
|
|
|
resource_group_name = azurerm_resource_group.cluster.name
|
|
|
|
|
|
|
|
name = "worker"
|
|
|
|
loadbalancer_id = azurerm_lb.cluster.id
|
|
|
|
frontend_ip_configuration {
|
|
|
|
name = "ingress"
|
|
|
|
}
|
|
|
|
|
|
|
|
protocol = "All"
|
|
|
|
backend_address_pool_id = azurerm_lb_backend_address_pool.worker.id
|
|
|
|
}
|
|
|
|
|
2018-08-20 03:48:22 +02:00
|
|
|
# Address pool of controllers
|
|
|
|
resource "azurerm_lb_backend_address_pool" "controller" {
|
2019-05-28 06:43:08 +02:00
|
|
|
resource_group_name = azurerm_resource_group.cluster.name
|
2018-08-20 03:48:22 +02:00
|
|
|
|
|
|
|
name = "controller"
|
2019-05-28 06:43:08 +02:00
|
|
|
loadbalancer_id = azurerm_lb.cluster.id
|
2018-08-20 03:48:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Address pool of workers
|
|
|
|
resource "azurerm_lb_backend_address_pool" "worker" {
|
2019-05-28 06:43:08 +02:00
|
|
|
resource_group_name = azurerm_resource_group.cluster.name
|
2018-08-20 03:48:22 +02:00
|
|
|
|
|
|
|
name = "worker"
|
2019-05-28 06:43:08 +02:00
|
|
|
loadbalancer_id = azurerm_lb.cluster.id
|
2018-08-20 03:48:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Health checks / probes
|
|
|
|
|
|
|
|
# TCP health check for apiserver
|
|
|
|
resource "azurerm_lb_probe" "apiserver" {
|
2019-05-28 06:43:08 +02:00
|
|
|
resource_group_name = azurerm_resource_group.cluster.name
|
2018-08-20 03:48:22 +02:00
|
|
|
|
|
|
|
name = "apiserver"
|
2019-05-28 06:43:08 +02:00
|
|
|
loadbalancer_id = azurerm_lb.cluster.id
|
2018-08-20 03:48:22 +02:00
|
|
|
protocol = "Tcp"
|
|
|
|
port = 6443
|
|
|
|
|
|
|
|
# unhealthy threshold
|
|
|
|
number_of_probes = 3
|
|
|
|
|
|
|
|
interval_in_seconds = 5
|
|
|
|
}
|
|
|
|
|
|
|
|
# HTTP health check for ingress
|
|
|
|
resource "azurerm_lb_probe" "ingress" {
|
2019-05-28 06:43:08 +02:00
|
|
|
resource_group_name = azurerm_resource_group.cluster.name
|
2018-08-20 03:48:22 +02:00
|
|
|
|
|
|
|
name = "ingress"
|
2019-05-28 06:43:08 +02:00
|
|
|
loadbalancer_id = azurerm_lb.cluster.id
|
2018-08-20 03:48:22 +02:00
|
|
|
protocol = "Http"
|
|
|
|
port = 10254
|
|
|
|
request_path = "/healthz"
|
|
|
|
|
|
|
|
# unhealthy threshold
|
|
|
|
number_of_probes = 3
|
|
|
|
|
|
|
|
interval_in_seconds = 5
|
|
|
|
}
|
2019-05-28 06:43:08 +02:00
|
|
|
|