Skip to content

Commit

Permalink
azurerm_kubernetes_cluster: Support for upgrade path from Azure CNI…
Browse files Browse the repository at this point in the history
… to Azure CNI Overlay
  • Loading branch information
jkroepke committed Jun 6, 2024
1 parent 6c924c5 commit a81a846
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
23 changes: 21 additions & 2 deletions internal/services/containers/kubernetes_cluster_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ func resourceKubernetesCluster() *pluginsdk.Resource {
pluginsdk.ForceNewIfChange("network_profile.0.network_policy", func(ctx context.Context, old, new, meta interface{}) bool {
return old.(string) != "" || new.(string) != string(managedclusters.NetworkPolicyCilium)
}),
pluginsdk.ForceNewIfChange("network_profile.0.pod_cidr", func(ctx context.Context, old, new, meta interface{}) bool {
return old.(string) != ""
}),
pluginsdk.ForceNewIfChange("network_profile.0.pod_cidrs", func(ctx context.Context, old, new, meta interface{}) bool {
return len(old.([]interface{})) > 0
}),
pluginsdk.ForceNewIfChange("custom_ca_trust_certificates_base64", func(ctx context.Context, old, new, meta interface{}) bool {
return len(old.([]interface{})) > 0 && len(new.([]interface{})) == 0
}),
Expand Down Expand Up @@ -1031,15 +1037,13 @@ func resourceKubernetesCluster() *pluginsdk.Resource {
Type: pluginsdk.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
ValidateFunc: validate.CIDR,
},

"pod_cidrs": {
Type: pluginsdk.TypeList,
Optional: true,
Computed: true,
ForceNew: true,
Elem: &pluginsdk.Schema{
Type: pluginsdk.TypeString,
ValidateFunc: validation.StringIsNotEmpty,
Expand Down Expand Up @@ -2340,6 +2344,21 @@ func resourceKubernetesClusterUpdate(d *pluginsdk.ResourceData, meta interface{}
existing.Model.Properties.NetworkProfile.NetworkDataplane = pointer.To(managedclusters.NetworkDataplane(ebpfDataPlane))
}

if key := "network_profile.0.network_plugin_mode"; d.HasChange(key) {
networkPluginMode := d.Get(key).(string)
existing.Model.Properties.NetworkProfile.NetworkPluginMode = pointer.To(managedclusters.NetworkPluginMode(networkPluginMode))
}

if key := "network_profile.0.pod_cidr"; d.HasChange(key) {
podCidr := d.Get(key).(string)
existing.Model.Properties.NetworkProfile.PodCidr = pointer.To(podCidr)
}

if key := "network_profile.0.pod_cidrs"; d.HasChange(key) {
podCidrs := d.Get(key).([]interface{})
existing.Model.Properties.NetworkProfile.PodCidrs = utils.ExpandStringSlice(podCidrs)
}

if key := "network_profile.0.outbound_type"; d.HasChange(key) {
outboundType := managedclusters.OutboundType(d.Get(key).(string))
existing.Model.Properties.NetworkProfile.OutboundType = pointer.To(outboundType)
Expand Down
4 changes: 2 additions & 2 deletions website/docs/r/kubernetes_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -699,9 +699,9 @@ A `network_profile` block supports the following:

* `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` or `network_plugin_mode` is set to `overlay`. Changing this forces a new resource to be created.
* `pod_cidr` - (Optional) The CIDR to use for pod IP addresses. This field can only be set when `network_plugin` is set to `kubenet` or `network_plugin_mode` is set to `overlay`. Changing an non-empty value forces a new resource to be created.

* `pod_cidrs` - (Optional) A list of CIDRs to use for pod IP addresses. For single-stack networking a single IPv4 CIDR is expected. For dual-stack networking an IPv4 and IPv6 CIDR are expected. Changing this forces a new resource to be created.
* `pod_cidrs` - (Optional) A list of CIDRs to use for pod IP addresses. For single-stack networking a single IPv4 CIDR is expected. For dual-stack networking an IPv4 and IPv6 CIDR are expected. Changing an non-empty value forces a new resource to be created.

* `service_cidr` - (Optional) The Network Range used by the Kubernetes service. Changing this forces a new resource to be created.

Expand Down

0 comments on commit a81a846

Please sign in to comment.