Skip to content

Commit

Permalink
support migration of outbound types (#25021)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephybun authored Feb 27, 2024
1 parent ac57f14 commit 3f85dee
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,28 @@ func TestAccKubernetesCluster_outboundTypeLoadBalancer(t *testing.T) {
})
}

func TestAccKubernetesCluster_outboundTypeUpdate(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_kubernetes_cluster", "test")
r := KubernetesClusterResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.managedNatGatewayConfig(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
{
Config: r.outboundTypeLoadBalancerConfig(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
})
}

func TestAccKubernetesCluster_natGatewayProfile(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_kubernetes_cluster", "test")
r := KubernetesClusterResource{}
Expand Down Expand Up @@ -2121,7 +2143,7 @@ resource "azurerm_kubernetes_cluster" "test" {
network_profile {
network_plugin = "kubenet"
load_balancer_sku = "basic"
load_balancer_sku = "standard"
pod_cidr = "10.244.0.0/16"
service_cidr = "10.0.0.0/16"
dns_service_ip = "10.0.0.10"
Expand Down
5 changes: 4 additions & 1 deletion internal/services/containers/kubernetes_cluster_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,6 @@ func resourceKubernetesCluster() *pluginsdk.Resource {
"outbound_type": {
Type: pluginsdk.TypeString,
Optional: true,
ForceNew: true,
Default: string(managedclusters.OutboundTypeLoadBalancer),
ValidateFunc: validation.StringInSlice([]string{
string(managedclusters.OutboundTypeLoadBalancer),
Expand Down Expand Up @@ -2158,6 +2157,10 @@ func resourceKubernetesClusterUpdate(d *pluginsdk.ResourceData, meta interface{}
ebpfDataPlane := d.Get(key).(string)
existing.Model.Properties.NetworkProfile.NetworkDataplane = pointer.To(managedclusters.NetworkDataplane(ebpfDataPlane))
}

if key := "network_profile.0.outbound_type"; d.HasChange(key) {
existing.Model.Properties.NetworkProfile.OutboundType = pointer.To(managedclusters.OutboundType(d.Get(key).(string)))
}
}
if d.HasChange("service_mesh_profile") {
updateCluster = true
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/kubernetes_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ A `network_profile` block supports the following:

~> **Note:** When `network_plugin_mode` is set to `overlay`, the `network_plugin` field can only be set to `azure`. When upgrading from Azure CNI without overlay, `pod_subnet_id` must be specified.

* `outbound_type` - (Optional) The outbound (egress) routing method which should be used for this Kubernetes Cluster. Possible values are `loadBalancer`, `userDefinedRouting`, `managedNATGateway` and `userAssignedNATGateway`. Defaults to `loadBalancer`. Changing this forces a new resource to be created.
* `outbound_type` - (Optional) The outbound (egress) routing method which should be used for this Kubernetes Cluster. Possible values are `loadBalancer`, `userDefinedRouting`, `managedNATGateway` and `userAssignedNATGateway`. Defaults to `loadBalancer`. More information on supported migration paths for `outbound_type` can be found in [this documentation](https://learn.microsoft.com/azure/aks/egress-outboundtype#updating-outboundtype-after-cluster-creation).

* `pod_cidr` - (Optional) The CIDR to use for pod IP addresses. This field can only be set when `network_plugin` is set to `kubenet`. Changing this forces a new resource to be created.

Expand Down

0 comments on commit 3f85dee

Please sign in to comment.