Skip to content

Commit

Permalink
azurerm_kubernetes_cluster: support for the backend_pool_type pro…
Browse files Browse the repository at this point in the history
…perty (#27596)
  • Loading branch information
hqhqhqhqhqhqhqhqhqhqhq authored Oct 29, 2024
1 parent 10ba557 commit 6ac4caf
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3020,6 +3020,7 @@ resource "azurerm_kubernetes_cluster" "test" {
load_balancer_sku = "standard"
load_balancer_profile {
outbound_ip_address_ids = [azurerm_public_ip.test.id]
backend_pool_type = "NodeIP"
}
}
}
Expand Down
29 changes: 29 additions & 0 deletions internal/services/containers/kubernetes_cluster_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -1072,26 +1072,30 @@ func resourceKubernetesCluster() *pluginsdk.Resource {
Default: 0,
ValidateFunc: validation.IntBetween(0, 64000),
},

"idle_timeout_in_minutes": {
Type: pluginsdk.TypeInt,
Optional: true,
Default: 30,
ValidateFunc: validation.IntBetween(4, 100),
},

"managed_outbound_ip_count": {
Type: pluginsdk.TypeInt,
Optional: true,
Computed: true,
ValidateFunc: validation.IntBetween(1, 100),
ConflictsWith: []string{"network_profile.0.load_balancer_profile.0.outbound_ip_prefix_ids", "network_profile.0.load_balancer_profile.0.outbound_ip_address_ids"},
},

"managed_outbound_ipv6_count": {
Type: pluginsdk.TypeInt,
Optional: true,
Computed: true,
ValidateFunc: validation.IntBetween(1, 100),
ConflictsWith: []string{"network_profile.0.load_balancer_profile.0.outbound_ip_prefix_ids", "network_profile.0.load_balancer_profile.0.outbound_ip_address_ids"},
},

"outbound_ip_prefix_ids": {
Type: pluginsdk.TypeSet,
Optional: true,
Expand All @@ -1101,6 +1105,7 @@ func resourceKubernetesCluster() *pluginsdk.Resource {
ValidateFunc: azure.ValidateResourceID,
},
},

"outbound_ip_address_ids": {
Type: pluginsdk.TypeSet,
Optional: true,
Expand All @@ -1110,13 +1115,24 @@ func resourceKubernetesCluster() *pluginsdk.Resource {
ValidateFunc: azure.ValidateResourceID,
},
},

"effective_outbound_ips": {
Type: pluginsdk.TypeSet,
Computed: true,
Elem: &pluginsdk.Schema{
Type: pluginsdk.TypeString,
},
},

"backend_pool_type": {
Type: pluginsdk.TypeString,
Optional: true,
Default: string(managedclusters.BackendPoolTypeNodeIPConfiguration),
ValidateFunc: validation.StringInSlice([]string{
string(managedclusters.BackendPoolTypeNodeIPConfiguration),
string(managedclusters.BackendPoolTypeNodeIP),
}, false),
},
},
},
},
Expand Down Expand Up @@ -2039,6 +2055,11 @@ func resourceKubernetesClusterUpdate(d *pluginsdk.ResourceData, meta interface{}
loadBalancerProfile.AllocatedOutboundPorts = utils.Int64(int64(allocatedOutboundPorts))
}

if key := "network_profile.0.load_balancer_profile.0.backend_pool_type"; d.HasChange(key) {
backendPoolType := d.Get(key).(string)
loadBalancerProfile.BackendPoolType = pointer.To(managedclusters.BackendPoolType(backendPoolType))
}

existing.Model.Properties.NetworkProfile.LoadBalancerProfile = &loadBalancerProfile
}

Expand Down Expand Up @@ -3230,6 +3251,10 @@ func expandLoadBalancerProfile(d []interface{}) *managedclusters.ManagedClusterL
profile.OutboundIPs = &managedclusters.ManagedClusterLoadBalancerProfileOutboundIPs{PublicIPs: outIps}
}

if backendPoolType, ok := config["backend_pool_type"].(string); ok {
profile.BackendPoolType = pointer.To(managedclusters.BackendPoolType(backendPoolType))
}

return profile
}

Expand Down Expand Up @@ -3391,6 +3416,10 @@ func flattenKubernetesClusterNetworkProfile(profile *managedclusters.ContainerSe
}
}

if v := lbp.BackendPoolType; v != nil {
lb["backend_pool_type"] = v
}

lb["effective_outbound_ips"] = resourceReferencesToIds(profile.LoadBalancerProfile.EffectiveOutboundIPs)
lbProfiles = append(lbProfiles, lb)
}
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/kubernetes_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,8 @@ A `load_balancer_profile` block supports the following:

~> **Note:** The fields `managed_outbound_ip_count`, `outbound_ip_address_ids` and `outbound_ip_prefix_ids` are mutually exclusive. Note that when specifying `outbound_ip_address_ids` ([azurerm_public_ip](/docs/providers/azurerm/r/public_ip.html)) the SKU must be `standard`.

* `backend_pool_type` - (Optional) The type of the managed inbound Load Balancer Backend Pool. Possible values are `NodeIP` and `NodeIPConfiguration`. Defaults to `NodeIPConfiguration`. See [the documentation](https://learn.microsoft.com/en-us/azure/aks/load-balancer-standard#change-the-inbound-pool-type) for more information.

* `idle_timeout_in_minutes` - (Optional) Desired outbound flow idle timeout in minutes for the cluster load balancer. Must be between `4` and `100` inclusive. Defaults to `30`.

* `managed_outbound_ip_count` - (Optional) Count of desired managed outbound IPs for the cluster load balancer. Must be between `1` and `100` inclusive.
Expand Down

0 comments on commit 6ac4caf

Please sign in to comment.