github.com/cilium/cilium@v1.16.2/operator/cmd/provider_aws_flags.go (about)

     1  // SPDX-License-Identifier: Apache-2.0
     2  // Copyright Authors of Cilium
     3  
     4  //go:build ipam_provider_aws
     5  
     6  package cmd
     7  
     8  import (
     9  	"github.com/spf13/cobra"
    10  	"github.com/spf13/viper"
    11  
    12  	operatorOption "github.com/cilium/cilium/operator/option"
    13  	"github.com/cilium/cilium/pkg/defaults"
    14  	"github.com/cilium/cilium/pkg/option"
    15  )
    16  
    17  func init() {
    18  	FlagsHooks = append(FlagsHooks, &awsFlagsHooks{})
    19  }
    20  
    21  type awsFlagsHooks struct{}
    22  
    23  func (hook *awsFlagsHooks) RegisterProviderFlag(cmd *cobra.Command, vp *viper.Viper) {
    24  	flags := cmd.Flags()
    25  
    26  	flags.Var(option.NewNamedMapOptions(operatorOption.AWSInstanceLimitMapping, &operatorOption.Config.AWSInstanceLimitMapping, nil),
    27  		operatorOption.AWSInstanceLimitMapping,
    28  		`Add or overwrite mappings of AWS instance limit in the form of `+
    29  			`{"AWS instance type": "Maximum Network Interfaces","IPv4 Addresses `+
    30  			`per Interface","IPv6 Addresses per Interface"}. cli example: `+
    31  			`--aws-instance-limit-mapping=a1.medium=2,4,4 `+
    32  			`--aws-instance-limit-mapping=a2.somecustomflavor=4,5,6 `+
    33  			`configmap example: {"a1.medium": "2,4,4", "a2.somecustomflavor": "4,5,6"}`)
    34  	option.BindEnv(vp, operatorOption.AWSInstanceLimitMapping)
    35  
    36  	flags.Bool(operatorOption.AWSReleaseExcessIPs, false, "Enable releasing excess free IP addresses from AWS ENI.")
    37  	option.BindEnv(vp, operatorOption.AWSReleaseExcessIPs)
    38  
    39  	flags.Int(operatorOption.ExcessIPReleaseDelay, 180, "Number of seconds operator would wait before it releases an IP previously marked as excess")
    40  	option.BindEnv(vp, operatorOption.ExcessIPReleaseDelay)
    41  
    42  	flags.Bool(operatorOption.AWSEnablePrefixDelegation, false, "Allows operator to allocate prefixes to ENIs instead of individual IP addresses")
    43  	option.BindEnv(vp, operatorOption.AWSEnablePrefixDelegation)
    44  
    45  	flags.Var(option.NewNamedMapOptions(operatorOption.ENITags, &operatorOption.Config.ENITags, nil),
    46  		operatorOption.ENITags, "ENI tags in the form of k1=v1 (multiple k/v pairs can be passed by repeating the CLI flag)")
    47  	option.BindEnv(vp, operatorOption.ENITags)
    48  
    49  	flags.Var(option.NewNamedMapOptions(operatorOption.ENIGarbageCollectionTags, &operatorOption.Config.ENIGarbageCollectionTags, nil),
    50  		operatorOption.ENIGarbageCollectionTags, "Additional tags attached to ENIs created by Cilium. Dangling ENIs with this tag will be garbage collected")
    51  	option.BindEnv(vp, operatorOption.ENIGarbageCollectionTags)
    52  
    53  	flags.Duration(operatorOption.ENIGarbageCollectionInterval, defaults.ENIGarbageCollectionInterval,
    54  		"Interval for garbage collection of unattached ENIs. Set to 0 to disable")
    55  	option.BindEnv(vp, operatorOption.ENIGarbageCollectionInterval)
    56  
    57  	flags.Bool(operatorOption.UpdateEC2AdapterLimitViaAPI, true, "Use the EC2 API to update the instance type to adapter limits")
    58  	option.BindEnv(vp, operatorOption.UpdateEC2AdapterLimitViaAPI)
    59  
    60  	flags.Bool(operatorOption.AWSUsePrimaryAddress, false, "Allows for using primary address of the ENI for allocations on the node")
    61  	option.BindEnv(vp, operatorOption.AWSUsePrimaryAddress)
    62  
    63  	flags.String(operatorOption.EC2APIEndpoint, "", "AWS API endpoint for the EC2 service")
    64  	option.BindEnv(vp, operatorOption.EC2APIEndpoint)
    65  
    66  	vp.BindPFlags(flags)
    67  }