Skip to content

Commit 8ccb53a

Browse files
committed
[ipam] add generic ipam-release-excess-ips flag and wire Azure
Signed-off-by: Jared Ledvina <jared.ledvina@datadoghq.com>
1 parent 8ee61c7 commit 8ccb53a

4 files changed

Lines changed: 19 additions & 6 deletions

File tree

operator/pkg/ipam/allocator/azure/azure.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ type AllocatorAzure struct {
2222
AzureResourceGroup string
2323
AzureUserAssignedIdentityID string
2424
AzureUsePrimaryAddress bool
25+
AzureReleaseExcessIPs bool
26+
ExcessIPReleaseDelay int
2527
ParallelAllocWorkers int64
2628
LimitIPAMAPIBurst int
2729
LimitIPAMAPIQPS float64
@@ -75,7 +77,7 @@ func (a *AllocatorAzure) Start(ctx context.Context, getterUpdater allocator.Cili
7577
return nil, fmt.Errorf("unable to create Azure client: %w", err)
7678
}
7779
instances := ipam.NewInstancesManager(a.rootLogger, azureClient, a.AzureUsePrimaryAddress)
78-
nodeManager, err := nodemanager.NewNodeManager(a.logger, instances, getterUpdater, iMetrics, a.ParallelAllocWorkers, false, 0, false)
80+
nodeManager, err := nodemanager.NewNodeManager(a.logger, instances, getterUpdater, iMetrics, a.ParallelAllocWorkers, a.AzureReleaseExcessIPs, a.ExcessIPReleaseDelay, false)
7981
if err != nil {
8082
return nil, fmt.Errorf("unable to initialize Azure node manager: %w", err)
8183
}

operator/pkg/ipam/aws.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ func init() {
3535

3636
type AWSConfig struct {
3737
AWSReleaseExcessIPs bool
38-
ExcessIPReleaseDelay int
3938
AWSEnablePrefixDelegation bool
4039
ENITags map[string]string
4140
ENIGarbageCollectionTags map[string]string `mapstructure:"eni-gc-tags"`
@@ -49,7 +48,6 @@ type AWSConfig struct {
4948

5049
var awsDefaultConfig = AWSConfig{
5150
AWSReleaseExcessIPs: false,
52-
ExcessIPReleaseDelay: 180,
5351
AWSEnablePrefixDelegation: false,
5452
ENITags: nil,
5553
ENIGarbageCollectionTags: nil,
@@ -63,7 +61,7 @@ var awsDefaultConfig = AWSConfig{
6361

6462
func (cfg AWSConfig) Flags(flags *pflag.FlagSet) {
6563
flags.Bool("aws-release-excess-ips", awsDefaultConfig.AWSReleaseExcessIPs, "Enable releasing excess free IP addresses from AWS ENI.")
66-
flags.Int("excess-ip-release-delay", awsDefaultConfig.ExcessIPReleaseDelay, "Number of seconds operator would wait before it releases an IP previously marked as excess")
64+
flags.MarkDeprecated("aws-release-excess-ips", "use --ipam-release-excess-ips instead")
6765
flags.Bool("aws-enable-prefix-delegation", awsDefaultConfig.AWSEnablePrefixDelegation, "Allows operator to allocate prefixes to ENIs instead of individual IP addresses")
6866
flags.StringToString("eni-tags", awsDefaultConfig.ENITags,
6967
"ENI tags in the form of k1=v1 (multiple k/v pairs can be passed by repeating the CLI flag)")
@@ -97,8 +95,8 @@ type awsParams struct {
9795

9896
func startAWSAllocator(p awsParams) {
9997
alloc := &aws.AllocatorAWS{
100-
AWSReleaseExcessIPs: p.AwsCfg.AWSReleaseExcessIPs,
101-
ExcessIPReleaseDelay: p.AwsCfg.ExcessIPReleaseDelay,
98+
AWSReleaseExcessIPs: p.AwsCfg.AWSReleaseExcessIPs || p.Cfg.IPAMReleaseExcessIPs,
99+
ExcessIPReleaseDelay: p.Cfg.ExcessIPReleaseDelay,
102100
AWSEnablePrefixDelegation: p.AwsCfg.AWSEnablePrefixDelegation,
103101
ENITags: p.AwsCfg.ENITags,
104102
ENIGarbageCollectionTags: p.AwsCfg.ENIGarbageCollectionTags,

operator/pkg/ipam/azure.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ func startAzureAllocator(p azureParams) {
7676
AzureResourceGroup: p.AzureCfg.AzureResourceGroup,
7777
AzureUserAssignedIdentityID: p.AzureCfg.AzureUserAssignedIdentityID,
7878
AzureUsePrimaryAddress: p.AzureCfg.AzureUsePrimaryAddress,
79+
AzureReleaseExcessIPs: p.Cfg.IPAMReleaseExcessIPs,
80+
ExcessIPReleaseDelay: p.Cfg.ExcessIPReleaseDelay,
7981
ParallelAllocWorkers: p.Cfg.ParallelAllocWorkers,
8082
LimitIPAMAPIBurst: p.Cfg.LimitIPAMAPIBurst,
8183
LimitIPAMAPIQPS: p.Cfg.LimitIPAMAPIQPS,

operator/pkg/ipam/cell.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,27 @@ type Config struct {
3131
ParallelAllocWorkers int64
3232
LimitIPAMAPIBurst int
3333
LimitIPAMAPIQPS float64
34+
// IPAMReleaseExcessIPs enables releasing excess free IP addresses,
35+
// independent of cloud provider. It supersedes the per-provider
36+
// --{aws,alibaba-cloud}-release-excess-ips flags.
37+
IPAMReleaseExcessIPs bool
38+
// ExcessIPReleaseDelay is the number of seconds the operator waits before
39+
// it releases an IP previously marked as excess.
40+
ExcessIPReleaseDelay int
3441
}
3542

3643
var defaultConfig = Config{
3744
ParallelAllocWorkers: 50,
3845
LimitIPAMAPIBurst: 20,
3946
LimitIPAMAPIQPS: 4.0,
47+
IPAMReleaseExcessIPs: false,
48+
ExcessIPReleaseDelay: 180,
4049
}
4150

4251
func (cfg Config) Flags(flags *pflag.FlagSet) {
4352
flags.Int64(option.ParallelAllocWorkers, defaultConfig.ParallelAllocWorkers, "Maximum number of parallel IPAM workers")
4453
flags.Int("limit-ipam-api-burst", defaultConfig.LimitIPAMAPIBurst, "Upper burst limit when accessing external APIs")
4554
flags.Float64("limit-ipam-api-qps", defaultConfig.LimitIPAMAPIQPS, "Queries per second limit when accessing external IPAM APIs")
55+
flags.Bool("ipam-release-excess-ips", defaultConfig.IPAMReleaseExcessIPs, "Enable releasing excess free IP addresses from the cloud provider, regardless of the provider in use.")
56+
flags.Int("excess-ip-release-delay", defaultConfig.ExcessIPReleaseDelay, "Number of seconds operator would wait before it releases an IP previously marked as excess")
4657
}

0 commit comments

Comments
 (0)