Skip to content

Commit

Permalink
Enable IP forwarding in azure
Browse files Browse the repository at this point in the history
  • Loading branch information
realjenius committed Aug 8, 2024
1 parent 0b9a678 commit a666643
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion pkg/cloudprovider/provider/azure/create_delete_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ func getVirtualNetwork(ctx context.Context, c *config) (network.VirtualNetwork,
return virtualNetworksClient.Get(ctx, c.VNetResourceGroup, c.VNetName, "")
}

func createOrUpdateNetworkInterface(ctx context.Context, log *zap.SugaredLogger, ifName string, machineUID types.UID, config *config, publicIP, publicIPv6 *network.PublicIPAddress, ipFamily util.IPFamily, enableAcceleratedNetworking *bool) (*network.Interface, error) {
func createOrUpdateNetworkInterface(ctx context.Context, log *zap.SugaredLogger, ifName string, machineUID types.UID, config *config, publicIP, publicIPv6 *network.PublicIPAddress, ipFamily util.IPFamily, enableAcceleratedNetworking *bool, enableIPForwarding *bool) (*network.Interface, error) {
ifClient, err := getInterfacesClient(config)
if err != nil {
return nil, fmt.Errorf("failed to create interfaces client: %w", err)
Expand Down Expand Up @@ -363,6 +363,7 @@ func createOrUpdateNetworkInterface(ctx context.Context, log *zap.SugaredLogger,
}

ifSpec.InterfacePropertiesFormat.EnableAcceleratedNetworking = enableAcceleratedNetworking
ifSpec.InterfacePropertiesFormat.EnableIPForwarding = enableIPForwarding

if config.SecurityGroupName != "" {
authorizer, err := auth.NewClientCredentialsConfig(config.ClientID, config.ClientSecret, config.TenantID).Authorizer()
Expand Down
6 changes: 4 additions & 2 deletions pkg/cloudprovider/provider/azure/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ type config struct {
AssignPublicIP bool
PublicIPSKU *network.PublicIPAddressSkuName
EnableAcceleratedNetworking *bool
EnableIPForwarding *bool
EnableBootDiagnostics bool
Tags map[string]string
}
Expand Down Expand Up @@ -335,6 +336,7 @@ func (p *provider) getConfig(provSpec clusterv1alpha1.ProviderSpec) (*config, *p

c.AssignAvailabilitySet = rawCfg.AssignAvailabilitySet
c.EnableAcceleratedNetworking = rawCfg.EnableAcceleratedNetworking
c.EnableIPForwarding = rawCfg.EnableIPForwarding

c.AvailabilitySet, err = p.configVarResolver.GetConfigVarStringValue(rawCfg.AvailabilitySet)
if err != nil {
Expand Down Expand Up @@ -639,7 +641,7 @@ func (p *provider) Create(ctx context.Context, log *zap.SugaredLogger, machine *
return nil, err
}

iface, err := createOrUpdateNetworkInterface(ctx, log, ifaceName(machine), machine.UID, config, publicIP, publicIPv6, ipFamily, config.EnableAcceleratedNetworking)
iface, err := createOrUpdateNetworkInterface(ctx, log, ifaceName(machine), machine.UID, config, publicIP, publicIPv6, ipFamily, config.EnableAcceleratedNetworking, config.EnableIPForwarding)
if err != nil {
return nil, fmt.Errorf("failed to generate main network interface: %w", err)
}
Expand Down Expand Up @@ -1157,7 +1159,7 @@ func (p *provider) MigrateUID(ctx context.Context, log *zap.SugaredLogger, machi
}

if kuberneteshelper.HasFinalizer(machine, finalizerNIC) {
_, err = createOrUpdateNetworkInterface(ctx, log, ifaceName(machine), newUID, config, publicIP, publicIPv6, util.IPFamilyUnspecified, config.EnableAcceleratedNetworking)
_, err = createOrUpdateNetworkInterface(ctx, log, ifaceName(machine), newUID, config, publicIP, publicIPv6, util.IPFamilyUnspecified, config.EnableAcceleratedNetworking, config.EnableIPForwarding)
if err != nil {
return fmt.Errorf("failed to update UID on main network interface: %w", err)
}
Expand Down
1 change: 1 addition & 0 deletions pkg/cloudprovider/provider/azure/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type RawConfig struct {
ImagePlan *ImagePlan `json:"imagePlan,omitempty"`
ImageReference *ImageReference `json:"imageReference,omitempty"`
EnableAcceleratedNetworking *bool `json:"enableAcceleratedNetworking"`
EnableIPForwarding *bool `json:"enableIPForwarding"`
EnableBootDiagnostics *bool `json:"enableBootDiagnostics,omitempty"`

ImageID providerconfigtypes.ConfigVarString `json:"imageID"`
Expand Down

0 comments on commit a666643

Please sign in to comment.