diff --git a/internal/models/akscluster/network_config.go b/internal/models/akscluster/network_config.go index d32382d8e..22b96e5da 100644 --- a/internal/models/akscluster/network_config.go +++ b/internal/models/akscluster/network_config.go @@ -17,6 +17,12 @@ const ( // VmwareTanzuManageV1alpha1AksClusterNetworkPluginModeOverlay captures value "overlay". VmwareTanzuManageV1alpha1AksClusterNetworkPluginModeOverlay = "overlay" + + // VmwareTanzuManageV1alpha1AksClusterNetworkDataplaneCilium captures value "cilium". + VmwareTanzuManageV1alpha1AksClusterNetworkDataplaneCilium = "cilium" + + // VmwareTanzuManageV1alpha1AksClusterNetworkDataplaneAzure captures value "azure". + VmwareTanzuManageV1alpha1AksClusterNetworkDataplaneAzure = "azure" ) // VmwareTanzuManageV1alpha1AksclusterNetworkConfig The network configuration for the AKS cluster. @@ -52,6 +58,9 @@ type VmwareTanzuManageV1alpha1AksclusterNetworkConfig struct { // The CIDR notation IP ranges from which to assign service cluster IPs. ServiceCidrs []string `json:"serviceCidrs"` + + // Network dataplane used in the Kubernetes cluster. The valid value is azure and cilium. + NetworkDataplane string `json:"networkDataplane,omitempty"` } // MarshalBinary interface implementation. diff --git a/internal/resources/akscluster/akscluster_mapper.go b/internal/resources/akscluster/akscluster_mapper.go index 6e9f4bbb6..47ad2f794 100644 --- a/internal/resources/akscluster/akscluster_mapper.go +++ b/internal/resources/akscluster/akscluster_mapper.go @@ -279,6 +279,10 @@ func constructNetworkConfig(data []any) *models.VmwareTanzuManageV1alpha1Aksclus networkConfig.PodCidrs = helper.SetPrimitiveList[string](v.([]any), podCidrKey) } + if v, ok := networkConfigData[networkDataplaneKey]; ok { + helper.SetPrimitiveValue(v, &networkConfig.NetworkDataplane, networkDataplaneKey) + } + return networkConfig } @@ -608,6 +612,7 @@ func toNetworkConfigMap(config *models.VmwareTanzuManageV1alpha1AksclusterNetwor data[dockerBridgeCidrKey] = config.DockerBridgeCidr data[podCidrKey] = toInterfaceArray(config.PodCidrs) data[serviceCidrKey] = toInterfaceArray(config.ServiceCidrs) + data[networkDataplaneKey] = config.NetworkDataplane return []any{data} } diff --git a/internal/resources/akscluster/constants.go b/internal/resources/akscluster/constants.go index 7b5fb5695..08776c322 100644 --- a/internal/resources/akscluster/constants.go +++ b/internal/resources/akscluster/constants.go @@ -53,6 +53,7 @@ const ( loadBalancerSkuKey = "load_balancer_sku" networkPluginKey = "network_plugin" networkPluginModeKey = "network_plugin_mode" + networkDataplaneKey = "network_dataplane" networkPolicyKey = "network_policy" dnsServiceIPKey = "dns_service_ip" dockerBridgeCidrKey = "docker_bridge_cidr" diff --git a/internal/resources/akscluster/helpers_test.go b/internal/resources/akscluster/helpers_test.go index e27efeaba..7b8f1b5ee 100644 --- a/internal/resources/akscluster/helpers_test.go +++ b/internal/resources/akscluster/helpers_test.go @@ -354,6 +354,7 @@ func aTestClusterDataMap(w ...mapWither) map[string]any { "pod_cidr": nil, "service_cidr": []any{"127.0.0.4"}, "dns_prefix": "net-prefix", + "network_dataplane": "", }}, "storage_config": []any{map[string]any{ "enable_disk_csi_driver": true, diff --git a/internal/resources/akscluster/resource_akscluster_acc_test.go b/internal/resources/akscluster/resource_akscluster_acc_test.go index 3dc203bce..439f61817 100644 --- a/internal/resources/akscluster/resource_akscluster_acc_test.go +++ b/internal/resources/akscluster/resource_akscluster_acc_test.go @@ -37,7 +37,7 @@ import ( ) // Version of Kubernetes to deploy during acceptance tests. -var aksKubernetesVersion = "1.27.9" +var aksKubernetesVersion = "1.28.0" func validateSetup(t *testing.T) { // Check if the required environment variables are set @@ -414,6 +414,9 @@ func testAKSCluster(fn *aksmodel.VmwareTanzuManageV1alpha1AksclusterFullName) st count = 1 mode = "SYSTEM" vm_size = "Standard_DS2_v2" + upgrade_config { + max_surge = "10%%" + } } } } @@ -448,6 +451,9 @@ func testAKSClusterEnableCSI(fn *aksmodel.VmwareTanzuManageV1alpha1AksclusterFul count = 1 mode = "SYSTEM" vm_size = "Standard_DS2_v2" + upgrade_config { + max_surge = "10%%" + } } } } @@ -482,6 +488,9 @@ func testAKSClusterAddUserNodepool(fn *aksmodel.VmwareTanzuManageV1alpha1Aksclus count = 1 mode = "SYSTEM" vm_size = "Standard_DS2_v2" + upgrade_config { + max_surge = "10%%" + } } } nodepool { @@ -490,6 +499,9 @@ func testAKSClusterAddUserNodepool(fn *aksmodel.VmwareTanzuManageV1alpha1Aksclus count = 1 mode = "USER" vm_size = "Standard_DS2_v2" + upgrade_config { + max_surge = "10%%" + } } } } @@ -545,7 +557,10 @@ func mockNodepool(w ...nodepoolWither) *aksmodel.VmwareTanzuManageV1alpha1Aksclu Mode: aksmodel.VmwareTanzuManageV1alpha1AksclusterNodepoolModeSYSTEM.Pointer(), OsType: aksmodel.VmwareTanzuManageV1alpha1AksclusterNodepoolOsTypeLINUX.Pointer(), VMSize: "Standard_DS2_v2", - Type: aksmodel.VmwareTanzuManageV1alpha1AksclusterNodepoolTypeVIRTUALMACHINESCALESETS.Pointer(), + UpgradeConfig: &aksmodel.VmwareTanzuManageV1alpha1AksclusterNodepoolUpgradeConfig{ + MaxSurge: "10%", + }, + Type: aksmodel.VmwareTanzuManageV1alpha1AksclusterNodepoolTypeVIRTUALMACHINESCALESETS.Pointer(), }, Status: &aksmodel.VmwareTanzuManageV1alpha1AksclusterNodepoolStatus{ Phase: aksmodel.VmwareTanzuManageV1alpha1AksclusterNodepoolPhaseREADY.Pointer(), diff --git a/internal/resources/akscluster/schema.go b/internal/resources/akscluster/schema.go index def40c8f6..868f993cd 100644 --- a/internal/resources/akscluster/schema.go +++ b/internal/resources/akscluster/schema.go @@ -400,6 +400,17 @@ var NetworkConfig = &schema.Resource{ ForceNew: true, Required: true, }, + networkDataplaneKey: { + Type: schema.TypeString, + Description: "Network dataplane used in the Kubernetes cluster. The valid value is azure and cilium.", + ForceNew: true, + Optional: true, + Computed: true, + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"", + aksmodel.VmwareTanzuManageV1alpha1AksClusterNetworkDataplaneCilium, + aksmodel.VmwareTanzuManageV1alpha1AksClusterNetworkDataplaneAzure, + }, false)), + }, }, }