azure

package
v1.6.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 28, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InternalVXLANPort = 10800
	ExternalVXLANPort = 10801
)

Variables

This section is empty.

Functions

func Apply

func Apply(ctx context.Context, ctrlConfig *controller.ControllerConfig, poolName string) error

Apply orchestrates Azure GWLB integration on startup. It discovers the GWLB backend pool, detects the VXLAN tunnel interface, updates controller configuration, and registers with the backend pool.

Steps: 1. Start preboot health server (allows GWLB health checks to pass during bootstrap) 2. Discover GWLB backend pool via IMDS and ARM API 3. Register VM with backend pool (so GWLB sends traffic) 4. Find VXLAN tunnel interface (UDP 10800/10801) - created after registration 5. Stop preboot health server (full API server takes over) 6. Update ctrlConfig.IngressDevice to tunnel interface

Returns error if any step fails (startup should abort).

func Cleanup

func Cleanup(ctx context.Context) error

Cleanup deregisters from the GWLB backend pool on shutdown. Called by SIGTERM handler in cmd/root.go SetupSignalHandler.

Returns error if deregistration fails. Non-fatal - acceptable for forced shutdown.

func DeregisterFromBackendPool

func DeregisterFromBackendPool(ctx context.Context, cfg *GWLBConfig) error

DeregisterFromBackendPool removes this VM from the GWLB backend pool. Must complete within 20s for graceful shutdown (RESEARCH.md Pitfall 6).

Returns error if deregistration fails. Acceptable to fail on forced shutdown.

func FindVXLANTunnelInterface

func FindVXLANTunnelInterface() (string, error)

FindVXLANTunnelInterface identifies the network interface receiving Azure GWLB VXLAN traffic. Returns interface name (e.g., "eth0") or error if not found.

Azure GWLB sends VXLAN-encapsulated traffic directly to eth0 as UDP packets on ports 10800/10801. Unlike AWS GWLB which creates a separate geneve interface, Azure delivers VXLAN traffic on the primary NIC. The BPF programs handle VXLAN decapsulation inline.

func IsRegisteredWithBackendPool

func IsRegisteredWithBackendPool(ctx context.Context, cfg *GWLBConfig) (bool, error)

IsRegisteredWithBackendPool checks if this VM is already registered with the backend pool. Checks both NIC-based associations (from Terraform) and IP-based registrations. Returns true if registered, false otherwise.

func RegisterWithBackendPool

func RegisterWithBackendPool(ctx context.Context, cfg *GWLBConfig) error

RegisterWithBackendPool adds this VM's private IP to the GWLB backend pool. Uses IP-based backend pool (not NIC-based) for VMSS auto-scaling support. Blocks until registration completes or times out (2 minutes max).

If the VM is already registered (via Terraform NIC association or previous IP registration), this function returns nil without modifying the backend pool.

Returns error if registration fails after retries.

func SetMetricsCollector

func SetMetricsCollector(mc *metrics.MetricsCollector)

SetMetricsCollector stores the metrics collector reference for registration status updates. Called from cmd/root.go after controller initialization.

Types

type GWLBConfig

type GWLBConfig struct {
	// From IMDS
	VMId           string
	SubscriptionID string
	ResourceGroup  string
	Location       string
	PrivateIP      string

	// From ARM API discovery
	LoadBalancerName string
	BackendPoolName  string
	VNetResourceID   string
}

GWLBConfig holds the configuration for Azure Gateway Load Balancer integration. It includes VM identity from IMDS, discovered GWLB details, and network configuration.

func DiscoverGWLBBackendPool

func DiscoverGWLBBackendPool(ctx context.Context, poolName string) (*GWLBConfig, error)

DiscoverGWLBBackendPool discovers the Azure Gateway Load Balancer backend pool for this VM instance.

Discovery process: 1. Query IMDS for VM identity (subscription, resource group, vmId, location) 2. Create DefaultAzureCredential for ARM API access (managed identity) 3. Query VM instance view to get primary NIC resource ID 4. Query NIC details to get private IP and VNet resource ID 5. Construct VNet resource ID in ARM format 6. List load balancers in resource group, filter by SKU = "Gateway" 7. Find backend pool by name (exact match on poolName parameter)

Returns:

  • *GWLBConfig: Complete configuration for GWLB registration
  • error: discovery failure (IMDS, credentials, ARM API, not found)

type IMDSMetadata

type IMDSMetadata struct {
	VMId           string `json:"vmId"`
	SubscriptionId string `json:"subscriptionId"`
	ResourceGroup  string `json:"resourceGroupName"`
	Location       string `json:"location"`
	Name           string `json:"name"`
}

IMDSMetadata represents the Azure Instance Metadata Service response. It contains VM identity and configuration information.

func QueryIMDS

func QueryIMDS(ctx context.Context) (*IMDSMetadata, error)

QueryIMDS queries the Azure Instance Metadata Service for VM metadata. It uses API version 2025-04-07 (latest) with required "Metadata: true" header.

The function handles retriable errors (404, 429, 410) and returns them for the caller to handle with exponential backoff.

Returns:

  • *IMDSMetadata: VM identity and configuration
  • error: retriable errors (404, 429, 410) or permanent errors

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL