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