Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ build:
PLATFORM ?= linux/amd64
.PHONY: docker-image
docker-image:
@docker buildx build --platform $(PLATFORM) -t $(IMAGE_REPOSITORY):$(IMAGE_TAG) .
@docker buildx build --load --platform $(PLATFORM) -t $(IMAGE_REPOSITORY):$(IMAGE_TAG) .

.PHONY: docker-login
docker-login:
Expand Down
3 changes: 2 additions & 1 deletion pkg/azure/access/helpers/nic.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ package helpers

import (
"context"
"k8s.io/klog/v2"
"time"

"github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4"
"k8s.io/klog/v2"

"github.com/gardener/machine-controller-manager-provider-azure/pkg/azure/access/errors"
"github.com/gardener/machine-controller-manager-provider-azure/pkg/azure/instrument"
)
Expand Down
7 changes: 7 additions & 0 deletions pkg/azure/api/providerspec.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ type AzureProviderSpec struct {
SubnetInfo AzureSubnetInfo `json:"subnetInfo,omitempty"`
// CloudConfiguration contains config that controls which cloud to connect to
CloudConfiguration *CloudConfiguration `json:"cloudConfiguration,omitempty"`
// BackendAddressPoolConfig contains the configuration for the Azure Load Balancer.
BackendAddressPoolConfig *AzureBackendAddressPoolConfig `json:"backendAddressPoolConfig,omitempty"`
}

// AzureVirtualMachineProperties describes the properties of a Virtual Machine.
Expand Down Expand Up @@ -330,3 +332,8 @@ type CloudConfiguration struct {
// Name is the name of the cloud to connect to, e.g. "AzurePublic" or "AzureChina".
Name string `json:"name"`
}

// AzureBackendAddressPoolConfig is the configuration for a backend pool address in an Azure Load Balancer.
type AzureBackendAddressPoolConfig struct {
ID string `json:"id"`
}
11 changes: 10 additions & 1 deletion pkg/azure/provider/helpers/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
corev1 "k8s.io/api/core/v1"
"k8s.io/klog/v2"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"

"github.com/gardener/machine-controller-manager-provider-azure/pkg/azure/access"
accesserrors "github.com/gardener/machine-controller-manager-provider-azure/pkg/azure/access/errors"
Expand Down Expand Up @@ -393,12 +394,13 @@ func CreateNICIfNotExists(ctx context.Context, factory access.Factory, connectCo
if err != nil {
return "", status.WrapError(codes.Internal, fmt.Sprintf("failed to create NIC: [ResourceGroup: %s, Name: %s], Err: %v", providerSpec.ResourceGroup, nicName, err), err)
}

klog.Infof("Successfully created NIC: [ResourceGroup: %s, NIC: [Name: %s, ID: %s]]", resourceGroup, nicName, *nic.ID)
return *nic.ID, nil
}

func createNICParams(providerSpec api.AzureProviderSpec, subnet *armnetwork.Subnet, nicName string) armnetwork.Interface {
return armnetwork.Interface{
ifc := armnetwork.Interface{
Location: to.Ptr(providerSpec.Location),
Properties: &armnetwork.InterfacePropertiesFormat{
EnableAcceleratedNetworking: providerSpec.Properties.NetworkProfile.AcceleratedNetworking,
Expand All @@ -407,6 +409,7 @@ func createNICParams(providerSpec api.AzureProviderSpec, subnet *armnetwork.Subn
{
Name: &nicName,
Properties: &armnetwork.InterfaceIPConfigurationPropertiesFormat{
Primary: ptr.To(true),
PrivateIPAllocationMethod: to.Ptr(armnetwork.IPAllocationMethodDynamic),
Subnet: subnet,
},
Expand All @@ -417,6 +420,12 @@ func createNICParams(providerSpec api.AzureProviderSpec, subnet *armnetwork.Subn
Tags: createNICTags(providerSpec.Tags),
Name: &nicName,
}
if providerSpec.BackendAddressPoolConfig != nil {
ifc.Properties.IPConfigurations[0].Properties.LoadBalancerBackendAddressPools = []*armnetwork.BackendAddressPool{
{ID: ptr.To(providerSpec.BackendAddressPoolConfig.ID)},
}
}
return ifc
}

func createNICTags(tags map[string]string) map[string]*string {
Expand Down
Loading