Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
f785f3d3
Commit
f785f3d3
authored
Aug 27, 2016
by
Angus Salkeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up IPTables caps i.e.: sed -i "s/Iptables/IPTables/g"
parent
6fcbbe86
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
107 additions
and
116 deletions
+107
-116
server.go
cmd/kube-proxy/app/server.go
+18
-18
server_test.go
cmd/kube-proxy/app/server_test.go
+13
-13
eviction_manager.go
pkg/kubelet/eviction/eviction_manager.go
+3
-8
helpers.go
pkg/kubelet/eviction/helpers.go
+2
-6
fake_iptables.go
pkg/kubelet/network/hostport/fake_iptables.go
+21
-21
hostport.go
pkg/kubelet/network/hostport/hostport.go
+2
-2
hostport_test.go
pkg/kubelet/network/hostport/hostport_test.go
+4
-4
kubenet_linux.go
pkg/kubelet/network/kubenet/kubenet_linux.go
+3
-3
plugins.go
pkg/kubelet/network/plugins.go
+3
-3
proxier.go
pkg/proxy/iptables/proxier.go
+8
-8
iptables.go
pkg/util/iptables/iptables.go
+17
-17
iptables_test.go
pkg/util/iptables/iptables_test.go
+8
-8
conformance.go
test/e2e_node/environment/conformance.go
+5
-5
No files found.
cmd/kube-proxy/app/server.go
View file @
f785f3d3
...
...
@@ -68,14 +68,14 @@ type ProxyServer struct {
const
(
proxyModeUserspace
=
"userspace"
proxyModeI
pt
ables
=
"iptables"
proxyModeI
PT
ables
=
"iptables"
experimentalProxyModeAnnotation
=
options
.
ExperimentalProxyModeAnnotation
betaProxyModeAnnotation
=
"net.beta.kubernetes.io/proxy-mode"
)
func
checkKnownProxyMode
(
proxyMode
string
)
bool
{
switch
proxyMode
{
case
""
,
proxyModeUserspace
,
proxyModeI
pt
ables
:
case
""
,
proxyModeUserspace
,
proxyModeI
PT
ables
:
return
true
}
return
false
...
...
@@ -199,18 +199,18 @@ func NewProxyServerDefault(config *options.ProxyServerConfig) (*ProxyServer, err
var
endpointsHandler
proxyconfig
.
EndpointsConfigHandler
proxyMode
:=
getProxyMode
(
string
(
config
.
Mode
),
client
.
Nodes
(),
hostname
,
iptInterface
,
iptables
.
LinuxKernelCompatTester
{})
if
proxyMode
==
proxyModeI
pt
ables
{
if
proxyMode
==
proxyModeI
PT
ables
{
glog
.
V
(
0
)
.
Info
(
"Using iptables Proxier."
)
if
config
.
IPTablesMasqueradeBit
==
nil
{
// IPTablesMasqueradeBit must be specified or defaulted.
return
nil
,
fmt
.
Errorf
(
"Unable to read IPTablesMasqueradeBit from config"
)
}
proxierI
pt
ables
,
err
:=
iptables
.
NewProxier
(
iptInterface
,
utilsysctl
.
New
(),
execer
,
config
.
IPTablesSyncPeriod
.
Duration
,
config
.
MasqueradeAll
,
int
(
*
config
.
IPTablesMasqueradeBit
),
config
.
ClusterCIDR
,
hostname
,
getNodeIP
(
client
,
hostname
))
proxierI
PT
ables
,
err
:=
iptables
.
NewProxier
(
iptInterface
,
utilsysctl
.
New
(),
execer
,
config
.
IPTablesSyncPeriod
.
Duration
,
config
.
MasqueradeAll
,
int
(
*
config
.
IPTablesMasqueradeBit
),
config
.
ClusterCIDR
,
hostname
,
getNodeIP
(
client
,
hostname
))
if
err
!=
nil
{
glog
.
Fatalf
(
"Unable to create proxier: %v"
,
err
)
}
proxier
=
proxierI
pt
ables
endpointsHandler
=
proxierI
pt
ables
proxier
=
proxierI
PT
ables
endpointsHandler
=
proxierI
PT
ables
// No turning back. Remove artifacts that might still exist from the userspace Proxier.
glog
.
V
(
0
)
.
Info
(
"Tearing down userspace rules."
)
userspace
.
CleanupLeftovers
(
iptInterface
)
...
...
@@ -350,28 +350,28 @@ type nodeGetter interface {
Get
(
hostname
string
)
(
*
api
.
Node
,
error
)
}
func
getProxyMode
(
proxyMode
string
,
client
nodeGetter
,
hostname
string
,
iptver
iptables
.
I
pt
ablesVersioner
,
kcompat
iptables
.
KernelCompatTester
)
string
{
func
getProxyMode
(
proxyMode
string
,
client
nodeGetter
,
hostname
string
,
iptver
iptables
.
I
PT
ablesVersioner
,
kcompat
iptables
.
KernelCompatTester
)
string
{
if
proxyMode
==
proxyModeUserspace
{
return
proxyModeUserspace
}
else
if
proxyMode
==
proxyModeI
pt
ables
{
return
tryI
pt
ablesProxy
(
iptver
,
kcompat
)
}
else
if
proxyMode
==
proxyModeI
PT
ables
{
return
tryI
PT
ablesProxy
(
iptver
,
kcompat
)
}
else
if
proxyMode
!=
""
{
glog
.
Warningf
(
"Flag proxy-mode=%q unknown, assuming iptables proxy"
,
proxyMode
)
return
tryI
pt
ablesProxy
(
iptver
,
kcompat
)
return
tryI
PT
ablesProxy
(
iptver
,
kcompat
)
}
// proxyMode == "" - choose the best option.
if
client
==
nil
{
glog
.
Errorf
(
"nodeGetter is nil: assuming iptables proxy"
)
return
tryI
pt
ablesProxy
(
iptver
,
kcompat
)
return
tryI
PT
ablesProxy
(
iptver
,
kcompat
)
}
node
,
err
:=
client
.
Get
(
hostname
)
if
err
!=
nil
{
glog
.
Errorf
(
"Can't get Node %q, assuming iptables proxy, err: %v"
,
hostname
,
err
)
return
tryI
pt
ablesProxy
(
iptver
,
kcompat
)
return
tryI
PT
ablesProxy
(
iptver
,
kcompat
)
}
if
node
==
nil
{
glog
.
Errorf
(
"Got nil Node %q, assuming iptables proxy"
,
hostname
)
return
tryI
pt
ablesProxy
(
iptver
,
kcompat
)
return
tryI
PT
ablesProxy
(
iptver
,
kcompat
)
}
proxyMode
,
found
:=
node
.
Annotations
[
betaProxyModeAnnotation
]
if
found
{
...
...
@@ -387,19 +387,19 @@ func getProxyMode(proxyMode string, client nodeGetter, hostname string, iptver i
glog
.
V
(
1
)
.
Infof
(
"Annotation demands userspace proxy"
)
return
proxyModeUserspace
}
return
tryI
pt
ablesProxy
(
iptver
,
kcompat
)
return
tryI
PT
ablesProxy
(
iptver
,
kcompat
)
}
func
tryI
ptablesProxy
(
iptver
iptables
.
Ipt
ablesVersioner
,
kcompat
iptables
.
KernelCompatTester
)
string
{
func
tryI
PTablesProxy
(
iptver
iptables
.
IPT
ablesVersioner
,
kcompat
iptables
.
KernelCompatTester
)
string
{
var
err
error
// guaranteed false on error, error only necessary for debugging
useI
ptablesProxy
,
err
:=
iptables
.
CanUseIpt
ablesProxier
(
iptver
,
kcompat
)
useI
PTablesProxy
,
err
:=
iptables
.
CanUseIPT
ablesProxier
(
iptver
,
kcompat
)
if
err
!=
nil
{
glog
.
Errorf
(
"Can't determine whether to use iptables proxy, using userspace proxier: %v"
,
err
)
return
proxyModeUserspace
}
if
useI
pt
ablesProxy
{
return
proxyModeI
pt
ables
if
useI
PT
ablesProxy
{
return
proxyModeI
PT
ables
}
// Fallback.
glog
.
V
(
1
)
.
Infof
(
"Can't use iptables proxy, using userspace proxier: %v"
,
err
)
...
...
cmd/kube-proxy/app/server_test.go
View file @
f785f3d3
...
...
@@ -38,12 +38,12 @@ func (fake *fakeNodeInterface) Get(hostname string) (*api.Node, error) {
return
&
fake
.
node
,
nil
}
type
fakeI
pt
ablesVersioner
struct
{
type
fakeI
PT
ablesVersioner
struct
{
version
string
// what to return
err
error
// what to return
}
func
(
fake
*
fakeI
pt
ablesVersioner
)
GetVersion
()
(
string
,
error
)
{
func
(
fake
*
fakeI
PT
ablesVersioner
)
GetVersion
()
(
string
,
error
)
{
return
fake
.
version
,
fake
.
err
}
...
...
@@ -95,7 +95,7 @@ func Test_getProxyMode(t *testing.T) {
flag
:
"iptables"
,
iptablesVersion
:
iptables
.
MinCheckVersion
,
kernelCompat
:
true
,
expected
:
proxyModeI
pt
ables
,
expected
:
proxyModeI
PT
ables
,
},
{
// detect, error
flag
:
""
,
...
...
@@ -117,7 +117,7 @@ func Test_getProxyMode(t *testing.T) {
flag
:
""
,
iptablesVersion
:
iptables
.
MinCheckVersion
,
kernelCompat
:
true
,
expected
:
proxyModeI
pt
ables
,
expected
:
proxyModeI
PT
ables
,
},
{
// annotation says userspace
flag
:
""
,
...
...
@@ -153,7 +153,7 @@ func Test_getProxyMode(t *testing.T) {
annotationVal
:
"iptables"
,
iptablesVersion
:
iptables
.
MinCheckVersion
,
kernelCompat
:
true
,
expected
:
proxyModeI
pt
ables
,
expected
:
proxyModeI
PT
ables
,
},
{
// annotation says something else, version ok
flag
:
""
,
...
...
@@ -161,7 +161,7 @@ func Test_getProxyMode(t *testing.T) {
annotationVal
:
"other"
,
iptablesVersion
:
iptables
.
MinCheckVersion
,
kernelCompat
:
true
,
expected
:
proxyModeI
pt
ables
,
expected
:
proxyModeI
PT
ables
,
},
{
// annotation says nothing, version ok
flag
:
""
,
...
...
@@ -169,7 +169,7 @@ func Test_getProxyMode(t *testing.T) {
annotationVal
:
""
,
iptablesVersion
:
iptables
.
MinCheckVersion
,
kernelCompat
:
true
,
expected
:
proxyModeI
pt
ables
,
expected
:
proxyModeI
PT
ables
,
},
{
// annotation says userspace
flag
:
""
,
...
...
@@ -205,7 +205,7 @@ func Test_getProxyMode(t *testing.T) {
annotationVal
:
"iptables"
,
iptablesVersion
:
iptables
.
MinCheckVersion
,
kernelCompat
:
true
,
expected
:
proxyModeI
pt
ables
,
expected
:
proxyModeI
PT
ables
,
},
{
// annotation says something else, version ok
flag
:
""
,
...
...
@@ -213,7 +213,7 @@ func Test_getProxyMode(t *testing.T) {
annotationVal
:
"other"
,
iptablesVersion
:
iptables
.
MinCheckVersion
,
kernelCompat
:
true
,
expected
:
proxyModeI
pt
ables
,
expected
:
proxyModeI
PT
ables
,
},
{
// annotation says nothing, version ok
flag
:
""
,
...
...
@@ -221,7 +221,7 @@ func Test_getProxyMode(t *testing.T) {
annotationVal
:
""
,
iptablesVersion
:
iptables
.
MinCheckVersion
,
kernelCompat
:
true
,
expected
:
proxyModeI
pt
ables
,
expected
:
proxyModeI
PT
ables
,
},
{
// flag says userspace, annotation disagrees
flag
:
"userspace"
,
...
...
@@ -236,7 +236,7 @@ func Test_getProxyMode(t *testing.T) {
annotationVal
:
"userspace"
,
iptablesVersion
:
iptables
.
MinCheckVersion
,
kernelCompat
:
true
,
expected
:
proxyModeI
pt
ables
,
expected
:
proxyModeI
PT
ables
,
},
{
// flag says userspace, annotation disagrees
flag
:
"userspace"
,
...
...
@@ -251,13 +251,13 @@ func Test_getProxyMode(t *testing.T) {
annotationVal
:
"userspace"
,
iptablesVersion
:
iptables
.
MinCheckVersion
,
kernelCompat
:
true
,
expected
:
proxyModeI
pt
ables
,
expected
:
proxyModeI
PT
ables
,
},
}
for
i
,
c
:=
range
cases
{
getter
:=
&
fakeNodeInterface
{}
getter
.
node
.
Annotations
=
map
[
string
]
string
{
c
.
annotationKey
:
c
.
annotationVal
}
versioner
:=
&
fakeI
pt
ablesVersioner
{
c
.
iptablesVersion
,
c
.
iptablesError
}
versioner
:=
&
fakeI
PT
ablesVersioner
{
c
.
iptablesVersion
,
c
.
iptablesError
}
kcompater
:=
&
fakeKernelCompatTester
{
c
.
kernelCompat
}
r
:=
getProxyMode
(
c
.
flag
,
getter
,
"host"
,
versioner
,
kcompater
)
if
r
!=
c
.
expected
{
...
...
pkg/kubelet/eviction/eviction_manager.go
View file @
f785f3d3
...
...
@@ -98,12 +98,8 @@ func (m *managerImpl) Admit(attrs *lifecycle.PodAdmitAttributes) lifecycle.PodAd
return
lifecycle
.
PodAdmitResult
{
Admit
:
true
}
}
// Check the node conditions to identify the resource under pressure.
// The resource can only be either disk or memory; set the default to disk.
resource
:=
api
.
ResourceStorage
// the node has memory pressure, admit if not best-effort
if
hasNodeCondition
(
m
.
nodeConditions
,
api
.
NodeMemoryPressure
)
{
resource
=
api
.
ResourceMemory
// the node has memory pressure, admit if not best-effort
notBestEffort
:=
qos
.
BestEffort
!=
qos
.
GetPodQOS
(
attrs
.
Pod
)
if
notBestEffort
{
return
lifecycle
.
PodAdmitResult
{
Admit
:
true
}
...
...
@@ -111,11 +107,11 @@ func (m *managerImpl) Admit(attrs *lifecycle.PodAdmitAttributes) lifecycle.PodAd
}
// reject pods when under memory pressure (if pod is best effort), or if under disk pressure.
glog
.
Warningf
(
"Failed to admit pod %
q - node has conditions: %v"
,
format
.
Pod
(
attrs
.
Pod
)
,
m
.
nodeConditions
)
glog
.
Warningf
(
"Failed to admit pod %
v - %s"
,
format
.
Pod
(
attrs
.
Pod
),
"node has conditions: %v"
,
m
.
nodeConditions
)
return
lifecycle
.
PodAdmitResult
{
Admit
:
false
,
Reason
:
reason
,
Message
:
getMessage
(
resource
)
,
Message
:
message
,
}
}
...
...
@@ -248,7 +244,6 @@ func (m *managerImpl) synchronize(diskInfoProvider DiskInfoProvider, podFunc Act
glog
.
Infof
(
"eviction manager: pods ranked for eviction: %s"
,
format
.
Pods
(
activePods
))
// we kill at most a single pod during each eviction interval
message
:=
getMessage
(
resourceToReclaim
)
for
i
:=
range
activePods
{
pod
:=
activePods
[
i
]
status
:=
api
.
PodStatus
{
...
...
pkg/kubelet/eviction/helpers.go
View file @
f785f3d3
...
...
@@ -37,8 +37,8 @@ const (
unsupportedEvictionSignal
=
"unsupported eviction signal %v"
// the reason reported back in status.
reason
=
"Evicted"
// the message
format
associated with the reason.
message
Fmt
=
"The node was low on %
s."
// the message associated with the reason.
message
=
"The node was low on compute resource
s."
// disk, in bytes. internal to this module, used to account for local disk usage.
resourceDisk
api
.
ResourceName
=
"disk"
// inodes, number. internal to this module, used to account for local disk inode consumption.
...
...
@@ -894,7 +894,3 @@ func deleteImages(imageGC ImageGC, reportBytesFreed bool) nodeReclaimFunc {
return
resource
.
NewQuantity
(
reclaimed
,
resource
.
BinarySI
),
nil
}
}
func
getMessage
(
resource
api
.
ResourceName
)
string
{
return
fmt
.
Sprintf
(
messageFmt
,
resource
)
}
pkg/kubelet/network/hostport/fake_iptables.go
View file @
f785f3d3
...
...
@@ -35,21 +35,21 @@ type fakeTable struct {
chains
map
[
string
]
*
fakeChain
}
type
fakeI
pt
ables
struct
{
type
fakeI
PT
ables
struct
{
tables
map
[
string
]
*
fakeTable
}
func
NewFakeI
ptables
()
*
fakeIpt
ables
{
return
&
fakeI
pt
ables
{
func
NewFakeI
PTables
()
*
fakeIPT
ables
{
return
&
fakeI
PT
ables
{
tables
:
make
(
map
[
string
]
*
fakeTable
,
0
),
}
}
func
(
f
*
fakeI
pt
ables
)
GetVersion
()
(
string
,
error
)
{
func
(
f
*
fakeI
PT
ables
)
GetVersion
()
(
string
,
error
)
{
return
"1.4.21"
,
nil
}
func
(
f
*
fakeI
pt
ables
)
getTable
(
tableName
utiliptables
.
Table
)
(
*
fakeTable
,
error
)
{
func
(
f
*
fakeI
PT
ables
)
getTable
(
tableName
utiliptables
.
Table
)
(
*
fakeTable
,
error
)
{
table
,
ok
:=
f
.
tables
[
string
(
tableName
)]
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"Table %s does not exist"
,
tableName
)
...
...
@@ -57,7 +57,7 @@ func (f *fakeIptables) getTable(tableName utiliptables.Table) (*fakeTable, error
return
table
,
nil
}
func
(
f
*
fakeI
pt
ables
)
getChain
(
tableName
utiliptables
.
Table
,
chainName
utiliptables
.
Chain
)
(
*
fakeTable
,
*
fakeChain
,
error
)
{
func
(
f
*
fakeI
PT
ables
)
getChain
(
tableName
utiliptables
.
Table
,
chainName
utiliptables
.
Chain
)
(
*
fakeTable
,
*
fakeChain
,
error
)
{
table
,
err
:=
f
.
getTable
(
tableName
)
if
err
!=
nil
{
return
nil
,
nil
,
err
...
...
@@ -71,7 +71,7 @@ func (f *fakeIptables) getChain(tableName utiliptables.Table, chainName utilipta
return
table
,
chain
,
nil
}
func
(
f
*
fakeI
pt
ables
)
ensureChain
(
tableName
utiliptables
.
Table
,
chainName
utiliptables
.
Chain
)
(
bool
,
*
fakeChain
)
{
func
(
f
*
fakeI
PT
ables
)
ensureChain
(
tableName
utiliptables
.
Table
,
chainName
utiliptables
.
Chain
)
(
bool
,
*
fakeChain
)
{
table
,
chain
,
err
:=
f
.
getChain
(
tableName
,
chainName
)
if
err
!=
nil
{
// either table or table+chain don't exist yet
...
...
@@ -92,12 +92,12 @@ func (f *fakeIptables) ensureChain(tableName utiliptables.Table, chainName utili
return
true
,
chain
}
func
(
f
*
fakeI
pt
ables
)
EnsureChain
(
tableName
utiliptables
.
Table
,
chainName
utiliptables
.
Chain
)
(
bool
,
error
)
{
func
(
f
*
fakeI
PT
ables
)
EnsureChain
(
tableName
utiliptables
.
Table
,
chainName
utiliptables
.
Chain
)
(
bool
,
error
)
{
existed
,
_
:=
f
.
ensureChain
(
tableName
,
chainName
)
return
existed
,
nil
}
func
(
f
*
fakeI
pt
ables
)
FlushChain
(
tableName
utiliptables
.
Table
,
chainName
utiliptables
.
Chain
)
error
{
func
(
f
*
fakeI
PT
ables
)
FlushChain
(
tableName
utiliptables
.
Table
,
chainName
utiliptables
.
Chain
)
error
{
_
,
chain
,
err
:=
f
.
getChain
(
tableName
,
chainName
)
if
err
!=
nil
{
return
err
...
...
@@ -106,7 +106,7 @@ func (f *fakeIptables) FlushChain(tableName utiliptables.Table, chainName utilip
return
nil
}
func
(
f
*
fakeI
pt
ables
)
DeleteChain
(
tableName
utiliptables
.
Table
,
chainName
utiliptables
.
Chain
)
error
{
func
(
f
*
fakeI
PT
ables
)
DeleteChain
(
tableName
utiliptables
.
Table
,
chainName
utiliptables
.
Chain
)
error
{
table
,
_
,
err
:=
f
.
getChain
(
tableName
,
chainName
)
if
err
!=
nil
{
return
err
...
...
@@ -125,7 +125,7 @@ func findRule(chain *fakeChain, rule string) int {
return
-
1
}
func
(
f
*
fakeI
pt
ables
)
ensureRule
(
position
utiliptables
.
RulePosition
,
tableName
utiliptables
.
Table
,
chainName
utiliptables
.
Chain
,
rule
string
)
(
bool
,
error
)
{
func
(
f
*
fakeI
PT
ables
)
ensureRule
(
position
utiliptables
.
RulePosition
,
tableName
utiliptables
.
Table
,
chainName
utiliptables
.
Chain
,
rule
string
)
(
bool
,
error
)
{
_
,
chain
,
err
:=
f
.
getChain
(
tableName
,
chainName
)
if
err
!=
nil
{
_
,
chain
=
f
.
ensureChain
(
tableName
,
chainName
)
...
...
@@ -192,7 +192,7 @@ func normalizeRule(rule string) (string, error) {
return
normalized
,
nil
}
func
(
f
*
fakeI
pt
ables
)
EnsureRule
(
position
utiliptables
.
RulePosition
,
tableName
utiliptables
.
Table
,
chainName
utiliptables
.
Chain
,
args
...
string
)
(
bool
,
error
)
{
func
(
f
*
fakeI
PT
ables
)
EnsureRule
(
position
utiliptables
.
RulePosition
,
tableName
utiliptables
.
Table
,
chainName
utiliptables
.
Chain
,
args
...
string
)
(
bool
,
error
)
{
ruleArgs
:=
make
([]
string
,
0
)
for
_
,
arg
:=
range
args
{
// quote args with internal spaces (like comments)
...
...
@@ -204,7 +204,7 @@ func (f *fakeIptables) EnsureRule(position utiliptables.RulePosition, tableName
return
f
.
ensureRule
(
position
,
tableName
,
chainName
,
strings
.
Join
(
ruleArgs
,
" "
))
}
func
(
f
*
fakeI
pt
ables
)
DeleteRule
(
tableName
utiliptables
.
Table
,
chainName
utiliptables
.
Chain
,
args
...
string
)
error
{
func
(
f
*
fakeI
PT
ables
)
DeleteRule
(
tableName
utiliptables
.
Table
,
chainName
utiliptables
.
Chain
,
args
...
string
)
error
{
_
,
chain
,
err
:=
f
.
getChain
(
tableName
,
chainName
)
if
err
==
nil
{
rule
:=
strings
.
Join
(
args
,
" "
)
...
...
@@ -217,7 +217,7 @@ func (f *fakeIptables) DeleteRule(tableName utiliptables.Table, chainName utilip
return
nil
}
func
(
f
*
fakeI
pt
ables
)
IsIpv6
()
bool
{
func
(
f
*
fakeI
PT
ables
)
IsIpv6
()
bool
{
return
false
}
...
...
@@ -227,7 +227,7 @@ func saveChain(chain *fakeChain, data *bytes.Buffer) {
}
}
func
(
f
*
fakeI
pt
ables
)
Save
(
tableName
utiliptables
.
Table
)
([]
byte
,
error
)
{
func
(
f
*
fakeI
PT
ables
)
Save
(
tableName
utiliptables
.
Table
)
([]
byte
,
error
)
{
table
,
err
:=
f
.
getTable
(
tableName
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -246,7 +246,7 @@ func (f *fakeIptables) Save(tableName utiliptables.Table) ([]byte, error) {
return
data
.
Bytes
(),
nil
}
func
(
f
*
fakeI
pt
ables
)
SaveAll
()
([]
byte
,
error
)
{
func
(
f
*
fakeI
PT
ables
)
SaveAll
()
([]
byte
,
error
)
{
data
:=
bytes
.
NewBuffer
(
nil
)
for
_
,
table
:=
range
f
.
tables
{
tableData
,
err
:=
f
.
Save
(
table
.
name
)
...
...
@@ -260,7 +260,7 @@ func (f *fakeIptables) SaveAll() ([]byte, error) {
return
data
.
Bytes
(),
nil
}
func
(
f
*
fakeI
pt
ables
)
restore
(
restoreTableName
utiliptables
.
Table
,
data
[]
byte
,
flush
utiliptables
.
FlushFlag
)
error
{
func
(
f
*
fakeI
PT
ables
)
restore
(
restoreTableName
utiliptables
.
Table
,
data
[]
byte
,
flush
utiliptables
.
FlushFlag
)
error
{
buf
:=
bytes
.
NewBuffer
(
data
)
var
tableName
utiliptables
.
Table
for
{
...
...
@@ -320,16 +320,16 @@ func (f *fakeIptables) restore(restoreTableName utiliptables.Table, data []byte,
return
nil
}
func
(
f
*
fakeI
pt
ables
)
Restore
(
tableName
utiliptables
.
Table
,
data
[]
byte
,
flush
utiliptables
.
FlushFlag
,
counters
utiliptables
.
RestoreCountersFlag
)
error
{
func
(
f
*
fakeI
PT
ables
)
Restore
(
tableName
utiliptables
.
Table
,
data
[]
byte
,
flush
utiliptables
.
FlushFlag
,
counters
utiliptables
.
RestoreCountersFlag
)
error
{
return
f
.
restore
(
tableName
,
data
,
flush
)
}
func
(
f
*
fakeI
pt
ables
)
RestoreAll
(
data
[]
byte
,
flush
utiliptables
.
FlushFlag
,
counters
utiliptables
.
RestoreCountersFlag
)
error
{
func
(
f
*
fakeI
PT
ables
)
RestoreAll
(
data
[]
byte
,
flush
utiliptables
.
FlushFlag
,
counters
utiliptables
.
RestoreCountersFlag
)
error
{
return
f
.
restore
(
""
,
data
,
flush
)
}
func
(
f
*
fakeI
pt
ables
)
AddReloadFunc
(
reloadFunc
func
())
{
func
(
f
*
fakeI
PT
ables
)
AddReloadFunc
(
reloadFunc
func
())
{
}
func
(
f
*
fakeI
pt
ables
)
Destroy
()
{
func
(
f
*
fakeI
PT
ables
)
Destroy
()
{
}
pkg/kubelet/network/hostport/hostport.go
View file @
f785f3d3
...
...
@@ -162,7 +162,7 @@ func writeLine(buf *bytes.Buffer, words ...string) {
//hostportChainName takes containerPort for a pod and returns associated iptables chain.
// This is computed by hashing (sha256)
// then encoding to base32 and truncating with the prefix "KUBE-SVC-". We do
// this because I
pt
ables Chain Names must be <= 28 chars long, and the longer
// this because I
PT
ables Chain Names must be <= 28 chars long, and the longer
// they are the harder they are to read.
func
hostportChainName
(
cp
api
.
ContainerPort
,
podFullName
string
)
utiliptables
.
Chain
{
hash
:=
sha256
.
Sum256
([]
byte
(
string
(
cp
.
HostPort
)
+
string
(
cp
.
Protocol
)
+
podFullName
))
...
...
@@ -293,7 +293,7 @@ func (h *handler) SyncHostports(natInterfaceName string, runningPods []*RunningP
writeLine
(
natRules
,
args
...
)
// Create hostport chain to DNAT traffic to final destination
// I
pt
ables will maintained the stats for this chain
// I
PT
ables will maintained the stats for this chain
args
=
[]
string
{
"-A"
,
string
(
hostportChain
),
"-m"
,
"comment"
,
"--comment"
,
fmt
.
Sprintf
(
`"%s hostport %d"`
,
target
.
podFullName
,
containerPort
.
HostPort
),
...
...
pkg/kubelet/network/hostport/hostport_test.go
View file @
f785f3d3
...
...
@@ -52,11 +52,11 @@ type ruleMatch struct {
}
func
TestOpenPodHostports
(
t
*
testing
.
T
)
{
fakeI
ptables
:=
NewFakeIpt
ables
()
fakeI
PTables
:=
NewFakeIPT
ables
()
h
:=
&
handler
{
hostPortMap
:
make
(
map
[
hostport
]
closeable
),
iptables
:
fakeI
pt
ables
,
iptables
:
fakeI
PT
ables
,
portOpener
:
openFakeSocket
,
}
...
...
@@ -198,7 +198,7 @@ func TestOpenPodHostports(t *testing.T) {
}
for
_
,
rule
:=
range
genericRules
{
_
,
chain
,
err
:=
fakeI
pt
ables
.
getChain
(
utiliptables
.
TableNAT
,
utiliptables
.
Chain
(
rule
.
chain
))
_
,
chain
,
err
:=
fakeI
PT
ables
.
getChain
(
utiliptables
.
TableNAT
,
utiliptables
.
Chain
(
rule
.
chain
))
if
err
!=
nil
{
t
.
Fatalf
(
"Expected NAT chain %s did not exist"
,
rule
.
chain
)
}
...
...
@@ -211,7 +211,7 @@ func TestOpenPodHostports(t *testing.T) {
for
_
,
test
:=
range
tests
{
for
_
,
match
:=
range
test
.
matches
{
// Ensure chain exists
_
,
chain
,
err
:=
fakeI
pt
ables
.
getChain
(
utiliptables
.
TableNAT
,
utiliptables
.
Chain
(
match
.
chain
))
_
,
chain
,
err
:=
fakeI
PT
ables
.
getChain
(
utiliptables
.
TableNAT
,
utiliptables
.
Chain
(
match
.
chain
))
if
err
!=
nil
{
t
.
Fatalf
(
"Expected NAT chain %s did not exist"
,
match
.
chain
)
}
...
...
pkg/kubelet/network/kubenet/kubenet_linux.go
View file @
f785f3d3
...
...
@@ -54,7 +54,7 @@ const (
BridgeName
=
"cbr0"
DefaultCNIDir
=
"/opt/cni/bin"
sysctlBridgeCallI
pt
ables
=
"net/bridge/bridge-nf-call-iptables"
sysctlBridgeCallI
PT
ables
=
"net/bridge/bridge-nf-call-iptables"
// fallbackMTU is used if an MTU is not specified, and we cannot determine the MTU
fallbackMTU
=
1460
...
...
@@ -139,9 +139,9 @@ func (plugin *kubenetNetworkPlugin) Init(host network.Host, hairpinMode componen
// was built-in, we simply ignore the error here. A better thing to do is
// to check the kernel version in the future.
plugin
.
execer
.
Command
(
"modprobe"
,
"br-netfilter"
)
.
CombinedOutput
()
err
:=
plugin
.
sysctl
.
SetSysctl
(
sysctlBridgeCallI
pt
ables
,
1
)
err
:=
plugin
.
sysctl
.
SetSysctl
(
sysctlBridgeCallI
PT
ables
,
1
)
if
err
!=
nil
{
glog
.
Warningf
(
"can't set sysctl %s: %v"
,
sysctlBridgeCallI
pt
ables
,
err
)
glog
.
Warningf
(
"can't set sysctl %s: %v"
,
sysctlBridgeCallI
PT
ables
,
err
)
}
plugin
.
loConfig
,
err
=
libcni
.
ConfFromBytes
([]
byte
(
`{
...
...
pkg/kubelet/network/plugins.go
View file @
f785f3d3
...
...
@@ -154,7 +154,7 @@ func UnescapePluginName(in string) string {
type
NoopNetworkPlugin
struct
{
}
const
sysctlBridgeCallI
pt
ables
=
"net/bridge/bridge-nf-call-iptables"
const
sysctlBridgeCallI
PT
ables
=
"net/bridge/bridge-nf-call-iptables"
func
(
plugin
*
NoopNetworkPlugin
)
Init
(
host
Host
,
hairpinMode
componentconfig
.
HairpinMode
,
nonMasqueradeCIDR
string
,
mtu
int
)
error
{
// Set bridge-nf-call-iptables=1 to maintain compatibility with older
...
...
@@ -166,8 +166,8 @@ func (plugin *NoopNetworkPlugin) Init(host Host, hairpinMode componentconfig.Hai
// Ensure the netfilter module is loaded on kernel >= 3.18; previously
// it was built-in.
utilexec
.
New
()
.
Command
(
"modprobe"
,
"br-netfilter"
)
.
CombinedOutput
()
if
err
:=
utilsysctl
.
New
()
.
SetSysctl
(
sysctlBridgeCallI
pt
ables
,
1
);
err
!=
nil
{
glog
.
Warningf
(
"can't set sysctl %s: %v"
,
sysctlBridgeCallI
pt
ables
,
err
)
if
err
:=
utilsysctl
.
New
()
.
SetSysctl
(
sysctlBridgeCallI
PT
ables
,
1
);
err
!=
nil
{
glog
.
Warningf
(
"can't set sysctl %s: %v"
,
sysctlBridgeCallI
PT
ables
,
err
)
}
return
nil
...
...
pkg/proxy/iptables/proxier.go
View file @
f785f3d3
...
...
@@ -74,8 +74,8 @@ const (
KubeMarkDropChain
utiliptables
.
Chain
=
"KUBE-MARK-DROP"
)
// I
pt
ablesVersioner can query the current iptables version.
type
I
pt
ablesVersioner
interface
{
// I
PT
ablesVersioner can query the current iptables version.
type
I
PT
ablesVersioner
interface
{
// returns "X.Y.Z"
GetVersion
()
(
string
,
error
)
}
...
...
@@ -86,12 +86,12 @@ type KernelCompatTester interface {
IsCompatible
()
error
}
// CanUseI
pt
ablesProxier returns true if we should use the iptables Proxier
// CanUseI
PT
ablesProxier returns true if we should use the iptables Proxier
// instead of the "classic" userspace Proxier. This is determined by checking
// the iptables version and for the existence of kernel features. It may return
// an error if it fails to get the iptables version without error, in which
// case it will also return false.
func
CanUseI
ptablesProxier
(
iptver
Ipt
ablesVersioner
,
kcompat
KernelCompatTester
)
(
bool
,
error
)
{
func
CanUseI
PTablesProxier
(
iptver
IPT
ablesVersioner
,
kcompat
KernelCompatTester
)
(
bool
,
error
)
{
minVersion
,
err
:=
semver
.
NewVersion
(
iptablesMinVersion
)
if
err
!=
nil
{
return
false
,
err
...
...
@@ -127,7 +127,7 @@ func (lkct LinuxKernelCompatTester) IsCompatible() error {
}
const
sysctlRouteLocalnet
=
"net/ipv4/conf/all/route_localnet"
const
sysctlBridgeCallI
pt
ables
=
"net/bridge/bridge-nf-call-iptables"
const
sysctlBridgeCallI
PT
ables
=
"net/bridge/bridge-nf-call-iptables"
// internal struct for string service information
type
serviceInfo
struct
{
...
...
@@ -211,7 +211,7 @@ func NewProxier(ipt utiliptables.Interface, sysctl utilsysctl.Interface, exec ut
// Proxy needs br_netfilter and bridge-nf-call-iptables=1 when containers
// are connected to a Linux bridge (but not SDN bridges). Until most
// plugins handle this, log when config is missing
if
val
,
err
:=
sysctl
.
GetSysctl
(
sysctlBridgeCallI
pt
ables
);
err
==
nil
&&
val
!=
1
{
if
val
,
err
:=
sysctl
.
GetSysctl
(
sysctlBridgeCallI
PT
ables
);
err
==
nil
&&
val
!=
1
{
glog
.
Infof
(
"missing br-netfilter module or unset sysctl br-nf-call-iptables; proxy may not work as intended"
)
}
...
...
@@ -639,7 +639,7 @@ func flattenValidEndpoints(endpoints []hostPortInfo) []string {
// portProtoHash takes the ServicePortName and protocol for a service
// returns the associated 16 character hash. This is computed by hashing (sha256)
// then encoding to base32 and truncating to 16 chars. We do this because I
pt
ables
// then encoding to base32 and truncating to 16 chars. We do this because I
PT
ables
// Chain Names must be <= 28 chars long, and the longer they are the harder they are to read.
func
portProtoHash
(
s
proxy
.
ServicePortName
,
protocol
string
)
string
{
hash
:=
sha256
.
Sum256
([]
byte
(
s
.
String
()
+
protocol
))
...
...
@@ -664,7 +664,7 @@ func serviceFirewallChainName(s proxy.ServicePortName, protocol string) utilipta
// serviceLBPortChainName takes the ServicePortName for a service and
// returns the associated iptables chain. This is computed by hashing (sha256)
// then encoding to base32 and truncating with the prefix "KUBE-XLB-". We do
// this because I
pt
ables Chain Names must be <= 28 chars long, and the longer
// this because I
PT
ables Chain Names must be <= 28 chars long, and the longer
// they are the harder they are to read.
func
serviceLBChainName
(
s
proxy
.
ServicePortName
,
protocol
string
)
utiliptables
.
Chain
{
return
utiliptables
.
Chain
(
"KUBE-XLB-"
+
portProtoHash
(
s
,
protocol
))
...
...
pkg/util/iptables/iptables.go
View file @
f785f3d3
...
...
@@ -97,9 +97,9 @@ const (
)
const
(
cmdI
pt
ablesSave
string
=
"iptables-save"
cmdI
pt
ablesRestore
string
=
"iptables-restore"
cmdI
pt
ables
string
=
"iptables"
cmdI
PT
ablesSave
string
=
"iptables-save"
cmdI
PT
ablesRestore
string
=
"iptables-restore"
cmdI
PT
ables
string
=
"iptables"
cmdIp6tables
string
=
"ip6tables"
)
...
...
@@ -138,7 +138,7 @@ type runner struct {
// New returns a new Interface which will exec iptables.
func
New
(
exec
utilexec
.
Interface
,
dbus
utildbus
.
Interface
,
protocol
Protocol
)
Interface
{
vstring
,
err
:=
getI
pt
ablesVersionString
(
exec
)
vstring
,
err
:=
getI
PT
ablesVersionString
(
exec
)
if
err
!=
nil
{
glog
.
Warningf
(
"Error checking iptables version, assuming version at least %s: %v"
,
MinCheckVersion
,
err
)
vstring
=
MinCheckVersion
...
...
@@ -147,8 +147,8 @@ func New(exec utilexec.Interface, dbus utildbus.Interface, protocol Protocol) In
exec
:
exec
,
dbus
:
dbus
,
protocol
:
protocol
,
hasCheck
:
getI
pt
ablesHasCheckCommand
(
vstring
),
waitFlag
:
getI
pt
ablesWaitFlag
(
vstring
),
hasCheck
:
getI
PT
ablesHasCheckCommand
(
vstring
),
waitFlag
:
getI
PT
ablesWaitFlag
(
vstring
),
}
runner
.
connectToFirewallD
()
return
runner
...
...
@@ -191,7 +191,7 @@ func (runner *runner) connectToFirewallD() {
// GetVersion returns the version string.
func
(
runner
*
runner
)
GetVersion
()
(
string
,
error
)
{
return
getI
pt
ablesVersionString
(
runner
.
exec
)
return
getI
PT
ablesVersionString
(
runner
.
exec
)
}
// EnsureChain is part of Interface.
...
...
@@ -296,7 +296,7 @@ func (runner *runner) Save(table Table) ([]byte, error) {
// run and return
args
:=
[]
string
{
"-t"
,
string
(
table
)}
glog
.
V
(
4
)
.
Infof
(
"running iptables-save %v"
,
args
)
return
runner
.
exec
.
Command
(
cmdI
pt
ablesSave
,
args
...
)
.
CombinedOutput
()
return
runner
.
exec
.
Command
(
cmdI
PT
ablesSave
,
args
...
)
.
CombinedOutput
()
}
// SaveAll is part of Interface.
...
...
@@ -306,7 +306,7 @@ func (runner *runner) SaveAll() ([]byte, error) {
// run and return
glog
.
V
(
4
)
.
Infof
(
"running iptables-save"
)
return
runner
.
exec
.
Command
(
cmdI
pt
ablesSave
,
[]
string
{}
...
)
.
CombinedOutput
()
return
runner
.
exec
.
Command
(
cmdI
PT
ablesSave
,
[]
string
{}
...
)
.
CombinedOutput
()
}
// Restore is part of Interface.
...
...
@@ -337,7 +337,7 @@ func (runner *runner) restoreInternal(args []string, data []byte, flush FlushFla
// run the command and return the output or an error including the output and error
glog
.
V
(
4
)
.
Infof
(
"running iptables-restore %v"
,
args
)
cmd
:=
runner
.
exec
.
Command
(
cmdI
pt
ablesRestore
,
args
...
)
cmd
:=
runner
.
exec
.
Command
(
cmdI
PT
ablesRestore
,
args
...
)
cmd
.
SetStdin
(
bytes
.
NewBuffer
(
data
))
b
,
err
:=
cmd
.
CombinedOutput
()
if
err
!=
nil
{
...
...
@@ -350,7 +350,7 @@ func (runner *runner) iptablesCommand() string {
if
runner
.
IsIpv6
()
{
return
cmdIp6tables
}
else
{
return
cmdI
pt
ables
return
cmdI
PT
ables
}
}
...
...
@@ -379,7 +379,7 @@ func (runner *runner) checkRule(table Table, chain Chain, args ...string) (bool,
// of hack and half-measures. We should nix this ASAP.
func
(
runner
*
runner
)
checkRuleWithoutCheck
(
table
Table
,
chain
Chain
,
args
...
string
)
(
bool
,
error
)
{
glog
.
V
(
1
)
.
Infof
(
"running iptables-save -t %s"
,
string
(
table
))
out
,
err
:=
runner
.
exec
.
Command
(
cmdI
pt
ablesSave
,
"-t"
,
string
(
table
))
.
CombinedOutput
()
out
,
err
:=
runner
.
exec
.
Command
(
cmdI
PT
ablesSave
,
"-t"
,
string
(
table
))
.
CombinedOutput
()
if
err
!=
nil
{
return
false
,
fmt
.
Errorf
(
"error checking rule: %v"
,
err
)
}
...
...
@@ -453,7 +453,7 @@ func makeFullArgs(table Table, chain Chain, args ...string) []string {
}
// Checks if iptables has the "-C" flag
func
getI
pt
ablesHasCheckCommand
(
vstring
string
)
bool
{
func
getI
PT
ablesHasCheckCommand
(
vstring
string
)
bool
{
minVersion
,
err
:=
semver
.
NewVersion
(
MinCheckVersion
)
if
err
!=
nil
{
glog
.
Errorf
(
"MinCheckVersion (%s) is not a valid version string: %v"
,
MinCheckVersion
,
err
)
...
...
@@ -471,7 +471,7 @@ func getIptablesHasCheckCommand(vstring string) bool {
}
// Checks if iptables version has a "wait" flag
func
getI
pt
ablesWaitFlag
(
vstring
string
)
[]
string
{
func
getI
PT
ablesWaitFlag
(
vstring
string
)
[]
string
{
version
,
err
:=
semver
.
NewVersion
(
vstring
)
if
err
!=
nil
{
glog
.
Errorf
(
"vstring (%s) is not a valid version string: %v"
,
vstring
,
err
)
...
...
@@ -499,11 +499,11 @@ func getIptablesWaitFlag(vstring string) []string {
}
}
// getI
pt
ablesVersionString runs "iptables --version" to get the version string
// getI
PT
ablesVersionString runs "iptables --version" to get the version string
// in the form "X.X.X"
func
getI
pt
ablesVersionString
(
exec
utilexec
.
Interface
)
(
string
,
error
)
{
func
getI
PT
ablesVersionString
(
exec
utilexec
.
Interface
)
(
string
,
error
)
{
// this doesn't access mutable state so we don't need to use the interface / runner
bytes
,
err
:=
exec
.
Command
(
cmdI
pt
ables
,
"--version"
)
.
CombinedOutput
()
bytes
,
err
:=
exec
.
Command
(
cmdI
PT
ables
,
"--version"
)
.
CombinedOutput
()
if
err
!=
nil
{
return
""
,
err
}
...
...
pkg/util/iptables/iptables_test.go
View file @
f785f3d3
...
...
@@ -26,9 +26,9 @@ import (
"k8s.io/kubernetes/pkg/util/sets"
)
func
getI
pt
ablesCommand
(
protocol
Protocol
)
string
{
func
getI
PT
ablesCommand
(
protocol
Protocol
)
string
{
if
protocol
==
ProtocolIpv4
{
return
cmdI
pt
ables
return
cmdI
PT
ables
}
if
protocol
==
ProtocolIpv6
{
return
cmdIp6tables
...
...
@@ -70,7 +70,7 @@ func testEnsureChain(t *testing.T, protocol Protocol) {
if
fcmd
.
CombinedOutputCalls
!=
2
{
t
.
Errorf
(
"expected 2 CombinedOutput() calls, got %d"
,
fcmd
.
CombinedOutputCalls
)
}
cmd
:=
getI
pt
ablesCommand
(
protocol
)
cmd
:=
getI
PT
ablesCommand
(
protocol
)
if
!
sets
.
NewString
(
fcmd
.
CombinedOutputLog
[
1
]
...
)
.
HasAll
(
cmd
,
"-t"
,
"nat"
,
"-N"
,
"FOOBAR"
)
{
t
.
Errorf
(
"wrong CombinedOutput() log, got %s"
,
fcmd
.
CombinedOutputLog
[
1
])
}
...
...
@@ -427,7 +427,7 @@ func TestDeleteRuleErrorCreating(t *testing.T) {
}
}
func
TestGetI
pt
ablesHasCheckCommand
(
t
*
testing
.
T
)
{
func
TestGetI
PT
ablesHasCheckCommand
(
t
*
testing
.
T
)
{
testCases
:=
[]
struct
{
Version
string
Err
bool
...
...
@@ -451,12 +451,12 @@ func TestGetIptablesHasCheckCommand(t *testing.T) {
func
(
cmd
string
,
args
...
string
)
exec
.
Cmd
{
return
exec
.
InitFakeCmd
(
&
fcmd
,
cmd
,
args
...
)
},
},
}
version
,
err
:=
getI
pt
ablesVersionString
(
&
fexec
)
version
,
err
:=
getI
PT
ablesVersionString
(
&
fexec
)
if
(
err
!=
nil
)
!=
testCase
.
Err
{
t
.
Errorf
(
"Expected error: %v, Got error: %v"
,
testCase
.
Err
,
err
)
}
if
err
==
nil
{
check
:=
getI
pt
ablesHasCheckCommand
(
version
)
check
:=
getI
PT
ablesHasCheckCommand
(
version
)
if
testCase
.
Expected
!=
check
{
t
.
Errorf
(
"Expected result: %v, Got result: %v"
,
testCase
.
Expected
,
check
)
}
...
...
@@ -540,7 +540,7 @@ COMMIT
}
}
func
TestI
pt
ablesWaitFlag
(
t
*
testing
.
T
)
{
func
TestI
PT
ablesWaitFlag
(
t
*
testing
.
T
)
{
testCases
:=
[]
struct
{
Version
string
Result
string
...
...
@@ -556,7 +556,7 @@ func TestIptablesWaitFlag(t *testing.T) {
}
for
_
,
testCase
:=
range
testCases
{
result
:=
getI
pt
ablesWaitFlag
(
testCase
.
Version
)
result
:=
getI
PT
ablesWaitFlag
(
testCase
.
Version
)
if
strings
.
Join
(
result
,
""
)
!=
testCase
.
Result
{
t
.
Errorf
(
"For %s expected %v got %v"
,
testCase
.
Version
,
testCase
.
Result
,
result
)
}
...
...
test/e2e_node/environment/conformance.go
View file @
f785f3d3
...
...
@@ -195,7 +195,7 @@ const iptablesForwardRegexStr = `Chain FORWARD \(policy DROP\)`
func
firewall
()
error
{
out
,
err
:=
exec
.
Command
(
"iptables"
,
"-L"
,
"INPUT"
)
.
CombinedOutput
()
if
err
!=
nil
{
return
printSuccess
(
"Firewall I
pt
ables Check %s: Could not run iptables"
,
skipped
)
return
printSuccess
(
"Firewall I
PT
ables Check %s: Could not run iptables"
,
skipped
)
}
inputRegex
,
err
:=
regexp
.
Compile
(
iptablesInputRegexStr
)
if
err
!=
nil
{
...
...
@@ -203,13 +203,13 @@ func firewall() error {
panic
(
err
)
}
if
inputRegex
.
Match
(
out
)
{
return
printError
(
"Firewall I
pt
ables Check %s: Found INPUT rule matching %s"
,
failed
,
iptablesInputRegexStr
)
return
printError
(
"Firewall I
PT
ables Check %s: Found INPUT rule matching %s"
,
failed
,
iptablesInputRegexStr
)
}
// Check GCE forward rules
out
,
err
=
exec
.
Command
(
"iptables"
,
"-L"
,
"FORWARD"
)
.
CombinedOutput
()
if
err
!=
nil
{
return
printSuccess
(
"Firewall I
pt
ables Check %s: Could not run iptables"
,
skipped
)
return
printSuccess
(
"Firewall I
PT
ables Check %s: Could not run iptables"
,
skipped
)
}
forwardRegex
,
err
:=
regexp
.
Compile
(
iptablesForwardRegexStr
)
if
err
!=
nil
{
...
...
@@ -217,10 +217,10 @@ func firewall() error {
panic
(
err
)
}
if
forwardRegex
.
Match
(
out
)
{
return
printError
(
"Firewall I
pt
ables Check %s: Found FORWARD rule matching %s"
,
failed
,
iptablesInputRegexStr
)
return
printError
(
"Firewall I
PT
ables Check %s: Found FORWARD rule matching %s"
,
failed
,
iptablesInputRegexStr
)
}
return
printSuccess
(
"Firewall I
pt
ables Check %s"
,
success
)
return
printSuccess
(
"Firewall I
PT
ables Check %s"
,
success
)
}
// daemons checks that the required node programs are running: kubelet, kube-proxy, and docker
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment