Skip to content

Commit 94c73c0

Browse files
scottboringadamjensenbot
authored andcommitted
Adding optional flag for vnet resource group for scenarios when the vnet is in a different resource group from the AKS resource
1 parent 5637205 commit 94c73c0

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

docs/installation/install.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,12 @@ Additionally, since your API Server is not accessible from the public Internet,
127127
By default, the **AKS** provider exposes *liqo-auth* and *liqo-gateway* with **LoadBalancer** services.
128128
To change this behavior, check the [network flags](NetworkFlags).
129129
```
130+
131+
```{admonition} Virtual Network Resource Group
132+
By default, it is assumed the Virtual Network Resource for the AKS Subnet is located in the same Resource Group
133+
as the AKS Resource. If that is not the case, you will need to use the `--vnet-resource-group-name` flag to provide the
134+
correct Resource Group name where the Virtual Network Resource is located.
135+
```
130136
````
131137
132138
````{tab-item} EKS

pkg/liqoctl/install/aks/provider.go

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,12 @@ var _ install.Provider = (*Options)(nil)
3737
type 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

Comments
 (0)