New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
azure: add OutboundType for controlling egress #3324
Merged
openshift-merge-robot
merged 4 commits into
openshift:master
from
abhinavdahiya:azure_outbound_type
Jun 9, 2020
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
a99abf9
pkg/types/azure: add OutboundType for controlling egress
abhinavdahiya 3688fcb
manifests/azure: no outbound k8s service type LB for UDR
abhinavdahiya 2b94743
data/azure: implement outbound type LB and UDR
abhinavdahiya 19ceb44
azure/machines.go: make sure virtual machines are added to public LB …
abhinavdahiya File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,9 +3,16 @@ locals { | |
public_lb_frontend_ip_v6_configuration_name = "public-lb-ip-v6" | ||
} | ||
|
||
resource "azurerm_public_ip" "cluster_public_ip_v4" { | ||
locals { | ||
// DEBUG: Azure apparently requires dual stack LB for v6 | ||
count = var.use_ipv4 || true ? 1 : 0 | ||
need_public_ipv4 = ! var.private || ! var.outbound_udr | ||
|
||
need_public_ipv6 = var.use_ipv6 && (! var.private || ! var.outbound_udr) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe
|
||
} | ||
|
||
|
||
resource "azurerm_public_ip" "cluster_public_ip_v4" { | ||
count = local.need_public_ipv4 ? 1 : 0 | ||
|
||
sku = "Standard" | ||
location = var.region | ||
|
@@ -17,14 +24,15 @@ resource "azurerm_public_ip" "cluster_public_ip_v4" { | |
|
||
data "azurerm_public_ip" "cluster_public_ip_v4" { | ||
// DEBUG: Azure apparently requires dual stack LB for v6 | ||
count = var.use_ipv4 || true ? 1 : 0 | ||
count = local.need_public_ipv4 ? 1 : 0 | ||
|
||
name = azurerm_public_ip.cluster_public_ip_v4[0].name | ||
resource_group_name = var.resource_group_name | ||
} | ||
|
||
|
||
resource "azurerm_public_ip" "cluster_public_ip_v6" { | ||
count = var.use_ipv6 ? 1 : 0 | ||
count = local.need_public_ipv6 ? 1 : 0 | ||
|
||
ip_version = "IPv6" | ||
sku = "Standard" | ||
|
@@ -36,7 +44,7 @@ resource "azurerm_public_ip" "cluster_public_ip_v6" { | |
} | ||
|
||
data "azurerm_public_ip" "cluster_public_ip_v6" { | ||
count = var.use_ipv6 ? 1 : 0 | ||
count = local.need_public_ipv6 ? 1 : 0 | ||
|
||
name = azurerm_public_ip.cluster_public_ip_v6[0].name | ||
resource_group_name = var.resource_group_name | ||
|
@@ -51,8 +59,18 @@ resource "azurerm_lb" "public" { | |
dynamic "frontend_ip_configuration" { | ||
for_each = [for ip in [ | ||
// DEBUG: Azure apparently requires dual stack LB for external load balancers v6 | ||
{ name : local.public_lb_frontend_ip_v4_configuration_name, value : azurerm_public_ip.cluster_public_ip_v4[0].id, include : true, ipv6 : false }, | ||
{ name : local.public_lb_frontend_ip_v6_configuration_name, value : var.use_ipv6 ? azurerm_public_ip.cluster_public_ip_v6[0].id : null, include : var.use_ipv6, ipv6 : true }, | ||
{ | ||
name : local.public_lb_frontend_ip_v4_configuration_name, | ||
value : local.need_public_ipv4 ? azurerm_public_ip.cluster_public_ip_v4[0].id : null, | ||
include : local.need_public_ipv4, | ||
ipv6 : false, | ||
}, | ||
{ | ||
name : local.public_lb_frontend_ip_v6_configuration_name, | ||
value : local.need_public_ipv6 ? azurerm_public_ip.cluster_public_ip_v6[0].id : null, | ||
include : local.need_public_ipv6, | ||
ipv6 : true, | ||
}, | ||
] : { | ||
name : ip.name | ||
value : ip.value | ||
|
@@ -70,24 +88,29 @@ resource "azurerm_lb" "public" { | |
} | ||
} | ||
|
||
// The backends are only created when frontend configuration exists, because of the following error from Azure API; | ||
// ``` | ||
// Load Balancer /subscriptions/xx/resourceGroups/xx/providers/Microsoft.Network/loadBalancers/xx-public-lb does not have Frontend IP Configuration, | ||
// but it has other child resources. This setup is not supported. | ||
// ``` | ||
resource "azurerm_lb_backend_address_pool" "public_lb_pool_v4" { | ||
count = var.use_ipv4 ? 1 : 0 | ||
count = local.need_public_ipv4 ? 1 : 0 | ||
|
||
resource_group_name = var.resource_group_name | ||
loadbalancer_id = azurerm_lb.public.id | ||
name = var.cluster_id | ||
} | ||
|
||
resource "azurerm_lb_backend_address_pool" "public_lb_pool_v6" { | ||
count = var.use_ipv6 ? 1 : 0 | ||
count = local.need_public_ipv6 ? 1 : 0 | ||
|
||
resource_group_name = var.resource_group_name | ||
loadbalancer_id = azurerm_lb.public.id | ||
name = "${var.cluster_id}-IPv6" | ||
} | ||
|
||
resource "azurerm_lb_rule" "public_lb_rule_api_internal_v4" { | ||
count = var.private || ! var.use_ipv4 ? 0 : 1 | ||
count = var.use_ipv4 && ! var.private ? 1 : 0 | ||
|
||
name = "api-internal-v4" | ||
resource_group_name = var.resource_group_name | ||
|
@@ -104,7 +127,7 @@ resource "azurerm_lb_rule" "public_lb_rule_api_internal_v4" { | |
} | ||
|
||
resource "azurerm_lb_rule" "public_lb_rule_api_internal_v6" { | ||
count = var.private || ! var.use_ipv6 ? 0 : 1 | ||
count = var.use_ipv6 && ! var.private ? 1 : 0 | ||
|
||
name = "api-internal-v6" | ||
resource_group_name = var.resource_group_name | ||
|
@@ -120,36 +143,32 @@ resource "azurerm_lb_rule" "public_lb_rule_api_internal_v6" { | |
probe_id = azurerm_lb_probe.public_lb_probe_api_internal[0].id | ||
} | ||
|
||
resource "azurerm_lb_rule" "internal_outbound_rule_v4" { | ||
count = var.private && var.use_ipv4 ? 1 : 0 | ||
resource "azurerm_lb_outbound_rule" "public_lb_outbound_rule_v4" { | ||
count = var.use_ipv4 && var.private && ! var.outbound_udr ? 1 : 0 | ||
|
||
name = "internal_outbound_rule_v4" | ||
resource_group_name = var.resource_group_name | ||
protocol = "Tcp" | ||
backend_address_pool_id = azurerm_lb_backend_address_pool.public_lb_pool_v4[0].id | ||
loadbalancer_id = azurerm_lb.public.id | ||
frontend_port = 27627 | ||
backend_port = 27627 | ||
frontend_ip_configuration_name = local.public_lb_frontend_ip_v4_configuration_name | ||
enable_floating_ip = false | ||
idle_timeout_in_minutes = 30 | ||
load_distribution = "Default" | ||
name = "outbound-rule-v4" | ||
resource_group_name = var.resource_group_name | ||
loadbalancer_id = azurerm_lb.public.id | ||
backend_address_pool_id = azurerm_lb_backend_address_pool.public_lb_pool_v4[0].id | ||
protocol = "All" | ||
|
||
frontend_ip_configuration { | ||
name = local.public_lb_frontend_ip_v4_configuration_name | ||
} | ||
} | ||
|
||
resource "azurerm_lb_rule" "internal_outbound_rule_v6" { | ||
count = var.private && var.use_ipv6 ? 1 : 0 | ||
resource "azurerm_lb_outbound_rule" "public_lb_outbound_rule_v6" { | ||
count = var.use_ipv6 && var.private && ! var.outbound_udr ? 1 : 0 | ||
|
||
name = "internal_outbound_rule_v6" | ||
resource_group_name = var.resource_group_name | ||
protocol = "Tcp" | ||
backend_address_pool_id = azurerm_lb_backend_address_pool.public_lb_pool_v6[0].id | ||
loadbalancer_id = azurerm_lb.public.id | ||
frontend_port = 27627 | ||
backend_port = 27627 | ||
frontend_ip_configuration_name = local.public_lb_frontend_ip_v6_configuration_name | ||
enable_floating_ip = false | ||
idle_timeout_in_minutes = 30 | ||
load_distribution = "Default" | ||
name = "outbound-rule-v6" | ||
resource_group_name = var.resource_group_name | ||
loadbalancer_id = azurerm_lb.public.id | ||
backend_address_pool_id = azurerm_lb_backend_address_pool.public_lb_pool_v6[0].id | ||
protocol = "All" | ||
|
||
frontend_ip_configuration { | ||
name = local.public_lb_frontend_ip_v6_configuration_name | ||
} | ||
} | ||
|
||
resource "azurerm_lb_probe" "public_lb_probe_api_internal" { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would change this (and all the other blocks that use it) to "determines".