Skip to content

Commit

Permalink
k8s: use separate lb for K8s services on azure
Browse files Browse the repository at this point in the history
  • Loading branch information
3u13r committed Jul 21, 2024
1 parent eab4222 commit 6ed8523
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 22 deletions.
2 changes: 1 addition & 1 deletion internal/constellation/helm/overrides.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ func getCCMConfig(azureState state.Azure, serviceAccURI string) ([]byte, error)
ResourceGroup: azureState.ResourceGroup,
LoadBalancerSku: "standard",
SecurityGroupName: azureState.NetworkSecurityGroupName,
LoadBalancerName: azureState.LoadBalancerName,
LoadBalancerName: "kubernetes-lb",
UseInstanceMetadata: true,
VMType: "vmss",
Location: creds.Location,
Expand Down
40 changes: 19 additions & 21 deletions terraform/infrastructure/azure/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -212,24 +212,28 @@ resource "azurerm_network_security_group" "security_group" {
location = var.location
resource_group_name = var.resource_group
tags = local.tags
}

dynamic "security_rule" {
for_each = concat(
resource "azurerm_network_security_rule" "nsg_rule" {
for_each = {
for o in concat(
local.ports,
[{ name = "nodeports", port = local.ports_node_range, priority = 200 }]
)
content {
name = security_rule.value.name
priority = security_rule.value.priority
direction = "Inbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = security_rule.value.port
source_address_prefix = "*"
destination_address_prefix = "*"
}
: o.name => o
}

name = each.value.name
priority = each.value.priority
direction = "Inbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = each.value.port
source_address_prefix = "*"
destination_address_prefix = "*"
resource_group_name = var.resource_group
network_security_group_name = azurerm_network_security_group.security_group.name
}

module "scale_set_group" {
Expand Down Expand Up @@ -257,14 +261,8 @@ module "scale_set_group" {
image_id = var.image_id
network_security_group_id = azurerm_network_security_group.security_group.id
subnet_id = azurerm_subnet.node_subnet.id
backend_address_pool_ids = each.value.role == "control-plane" ? [
azurerm_lb_backend_address_pool.all.id,
module.loadbalancer_backend_control_plane.backendpool_id
] : [
azurerm_lb_backend_address_pool.all.id,
module.loadbalancer_backend_worker.backendpool_id
]
marketplace_image = var.marketplace_image
backend_address_pool_ids = each.value.role == "control-plane" ? [module.loadbalancer_backend_control_plane.backendpool_id] : []
marketplace_image = var.marketplace_image
}

module "jump_host" {
Expand Down
1 change: 1 addition & 0 deletions terraform/infrastructure/azure/modules/scale_set/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ resource "azurerm_linux_virtual_machine_scale_set" "scale_set" {
instances, # required. autoscaling modifies the instance count externally
source_image_id, # required. update procedure modifies the image id externally
source_image_reference, # required. update procedure modifies the image reference externally
network_interface[0].ip_configuration[0].load_balancer_backend_address_pool_ids
]
}
}

0 comments on commit 6ed8523

Please sign in to comment.