Skip to content
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

azurerm_kubernetes_cluster - mark ebpf_data_plane not force new #22952

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,14 @@ func TestAccKubernetesCluster_ebpfDataPlane(t *testing.T) {

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.ebpfDataPlane(data),
Config: r.ebpfDataPlane(data, ""),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
{
Config: r.ebpfDataPlane(data, "cilium"),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
Expand Down Expand Up @@ -3516,7 +3523,11 @@ resource "azurerm_kubernetes_cluster" "test" {
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, enabled, authorizedIPConfig)
}

func (KubernetesClusterResource) ebpfDataPlane(data acceptance.TestData) string {
func (KubernetesClusterResource) ebpfDataPlane(data acceptance.TestData, ebpfDataPlane string) string {
ebpfDataPlaneValue := "null"
if ebpfDataPlane != "" {
ebpfDataPlaneValue = fmt.Sprintf(`"%s"`, ebpfDataPlane)
}
return fmt.Sprintf(`
provider "azurerm" {
features {}
Expand Down Expand Up @@ -3558,11 +3569,11 @@ resource "azurerm_kubernetes_cluster" "test" {
network_profile {
pod_cidr = "192.168.0.0/16"
network_plugin = "azure"
ebpf_data_plane = "cilium"
ebpf_data_plane = %[3]s
network_plugin_mode = "overlay"
}
}
`, "westcentralus", data.RandomInteger)
`, data.Locations.Primary, data.RandomInteger, ebpfDataPlaneValue)
}

func (KubernetesClusterResource) networkPluginMode(data acceptance.TestData) string {
Expand Down
14 changes: 8 additions & 6 deletions internal/services/containers/kubernetes_cluster_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ func resourceKubernetesCluster() *pluginsdk.Resource {
}
return true
}),
pluginsdk.ForceNewIfChange("network_profile.0.ebpf_data_plane", func(ctx context.Context, old, new, meta interface{}) bool {
return old != ""
}),
func(ctx context.Context, d *schema.ResourceDiff, meta interface{}) error {
if d.HasChange("oidc_issuer_enabled") {
d.SetNewComputed("oidc_issuer_url")
Expand Down Expand Up @@ -1052,7 +1055,6 @@ func resourceKubernetesCluster() *pluginsdk.Resource {
"ebpf_data_plane": {
Type: pluginsdk.TypeString,
Optional: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{
string(managedclusters.NetworkDataplaneCilium),
}, false),
Expand Down Expand Up @@ -2036,11 +2038,6 @@ func resourceKubernetesClusterUpdate(d *pluginsdk.ResourceData, meta interface{}

networkProfile := *existing.Model.Properties.NetworkProfile

if networkProfile.LoadBalancerProfile == nil && networkProfile.NatGatewayProfile == nil {
// on of the profiles should be present
return fmt.Errorf("both `loadBalancerProfile` and `natGatewayProfile` are nil in Azure")
}

stephybun marked this conversation as resolved.
Show resolved Hide resolved
if networkProfile.LoadBalancerProfile != nil {
loadBalancerProfile := *networkProfile.LoadBalancerProfile

Expand Down Expand Up @@ -2147,6 +2144,11 @@ func resourceKubernetesClusterUpdate(d *pluginsdk.ResourceData, meta interface{}

existing.Model.Properties.NetworkProfile.NatGatewayProfile = &natGatewayProfile
}

if key := "network_profile.0.ebpf_data_plane"; d.HasChange(key) {
ebpfDataPlane := d.Get(key).(string)
existing.Model.Properties.NetworkProfile.NetworkDataplane = utils.ToPtr(managedclusters.NetworkDataplane(ebpfDataPlane))
ms-henglu marked this conversation as resolved.
Show resolved Hide resolved
}
}
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 @@ -673,7 +673,7 @@ A `network_profile` block supports the following:

-> **Note:** `docker_bridge_cidr` has been deprecated as the API no longer supports it and will be removed in version 4.0 of the provider.

* `ebpf_data_plane` - (Optional) Specifies the eBPF data plane used for building the Kubernetes network. Possible value is `cilium`. Changing this forces a new resource to be created.
* `ebpf_data_plane` - (Optional) Specifies the eBPF data plane used for building the Kubernetes network. Possible value is `cilium`. Disabling this forces a new resource to be created.

~> **Note:** When `ebpf_data_plane` is set to `cilium`, the `network_plugin` field can only be set to `azure`.

Expand Down