Skip to content

Commit

Permalink
Adding optional flag for vnet resource group for scenarios when the v…
Browse files Browse the repository at this point in the history
…net is in a different resource group from the AKS resource
  • Loading branch information
scottboring authored and adamjensenbot committed Aug 25, 2023
1 parent 5637205 commit 94c73c0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
6 changes: 6 additions & 0 deletions docs/installation/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ Additionally, since your API Server is not accessible from the public Internet,
By default, the **AKS** provider exposes *liqo-auth* and *liqo-gateway* with **LoadBalancer** services.
To change this behavior, check the [network flags](NetworkFlags).
```
```{admonition} Virtual Network Resource Group
By default, it is assumed the Virtual Network Resource for the AKS Subnet is located in the same Resource Group
as the AKS Resource. If that is not the case, you will need to use the `--vnet-resource-group-name` flag to provide the
correct Resource Group name where the Virtual Network Resource is located.
```
````
````{tab-item} EKS
Expand Down
22 changes: 15 additions & 7 deletions pkg/liqoctl/install/aks/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ var _ install.Provider = (*Options)(nil)
type Options struct {
*install.Options

subscriptionName string
subscriptionID string
resourceGroupName string
resourceName string
fqdn string
subscriptionName string
subscriptionID string
resourceGroupName string
resourceName string
vnetResourceGroupName string
fqdn string

authorizer *autorest.Authorizer
}
Expand Down Expand Up @@ -72,6 +73,8 @@ func (o *Options) RegisterFlags(cmd *cobra.Command) {
cmd.Flags().StringVar(&o.resourceGroupName, "resource-group-name", "",
"The Azure ResourceGroup name of the cluster")
cmd.Flags().StringVar(&o.resourceName, "resource-name", "", "The Azure Name of the cluster")
cmd.Flags().StringVar(&o.vnetResourceGroupName, "vnet-resource-group-name", "",
"The Azure ResourceGroup name of the Virtual Network (defaults to --resource-group-name if not provided)")
cmd.Flags().StringVar(&o.fqdn, "fqdn", "", "The private AKS cluster fqdn")

utilruntime.Must(cmd.MarkFlagRequired("resource-group-name"))
Expand All @@ -83,11 +86,16 @@ func (o *Options) Initialize(ctx context.Context) error {
if o.subscriptionID == "" && o.subscriptionName == "" {
return fmt.Errorf("neither --subscription-id nor --subscription-name specified")
}
if o.vnetResourceGroupName == "" {
// use AKS resource group if vnet resource group not provided
o.vnetResourceGroupName = o.resourceGroupName
}

o.Printer.Verbosef("AKS SubscriptionID: %q", o.subscriptionID)
o.Printer.Verbosef("AKS SubscriptionName: %q", o.subscriptionName)
o.Printer.Verbosef("AKS ResourceGroupName: %q", o.resourceGroupName)
o.Printer.Verbosef("AKS ResourceName: %q", o.resourceName)
o.Printer.Verbosef("VNET ResourceGroupName: %q", o.vnetResourceGroupName)

// if the cluster name has not been provided, we default it to the cloud provider resource name.
if o.ClusterName == "" {
Expand Down Expand Up @@ -189,7 +197,7 @@ func (o *Options) setupKubenet(ctx context.Context, cluster *containerservice.Ma
return err
}

vnet, err := networkClient.Get(ctx, o.resourceGroupName, vnetName, subnetName, "")
vnet, err := networkClient.Get(ctx, o.vnetResourceGroupName, vnetName, subnetName, "")
if err != nil {
return err
}
Expand All @@ -212,7 +220,7 @@ func (o *Options) setupAzureCNI(ctx context.Context, cluster *containerservice.M
return err
}

vnet, err := networkClient.Get(ctx, o.resourceGroupName, vnetName, subnetName, "")
vnet, err := networkClient.Get(ctx, o.vnetResourceGroupName, vnetName, subnetName, "")
if err != nil {
return err
}
Expand Down

0 comments on commit 94c73c0

Please sign in to comment.