@@ -53,7 +53,9 @@ func TestDefaultingWebhook(t *testing.T) {
5353 g .Expect (* amcp .Spec .SSHPublicKey ).NotTo (BeEmpty ())
5454 g .Expect (amcp .Spec .NodeResourceGroupName ).To (Equal ("MC_fooRg_fooName_fooLocation" ))
5555 g .Expect (amcp .Spec .VirtualNetwork .Name ).To (Equal ("fooName" ))
56+ g .Expect (amcp .Spec .VirtualNetwork .CIDRBlock ).To (Equal (defaultAKSVnetCIDR ))
5657 g .Expect (amcp .Spec .VirtualNetwork .Subnet .Name ).To (Equal ("fooName" ))
58+ g .Expect (amcp .Spec .VirtualNetwork .Subnet .CIDRBlock ).To (Equal (defaultAKSNodeSubnetCIDR ))
5759 g .Expect (amcp .Spec .SKU .Tier ).To (Equal (FreeManagedControlPlaneTier ))
5860 g .Expect (amcp .Spec .Identity .Type ).To (Equal (ManagedControlPlaneIdentityTypeSystemAssigned ))
5961 g .Expect (* amcp .Spec .OIDCIssuerProfile .Enabled ).To (BeFalse ())
@@ -87,6 +89,24 @@ func TestDefaultingWebhook(t *testing.T) {
8789 g .Expect (amcp .Spec .VirtualNetwork .Subnet .Name ).To (Equal ("fooSubnetName" ))
8890 g .Expect (amcp .Spec .SKU .Tier ).To (Equal (PaidManagedControlPlaneTier ))
8991 g .Expect (* amcp .Spec .OIDCIssuerProfile .Enabled ).To (BeTrue ())
92+
93+ t .Logf ("Testing amcp defaulting webhook with overlay" )
94+ amcp = & AzureManagedControlPlane {
95+ ObjectMeta : metav1.ObjectMeta {
96+ Name : "fooName" ,
97+ },
98+ Spec : AzureManagedControlPlaneSpec {
99+ ResourceGroupName : "fooRg" ,
100+ Location : "fooLocation" ,
101+ Version : "1.17.5" ,
102+ SSHPublicKey : ptr .To ("" ),
103+ NetworkPluginMode : ptr .To (NetworkPluginModeOverlay ),
104+ },
105+ }
106+ err = mcpw .Default (context .Background (), amcp )
107+ g .Expect (err ).NotTo (HaveOccurred ())
108+ g .Expect (amcp .Spec .VirtualNetwork .CIDRBlock ).To (Equal (defaultAKSVnetCIDRForOverlay ))
109+ g .Expect (amcp .Spec .VirtualNetwork .Subnet .CIDRBlock ).To (Equal (defaultAKSNodeSubnetCIDRForOverlay ))
90110}
91111
92112func TestValidatingWebhook (t * testing.T ) {
@@ -667,6 +687,30 @@ func TestValidatingWebhook(t *testing.T) {
667687 },
668688 expectErr : true ,
669689 },
690+ {
691+ name : "overlay cannot be used with kubenet" ,
692+ amcp : AzureManagedControlPlane {
693+ ObjectMeta : getAMCPMetaData (),
694+ Spec : AzureManagedControlPlaneSpec {
695+ Version : "v1.24.1" ,
696+ NetworkPlugin : ptr .To ("kubenet" ),
697+ NetworkPluginMode : ptr .To (NetworkPluginModeOverlay ),
698+ },
699+ },
700+ expectErr : true ,
701+ },
702+ {
703+ name : "overlay can be used with azure" ,
704+ amcp : AzureManagedControlPlane {
705+ ObjectMeta : getAMCPMetaData (),
706+ Spec : AzureManagedControlPlaneSpec {
707+ Version : "v1.24.1" ,
708+ NetworkPlugin : ptr .To ("azure" ),
709+ NetworkPluginMode : ptr .To (NetworkPluginModeOverlay ),
710+ },
711+ },
712+ expectErr : false ,
713+ },
670714 }
671715
672716 for _ , tt := range tests {
@@ -1422,6 +1466,49 @@ func TestAzureManagedControlPlane_ValidateUpdate(t *testing.T) {
14221466 },
14231467 wantErr : true ,
14241468 },
1469+ {
1470+ name : "NetworkPluginMode cannot change to \" overlay\" when NetworkPolicy is set" ,
1471+ oldAMCP : & AzureManagedControlPlane {
1472+ ObjectMeta : metav1.ObjectMeta {
1473+ Name : "test-cluster" ,
1474+ },
1475+ Spec : AzureManagedControlPlaneSpec {
1476+ NetworkPolicy : ptr .To ("anything" ),
1477+ NetworkPluginMode : nil ,
1478+ },
1479+ },
1480+ amcp : & AzureManagedControlPlane {
1481+ ObjectMeta : metav1.ObjectMeta {
1482+ Name : "test-cluster" ,
1483+ },
1484+ Spec : AzureManagedControlPlaneSpec {
1485+ NetworkPluginMode : ptr .To (NetworkPluginModeOverlay ),
1486+ },
1487+ },
1488+ wantErr : true ,
1489+ },
1490+ {
1491+ name : "NetworkPluginMode can change to \" overlay\" when NetworkPolicy is not set" ,
1492+ oldAMCP : & AzureManagedControlPlane {
1493+ ObjectMeta : metav1.ObjectMeta {
1494+ Name : "test-cluster" ,
1495+ },
1496+ Spec : AzureManagedControlPlaneSpec {
1497+ NetworkPolicy : nil ,
1498+ NetworkPluginMode : nil ,
1499+ },
1500+ },
1501+ amcp : & AzureManagedControlPlane {
1502+ ObjectMeta : metav1.ObjectMeta {
1503+ Name : "test-cluster" ,
1504+ },
1505+ Spec : AzureManagedControlPlaneSpec {
1506+ NetworkPluginMode : ptr .To (NetworkPluginModeOverlay ),
1507+ Version : "v0.0.0" ,
1508+ },
1509+ },
1510+ wantErr : false ,
1511+ },
14251512 {
14261513 name : "AzureManagedControlPlane OIDCIssuerProfile.Enabled false -> false OK" ,
14271514 oldAMCP : & AzureManagedControlPlane {
0 commit comments