Skip to content

Commit 10ea531

Browse files
author
Luigi Bitonti
committed
466 remove setupebtables option
1 parent c515c13 commit 10ea531

File tree

3 files changed

+0
-66
lines changed

3 files changed

+0
-66
lines changed

Dockerfile.node-cache

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
# limitations under the License.
1414

1515
FROM ARG_FROM_IPT
16-
RUN update-alternatives --set ebtables /usr/sbin/ebtables-legacy
1716
ADD bin/ARG_ARCH/ARG_BIN /ARG_BIN
1817
EXPOSE 53 53/udp
1918
EXPOSE 53 53/tcp

cmd/node-cache/app/cache_app.go

-64
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
utiliptables "k8s.io/kubernetes/pkg/util/iptables"
1717
utilexec "k8s.io/utils/exec"
1818
utilnet "k8s.io/utils/net"
19-
utilebtables "k8s.io/utils/net/ebtables"
2019
)
2120

2221
// ConfigParams lists the configuration options that can be provided to node-cache
@@ -35,7 +34,6 @@ type ConfigParams struct {
3534
UpstreamSvcName string // Name of the service whose clusterIP is the upstream for node-cache for cluster domain
3635
HealthPort string // port for the healthcheck
3736
SetupIptables bool
38-
SetupEbtables bool
3937
SkipTeardown bool // Indicates whether the iptables rules and interface should be torn down
4038
}
4139

@@ -45,18 +43,10 @@ type iptablesRule struct {
4543
args []string
4644
}
4745

48-
type ebtablesRule struct {
49-
table utilebtables.Table
50-
chain utilebtables.Chain
51-
args []string
52-
}
53-
5446
// CacheApp contains all the config required to run node-cache.
5547
type CacheApp struct {
5648
iptables utiliptables.Interface
5749
iptablesRules []iptablesRule
58-
ebtables utilebtables.Interface
59-
ebtablesRules []ebtablesRule
6050
params *ConfigParams
6151
netifHandle *netif.NetifManager
6252
kubednsConfig *options.KubeDNSConfig
@@ -76,9 +66,6 @@ func (c *CacheApp) Init() {
7666
if c.params.SetupIptables {
7767
c.initIptables()
7868
}
79-
if c.params.SetupEbtables {
80-
c.initEbtables()
81-
}
8269
initMetrics(c.params.MetricsListenAddress)
8370
// Write the config file from template.
8471
// this is required in case there is no or erroneous kube-dns configpath specified.
@@ -153,27 +140,6 @@ func newIPTables(isIPv6 bool) utiliptables.Interface {
153140
return utiliptables.New(execer, dbus, protocol)
154141
}
155142

156-
func (c *CacheApp) initEbtables() {
157-
protocol := "IPv4"
158-
if c.isIPv6() {
159-
protocol = "IPv6"
160-
}
161-
// using the localIPStr param since we need ip strings here
162-
for _, localIP := range strings.Split(c.params.LocalIPStr, ",") {
163-
c.ebtablesRules = append(c.ebtablesRules, []ebtablesRule{
164-
// Match traffic destined for localIp and use the MAC address of the bridge port as destination address
165-
{utilebtables.TableBroute, utilebtables.ChainBrouting, []string{"-p", protocol, "--ip-dst", localIP,
166-
"-j", "redirect"}},
167-
}...)
168-
}
169-
c.ebtables = newEBTables()
170-
}
171-
172-
func newEBTables() utilebtables.Interface {
173-
execer := utilexec.New()
174-
return utilebtables.New(execer)
175-
}
176-
177143
// TeardownNetworking removes all custom iptables rules and network interface added by node-cache
178144
func (c *CacheApp) TeardownNetworking() error {
179145
clog.Infof("Tearing down")
@@ -196,17 +162,6 @@ func (c *CacheApp) TeardownNetworking() error {
196162
// Delete the rule one last time since EnsureRule creates the rule if it doesn't exist
197163
c.iptables.DeleteRule(rule.table, rule.chain, rule.args...)
198164
}
199-
if c.params.SetupEbtables {
200-
for _, rule := range c.ebtablesRules {
201-
exists := true
202-
for exists == true {
203-
c.ebtables.DeleteRule(rule.table, rule.chain, rule.args...)
204-
exists, _ = c.ebtables.EnsureRule(utilebtables.Append, rule.table, rule.chain, rule.args...)
205-
}
206-
// Delete the rule one last time since EnsureRule creates the rule if it doesn't exist
207-
c.ebtables.DeleteRule(rule.table, rule.chain, rule.args...)
208-
}
209-
}
210165
}
211166
return err
212167
}
@@ -234,25 +189,6 @@ func (c *CacheApp) setupNetworking() {
234189
}
235190
}
236191

237-
if c.params.SetupEbtables {
238-
for _, rule := range c.ebtablesRules {
239-
exists, err := c.ebtables.EnsureRule(utilebtables.Append, rule.table, rule.chain, rule.args...)
240-
switch {
241-
case exists:
242-
// debug messages can be printed by including "debug" plugin in coreFile.
243-
clog.Debugf("ebtables rule %v for nodelocaldns already exists", rule)
244-
continue
245-
case err == nil:
246-
clog.Infof("Added back ebtables rule - %v", rule)
247-
continue
248-
// if we got here, either ebtables check failed or adding rule back failed.
249-
default:
250-
clog.Errorf("Error adding ebtables rule %v - %s", rule, err)
251-
setupErrCount.WithLabelValues("ebtables").Inc()
252-
}
253-
}
254-
}
255-
256192
if c.params.SetupInterface {
257193
exists, err := c.netifHandle.EnsureDummyDevice(c.params.InterfaceName)
258194
if !exists {

cmd/node-cache/main.go

-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ func parseAndValidateFlags() (*app.ConfigParams, error) {
6969
flag.DurationVar(&params.Interval, "syncinterval", 60, "interval(in seconds) to check for iptables rules")
7070
flag.StringVar(&params.MetricsListenAddress, "metrics-listen-address", "0.0.0.0:9353", "address to serve metrics on")
7171
flag.BoolVar(&params.SetupIptables, "setupiptables", true, "indicates whether iptables rules should be setup")
72-
flag.BoolVar(&params.SetupEbtables, "setupebtables", false, "indicates whether ebtables rules should be setup")
7372
flag.StringVar(&params.BaseCoreFile, "basecorefile", "/etc/coredns/Corefile.base", "Path to the template Corefile for node-cache")
7473
flag.StringVar(&params.CoreFile, "corefile", "/etc/Corefile", "Path to the Corefile to be used by node-cache")
7574
flag.StringVar(&params.KubednsCMPath, "kubednscm", "", "Path where the kube-dns configmap will be mounted")

0 commit comments

Comments
 (0)