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 162f85e
Showing 1 changed file with 21 additions and 2 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

0 comments on commit 162f85e

Please sign in to comment.