Skip to content

Commit 77459dd

Browse files
rjosephwrightmurali-reddy
authored andcommitted
Add CLI option to toggle disabling of source-dest-check in EC2 (#541)
When the number of nodes in a cluster is high enough, the `disableSourceDestinationCheck()` logic creates a high number of requests to EC2, resulting in throttling and subsequent problems, such as the inability to attach EBS volumes. This is not necessarily mitigated by the `ec2IamAuthorized` attribute which was added to overcome this issue, as the number of requests can still be high enough to reach Amazon's request limits. In addition, it is not necessary to run this multiple times in a loop for all the nodes in a cluster, as it is sufficient to set it once when an instance boots. This CLI option allows an administrator to turn off this feature for kube-router so they can use some other means of setting the attribute.
1 parent cadba6c commit 77459dd

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

docs/user-guide.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Usage of kube-router:
3636
--cleanup-config Cleanup iptables rules, ipvs, ipset configuration and exit.
3737
--cluster-asn uint ASN number under which cluster nodes will run iBGP.
3838
--cluster-cidr string CIDR range of pods in the cluster. It is used to identify traffic originating from and destinated to pods.
39+
--disable-source-dest-check Disable the source-dest-check attribute for AWS EC2 instances. When this option is false, it must be set some other way. (default true)
3940
--enable-cni Enable CNI plugin. Disable if you want to use kube-router features alongside another CNI plugin. (default true)
4041
--enable-ibgp Enables peering with nodes with the same ASN, if disabled will only peer with external BGP peers (default true)
4142
--enable-overlay When enable-overlay set to true, IP-in-IP tunneling is used for pod-to-pod networking across nodes in different subnets. When set to false no tunneling is used and routing infrastrcture is expected to route traffic for pod-to-pod networking across nodes in different subnets (default true)

pkg/controllers/routing/bgp_peers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ func (nrc *NetworkRoutingController) OnNodeUpdate(obj interface{}) {
333333

334334
// skip if first round of disableSourceDestinationCheck() is not done yet, this is to prevent
335335
// all the nodes for all the node add update trying to perfrom disableSourceDestinationCheck
336-
if nrc.initSrcDstCheckDone && nrc.ec2IamAuthorized {
336+
if nrc.disableSrcDstCheck && nrc.initSrcDstCheckDone && nrc.ec2IamAuthorized {
337337
nrc.disableSourceDestinationCheck()
338338
}
339339
}

pkg/controllers/routing/network_routes_controller.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ type NetworkRoutingController struct {
9090
bgpRRServer bool
9191
bgpClusterID uint32
9292
cniConfFile string
93+
disableSrcDstCheck bool
9394
initSrcDstCheckDone bool
9495
ec2IamAuthorized bool
9596
pathPrependAS string
@@ -121,8 +122,10 @@ func (nrc *NetworkRoutingController) Run(healthChan chan<- *healthcheck.Controll
121122
}
122123

123124
// In case of cluster provisioned on AWS disable source-destination check
124-
nrc.disableSourceDestinationCheck()
125-
nrc.initSrcDstCheckDone = true
125+
if nrc.disableSrcDstCheck {
126+
nrc.disableSourceDestinationCheck()
127+
nrc.initSrcDstCheckDone = true
128+
}
126129

127130
// enable IP forwarding for the packets coming in/out from the pods
128131
err = nrc.enableForwarding()
@@ -789,6 +792,7 @@ func NewNetworkRoutingController(clientset kubernetes.Interface,
789792
nrc.bgpRRClient = false
790793
nrc.bgpRRServer = false
791794
nrc.bgpServerStarted = false
795+
nrc.disableSrcDstCheck = kubeRouterConfig.DisableSrcDstCheck
792796
nrc.initSrcDstCheckDone = false
793797

794798
// lets start with assumption we hace necessary IAM creds to access EC2 api

pkg/options/options.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ type KubeRouterConfig struct {
2121
CleanupConfig bool
2222
ClusterAsn uint
2323
ClusterCIDR string
24+
DisableSrcDstCheck bool
2425
EnableCNI bool
2526
EnableiBGP bool
2627
EnableOverlay bool
@@ -144,4 +145,6 @@ func (s *KubeRouterConfig) AddFlags(fs *pflag.FlagSet) {
144145
fs.StringVarP(&s.VLevel, "v", "v", "0", "log level for V logs")
145146
fs.Uint16Var(&s.HealthPort, "health-port", 20244, "Health check port, 0 = Disabled")
146147
fs.BoolVar(&s.OverrideNextHop, "override-nexthop", false, "Override the next-hop in bgp routes sent to peers with the local ip.")
148+
fs.BoolVar(&s.DisableSrcDstCheck, "disable-source-dest-check", true,
149+
"Disable the source-dest-check attribute for AWS EC2 instances. When this option is false, it must be set some other way.")
147150
}

0 commit comments

Comments
 (0)