@@ -37,11 +37,12 @@ var _ install.Provider = (*Options)(nil)
3737type Options struct {
3838 * install.Options
3939
40- subscriptionName string
41- subscriptionID string
42- resourceGroupName string
43- resourceName string
44- fqdn string
40+ subscriptionName string
41+ subscriptionID string
42+ resourceGroupName string
43+ resourceName string
44+ vnetResourceGroupName string
45+ fqdn string
4546
4647 authorizer * autorest.Authorizer
4748}
@@ -72,6 +73,8 @@ func (o *Options) RegisterFlags(cmd *cobra.Command) {
7273 cmd .Flags ().StringVar (& o .resourceGroupName , "resource-group-name" , "" ,
7374 "The Azure ResourceGroup name of the cluster" )
7475 cmd .Flags ().StringVar (& o .resourceName , "resource-name" , "" , "The Azure Name of the cluster" )
76+ cmd .Flags ().StringVar (& o .vnetResourceGroupName , "vnet-resource-group-name" , "" ,
77+ "The Azure ResourceGroup name of the Virtual Network (defaults to --resource-group-name if not provided)" )
7578 cmd .Flags ().StringVar (& o .fqdn , "fqdn" , "" , "The private AKS cluster fqdn" )
7679
7780 utilruntime .Must (cmd .MarkFlagRequired ("resource-group-name" ))
@@ -83,11 +86,16 @@ func (o *Options) Initialize(ctx context.Context) error {
8386 if o .subscriptionID == "" && o .subscriptionName == "" {
8487 return fmt .Errorf ("neither --subscription-id nor --subscription-name specified" )
8588 }
89+ if o .vnetResourceGroupName == "" {
90+ // use AKS resource group if vnet resource group not provided
91+ o .vnetResourceGroupName = o .resourceGroupName
92+ }
8693
8794 o .Printer .Verbosef ("AKS SubscriptionID: %q" , o .subscriptionID )
8895 o .Printer .Verbosef ("AKS SubscriptionName: %q" , o .subscriptionName )
8996 o .Printer .Verbosef ("AKS ResourceGroupName: %q" , o .resourceGroupName )
9097 o .Printer .Verbosef ("AKS ResourceName: %q" , o .resourceName )
98+ o .Printer .Verbosef ("VNET ResourceGroupName: %q" , o .vnetResourceGroupName )
9199
92100 // if the cluster name has not been provided, we default it to the cloud provider resource name.
93101 if o .ClusterName == "" {
@@ -189,7 +197,7 @@ func (o *Options) setupKubenet(ctx context.Context, cluster *containerservice.Ma
189197 return err
190198 }
191199
192- vnet , err := networkClient .Get (ctx , o .resourceGroupName , vnetName , subnetName , "" )
200+ vnet , err := networkClient .Get (ctx , o .vnetResourceGroupName , vnetName , subnetName , "" )
193201 if err != nil {
194202 return err
195203 }
@@ -212,7 +220,7 @@ func (o *Options) setupAzureCNI(ctx context.Context, cluster *containerservice.M
212220 return err
213221 }
214222
215- vnet , err := networkClient .Get (ctx , o .resourceGroupName , vnetName , subnetName , "" )
223+ vnet , err := networkClient .Get (ctx , o .vnetResourceGroupName , vnetName , subnetName , "" )
216224 if err != nil {
217225 return err
218226 }
0 commit comments