Skip to content

Commit 05d03e7

Browse files
DandyDevelopermurali-reddy
authored andcommitted
cloudnativelabs#797 Conditionally disable "Allow All" input/chain on IPVS KUBE-ROUTER-SERVICES (cloudnativelabs#809)
* Added flag and condition for open input on iptables cloudnativelabs#797 * Adding flag to docs. * Updated to remove INPUT/CHAIN entirely. Name changed to IpvsDenyAll. * Updated README. * Updated docstring on ipvs-deny-all * ipvsDenyAll -> ipvsPermitAll * Updating user guide. * Descriptions updates per review
1 parent ff6a024 commit 05d03e7

File tree

5 files changed

+17
-5
lines changed

5 files changed

+17
-5
lines changed

docs/user-guide.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ Usage of kube-router:
6161
--ipvs-graceful-period duration The graceful period before removing destinations from IPVS services (e.g. '5s', '1m', '2h22m'). Must be greater than 0. (default 30s)
6262
--ipvs-graceful-termination Enables the experimental IPVS graceful terminaton capability
6363
--ipvs-sync-period duration The delay between ipvs config synchronizations (e.g. '5s', '1m', '2h22m'). Must be greater than 0. (default 5m0s)
64+
--ipvs-permit-all Permit all inbound traffic to the service VIP's
6465
--kubeconfig string Path to kubeconfig file with authorization information (the master location is set by the master flag).
6566
--masquerade-all SNAT all traffic to cluster IP/node port.
6667
--master string The address of the Kubernetes API server (overrides any value in kubeconfig).

pkg/controllers/proxy/network_services_controller.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ type NetworkServicesController struct {
212212
podCidr string
213213
masqueradeAll bool
214214
globalHairpin bool
215+
ipvsPermitAll bool
215216
client kubernetes.Interface
216217
nodeportBindOnAllIp bool
217218
MetricsEnabled bool
@@ -505,8 +506,14 @@ func (nsc *NetworkServicesController) setupIpvsFirewall() error {
505506
return fmt.Errorf("Failed to run iptables command: %s", err.Error())
506507
}
507508

509+
// config.IpvsPermitAll: true then create INPUT/KUBE-ROUTER-SERVICE Chain creation else return
510+
if !config.ipvsPermitAll {
511+
return nil
512+
}
513+
508514
var comment string
509515
var args []string
516+
var exists bool
510517

511518
comment = "allow input traffic to ipvs services"
512519
args = []string{"-m", "comment", "--comment", comment,
@@ -561,8 +568,8 @@ func (nsc *NetworkServicesController) setupIpvsFirewall() error {
561568

562569
func (nsc *NetworkServicesController) cleanupIpvsFirewall() {
563570
/*
564-
- delete firewall rules
565-
- delete ipsets
571+
- delete firewall rules
572+
- delete ipsets
566573
*/
567574
var err error
568575

@@ -2446,6 +2453,8 @@ func NewNetworkServicesController(clientset kubernetes.Interface,
24462453
nsc.svcLister = svcInformer.GetIndexer()
24472454
nsc.ServiceEventHandler = nsc.newSvcEventHandler()
24482455

2456+
nsc.ipvsPermitAll = config.IpvsPermitAll
2457+
24492458
nsc.epLister = epInformer.GetIndexer()
24502459
nsc.EndpointsEventHandler = nsc.newEndpointsEventHandler()
24512460

pkg/controllers/proxy/network_services_controller_moq.go

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/options/options.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ type KubeRouterConfig struct {
3939
IpvsSyncPeriod time.Duration
4040
IpvsGracefulPeriod time.Duration
4141
IpvsGracefulTermination bool
42+
IpvsPermitAll bool
4243
Kubeconfig string
4344
MasqueradeAll bool
4445
Master string
@@ -108,6 +109,8 @@ func (s *KubeRouterConfig) AddFlags(fs *pflag.FlagSet) {
108109
"The graceful period before removing destinations from IPVS services (e.g. '5s', '1m', '2h22m'). Must be greater than 0.")
109110
fs.BoolVar(&s.IpvsGracefulTermination, "ipvs-graceful-termination", false,
110111
"Enables the experimental IPVS graceful terminaton capability")
112+
fs.BoolVar(&s.IpvsPermitAll, "ipvs-permit-all", true,
113+
"Enables rule to accept all incoming traffic to service VIP's on the node.")
111114
fs.DurationVar(&s.RoutesSyncPeriod, "routes-sync-period", s.RoutesSyncPeriod,
112115
"The delay between route updates and advertisements (e.g. '5s', '1m', '2h22m'). Must be greater than 0.")
113116
fs.BoolVar(&s.AdvertiseClusterIp, "advertise-cluster-ip", false,
21.5 MB
Binary file not shown.

0 commit comments

Comments
 (0)