Skip to content

Commit

Permalink
Allow specifying the maximum number of pods, not just the ENI limit (#69
Browse files Browse the repository at this point in the history
)

Can clamp pods to less than the ENI max, which can be 700+
  • Loading branch information
theatrus authored Jul 17, 2019
1 parent d3a84d5 commit 9970112
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions cmd/cni-ipvlan-vpc-k8s-tool/cni-ipvlan-vpc-k8s-tool.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,13 @@ func actionLimits(c *cli.Context) error {

func actionMaxPods(c *cli.Context) error {
limit := aws.DefaultClient.ENILimits()
fmt.Printf("%d\n", (limit.Adapters-1)*limit.IPv4)
specifiedMax := c.Int("max")
max := (limit.Adapters - 1) * limit.IPv4
if specifiedMax > 0 && specifiedMax < max {
// Limit the maximum to the CLI maximum
max = specifiedMax
}
fmt.Printf("%d\n", max)
return nil
}

Expand Down Expand Up @@ -418,8 +424,11 @@ func main() {
},
{
Name: "maxpods",
Usage: "Return a single number specifying the maximum number of pod addresses that can be used on this instance",
Usage: "Return a single number specifying the maximum number of pod addresses that can be used on this instance. Limit maximum with --max",
Action: actionMaxPods,
Flags: []cli.Flag{
cli.IntFlag{Name: "max"},
},
},
{
Name: "bugs",
Expand Down

0 comments on commit 9970112

Please sign in to comment.