forked from cilium/cilium
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathcell.go
More file actions
52 lines (42 loc) · 1.66 KB
/
Copy pathcell.go
File metadata and controls
52 lines (42 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// SPDX-License-Identifier: Apache-2.0
// Copyright Authors of Cilium
package ipam
import (
"github.com/cilium/hive/cell"
"github.com/spf13/pflag"
"github.com/cilium/cilium/operator/option"
ipamMetrics "github.com/cilium/cilium/operator/pkg/ipam/metrics"
"github.com/cilium/cilium/pkg/metrics"
)
var allocators []cell.Cell
func Cell() cell.Cell {
return cell.Module(
"ip-allocator-provider",
"Operator IP allocator provider",
cell.Config(defaultConfig),
cell.ProvidePrivate(newNodeWatcherJobFactory),
metrics.Metric(ipamMetrics.NewMetrics),
cell.Group(allocators...),
)
}
type Config struct {
ParallelAllocWorkers int64
LimitIPAMAPIBurst int
LimitIPAMAPIQPS float64
IPAMReleaseExcessIPs bool
ExcessIPReleaseDelay int
}
var defaultConfig = Config{
ParallelAllocWorkers: 50,
LimitIPAMAPIBurst: 20,
LimitIPAMAPIQPS: 4.0,
IPAMReleaseExcessIPs: false,
ExcessIPReleaseDelay: 180,
}
func (cfg Config) Flags(flags *pflag.FlagSet) {
flags.Int64(option.ParallelAllocWorkers, defaultConfig.ParallelAllocWorkers, "Maximum number of parallel IPAM workers")
flags.Int("limit-ipam-api-burst", defaultConfig.LimitIPAMAPIBurst, "Upper burst limit when accessing external APIs")
flags.Float64("limit-ipam-api-qps", defaultConfig.LimitIPAMAPIQPS, "Queries per second limit when accessing external IPAM APIs")
flags.Bool("ipam-release-excess-ips", defaultConfig.IPAMReleaseExcessIPs, "Enable releasing excess free IP addresses from the cloud provider, regardless of the provider in use.")
flags.Int("excess-ip-release-delay", defaultConfig.ExcessIPReleaseDelay, "Number of seconds operator would wait before it releases an IP previously marked as excess")
}