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
a99e0048
Unverified
Commit
a99e0048
authored
Nov 07, 2018
by
k8s-ci-robot
Committed by
GitHub
Nov 07, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #70681 from justinsb/block_master_all_ips
e2e: block all master addresses
parents
f1bf9bef
c136a99b
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
66 additions
and
30 deletions
+66
-30
network_partition.go
test/e2e/apps/network_partition.go
+14
-6
networking_utils.go
test/e2e/framework/networking_utils.go
+7
-3
util.go
test/e2e/framework/util.go
+15
-6
firewall.go
test/e2e/network/firewall.go
+23
-12
taint_based_evictions.go
test/e2e/scheduling/taint_based_evictions.go
+7
-3
No files found.
test/e2e/apps/network_partition.go
View file @
a99e0048
...
@@ -198,10 +198,12 @@ var _ = SIGDescribe("Network Partition [Disruptive] [Slow]", func() {
...
@@ -198,10 +198,12 @@ var _ = SIGDescribe("Network Partition [Disruptive] [Slow]", func() {
By
(
fmt
.
Sprintf
(
"Block traffic from node %s to the master"
,
node
.
Name
))
By
(
fmt
.
Sprintf
(
"Block traffic from node %s to the master"
,
node
.
Name
))
host
,
err
:=
framework
.
GetNodeExternalIP
(
&
node
)
host
,
err
:=
framework
.
GetNodeExternalIP
(
&
node
)
framework
.
ExpectNoError
(
err
)
framework
.
ExpectNoError
(
err
)
master
:=
framework
.
GetMasterAddres
s
(
c
)
master
Addresses
:=
framework
.
GetAllMasterAddresse
s
(
c
)
defer
func
()
{
defer
func
()
{
By
(
fmt
.
Sprintf
(
"Unblock traffic from node %s to the master"
,
node
.
Name
))
By
(
fmt
.
Sprintf
(
"Unblock traffic from node %s to the master"
,
node
.
Name
))
framework
.
UnblockNetwork
(
host
,
master
)
for
_
,
masterAddress
:=
range
masterAddresses
{
framework
.
UnblockNetwork
(
host
,
masterAddress
)
}
if
CurrentGinkgoTestDescription
()
.
Failed
{
if
CurrentGinkgoTestDescription
()
.
Failed
{
return
return
...
@@ -214,7 +216,9 @@ var _ = SIGDescribe("Network Partition [Disruptive] [Slow]", func() {
...
@@ -214,7 +216,9 @@ var _ = SIGDescribe("Network Partition [Disruptive] [Slow]", func() {
}
}
}()
}()
framework
.
BlockNetwork
(
host
,
master
)
for
_
,
masterAddress
:=
range
masterAddresses
{
framework
.
BlockNetwork
(
host
,
masterAddress
)
}
By
(
"Expect to observe node and pod status change from Ready to NotReady after network partition"
)
By
(
"Expect to observe node and pod status change from Ready to NotReady after network partition"
)
expectNodeReadiness
(
false
,
newNode
)
expectNodeReadiness
(
false
,
newNode
)
...
@@ -576,10 +580,12 @@ var _ = SIGDescribe("Network Partition [Disruptive] [Slow]", func() {
...
@@ -576,10 +580,12 @@ var _ = SIGDescribe("Network Partition [Disruptive] [Slow]", func() {
By
(
fmt
.
Sprintf
(
"Block traffic from node %s to the master"
,
node
.
Name
))
By
(
fmt
.
Sprintf
(
"Block traffic from node %s to the master"
,
node
.
Name
))
host
,
err
:=
framework
.
GetNodeExternalIP
(
&
node
)
host
,
err
:=
framework
.
GetNodeExternalIP
(
&
node
)
framework
.
ExpectNoError
(
err
)
framework
.
ExpectNoError
(
err
)
master
:=
framework
.
GetMasterAddres
s
(
c
)
master
Addresses
:=
framework
.
GetAllMasterAddresse
s
(
c
)
defer
func
()
{
defer
func
()
{
By
(
fmt
.
Sprintf
(
"Unblock traffic from node %s to the master"
,
node
.
Name
))
By
(
fmt
.
Sprintf
(
"Unblock traffic from node %s to the master"
,
node
.
Name
))
framework
.
UnblockNetwork
(
host
,
master
)
for
_
,
masterAddress
:=
range
masterAddresses
{
framework
.
UnblockNetwork
(
host
,
masterAddress
)
}
if
CurrentGinkgoTestDescription
()
.
Failed
{
if
CurrentGinkgoTestDescription
()
.
Failed
{
return
return
...
@@ -589,7 +595,9 @@ var _ = SIGDescribe("Network Partition [Disruptive] [Slow]", func() {
...
@@ -589,7 +595,9 @@ var _ = SIGDescribe("Network Partition [Disruptive] [Slow]", func() {
expectNodeReadiness
(
true
,
newNode
)
expectNodeReadiness
(
true
,
newNode
)
}()
}()
framework
.
BlockNetwork
(
host
,
master
)
for
_
,
masterAddress
:=
range
masterAddresses
{
framework
.
BlockNetwork
(
host
,
masterAddress
)
}
By
(
"Expect to observe node and pod status change from Ready to NotReady after network partition"
)
By
(
"Expect to observe node and pod status change from Ready to NotReady after network partition"
)
expectNodeReadiness
(
false
,
newNode
)
expectNodeReadiness
(
false
,
newNode
)
...
...
test/e2e/framework/networking_utils.go
View file @
a99e0048
...
@@ -952,7 +952,7 @@ func TestUnderTemporaryNetworkFailure(c clientset.Interface, ns string, node *v1
...
@@ -952,7 +952,7 @@ func TestUnderTemporaryNetworkFailure(c clientset.Interface, ns string, node *v1
if
err
!=
nil
{
if
err
!=
nil
{
Failf
(
"Error getting node external ip : %v"
,
err
)
Failf
(
"Error getting node external ip : %v"
,
err
)
}
}
master
:=
GetMasterAddres
s
(
c
)
master
Addresses
:=
GetAllMasterAddresse
s
(
c
)
By
(
fmt
.
Sprintf
(
"block network traffic from node %s to the master"
,
node
.
Name
))
By
(
fmt
.
Sprintf
(
"block network traffic from node %s to the master"
,
node
.
Name
))
defer
func
()
{
defer
func
()
{
// This code will execute even if setting the iptables rule failed.
// This code will execute even if setting the iptables rule failed.
...
@@ -960,14 +960,18 @@ func TestUnderTemporaryNetworkFailure(c clientset.Interface, ns string, node *v1
...
@@ -960,14 +960,18 @@ func TestUnderTemporaryNetworkFailure(c clientset.Interface, ns string, node *v1
// had been inserted. (yes, we could look at the error code and ssh error
// had been inserted. (yes, we could look at the error code and ssh error
// separately, but I prefer to stay on the safe side).
// separately, but I prefer to stay on the safe side).
By
(
fmt
.
Sprintf
(
"Unblock network traffic from node %s to the master"
,
node
.
Name
))
By
(
fmt
.
Sprintf
(
"Unblock network traffic from node %s to the master"
,
node
.
Name
))
UnblockNetwork
(
host
,
master
)
for
_
,
masterAddress
:=
range
masterAddresses
{
UnblockNetwork
(
host
,
masterAddress
)
}
}()
}()
Logf
(
"Waiting %v to ensure node %s is ready before beginning test..."
,
resizeNodeReadyTimeout
,
node
.
Name
)
Logf
(
"Waiting %v to ensure node %s is ready before beginning test..."
,
resizeNodeReadyTimeout
,
node
.
Name
)
if
!
WaitForNodeToBe
(
c
,
node
.
Name
,
v1
.
NodeReady
,
true
,
resizeNodeReadyTimeout
)
{
if
!
WaitForNodeToBe
(
c
,
node
.
Name
,
v1
.
NodeReady
,
true
,
resizeNodeReadyTimeout
)
{
Failf
(
"Node %s did not become ready within %v"
,
node
.
Name
,
resizeNodeReadyTimeout
)
Failf
(
"Node %s did not become ready within %v"
,
node
.
Name
,
resizeNodeReadyTimeout
)
}
}
BlockNetwork
(
host
,
master
)
for
_
,
masterAddress
:=
range
masterAddresses
{
BlockNetwork
(
host
,
masterAddress
)
}
Logf
(
"Waiting %v for node %s to be not ready after simulated network failure"
,
resizeNodeNotReadyTimeout
,
node
.
Name
)
Logf
(
"Waiting %v for node %s to be not ready after simulated network failure"
,
resizeNodeNotReadyTimeout
,
node
.
Name
)
if
!
WaitForNodeToBe
(
c
,
node
.
Name
,
v1
.
NodeReady
,
false
,
resizeNodeNotReadyTimeout
)
{
if
!
WaitForNodeToBe
(
c
,
node
.
Name
,
v1
.
NodeReady
,
false
,
resizeNodeNotReadyTimeout
)
{
...
...
test/e2e/framework/util.go
View file @
a99e0048
...
@@ -4960,19 +4960,28 @@ func getMaster(c clientset.Interface) Address {
...
@@ -4960,19 +4960,28 @@ func getMaster(c clientset.Interface) Address {
return
master
return
master
}
}
// GetMasterAddress returns the hostname/external IP/internal IP as appropriate for e2e tests on a particular provider
// GetAllMasterAddresses returns all IP addresses on which the kubelet can reach the master.
// which is the address of the interface used for communication with the kubelet.
// It may return internal and external IPs, even if we expect for
func
GetMasterAddress
(
c
clientset
.
Interface
)
string
{
// e.g. internal IPs to be used (issue #56787), so that we can be
// sure to block the master fully during tests.
func
GetAllMasterAddresses
(
c
clientset
.
Interface
)
[]
string
{
master
:=
getMaster
(
c
)
master
:=
getMaster
(
c
)
ips
:=
sets
.
NewString
()
switch
TestContext
.
Provider
{
switch
TestContext
.
Provider
{
case
"gce"
,
"gke"
:
case
"gce"
,
"gke"
:
return
master
.
externalIP
if
master
.
externalIP
!=
""
{
ips
.
Insert
(
master
.
externalIP
)
}
if
master
.
internalIP
!=
""
{
ips
.
Insert
(
master
.
internalIP
)
}
case
"aws"
:
case
"aws"
:
return
awsMasterIP
ips
.
Insert
(
awsMasterIP
)
default
:
default
:
Failf
(
"This test is not supported for provider %s and should be disabled"
,
TestContext
.
Provider
)
Failf
(
"This test is not supported for provider %s and should be disabled"
,
TestContext
.
Provider
)
}
}
return
""
return
ips
.
List
()
}
}
// GetNodeExternalIP returns node external IP concatenated with port 22 for ssh
// GetNodeExternalIP returns node external IP concatenated with port 22 for ssh
...
...
test/e2e/network/firewall.go
View file @
a99e0048
...
@@ -18,6 +18,7 @@ package network
...
@@ -18,6 +18,7 @@ package network
import
(
import
(
"fmt"
"fmt"
"time"
"k8s.io/api/core/v1"
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/sets"
...
@@ -172,17 +173,27 @@ var _ = SIGDescribe("Firewall rule", func() {
...
@@ -172,17 +173,27 @@ var _ = SIGDescribe("Firewall rule", func() {
By
(
"Checking well known ports on master and nodes are not exposed externally"
)
By
(
"Checking well known ports on master and nodes are not exposed externally"
)
nodeAddrs
:=
framework
.
NodeAddresses
(
nodes
,
v1
.
NodeExternalIP
)
nodeAddrs
:=
framework
.
NodeAddresses
(
nodes
,
v1
.
NodeExternalIP
)
Expect
(
len
(
nodeAddrs
))
.
NotTo
(
BeZero
())
if
len
(
nodeAddrs
)
==
0
{
masterAddr
:=
framework
.
GetMasterAddress
(
cs
)
framework
.
Failf
(
"did not find any node addresses"
)
flag
,
_
:=
framework
.
TestNotReachableHTTPTimeout
(
masterAddr
,
ports
.
InsecureKubeControllerManagerPort
,
gce
.
FirewallTestTcpTimeout
)
}
Expect
(
flag
)
.
To
(
BeTrue
())
flag
,
_
=
framework
.
TestNotReachableHTTPTimeout
(
masterAddr
,
ports
.
SchedulerPort
,
gce
.
FirewallTestTcpTimeout
)
masterAddresses
:=
framework
.
GetAllMasterAddresses
(
cs
)
Expect
(
flag
)
.
To
(
BeTrue
())
for
_
,
masterAddress
:=
range
masterAddresses
{
flag
,
_
=
framework
.
TestNotReachableHTTPTimeout
(
nodeAddrs
[
0
],
ports
.
Kubelet
Port
,
gce
.
FirewallTestTcpTimeout
)
assertNotReachableHTTPTimeout
(
masterAddress
,
ports
.
InsecureKubeControllerManager
Port
,
gce
.
FirewallTestTcpTimeout
)
Expect
(
flag
)
.
To
(
BeTrue
()
)
assertNotReachableHTTPTimeout
(
masterAddress
,
ports
.
SchedulerPort
,
gce
.
FirewallTestTcpTimeout
)
flag
,
_
=
framework
.
TestNotReachableHTTPTimeout
(
nodeAddrs
[
0
],
ports
.
KubeletReadOnlyPort
,
gce
.
FirewallTestTcpTimeout
)
}
Expect
(
flag
)
.
To
(
BeTrue
()
)
assertNotReachableHTTPTimeout
(
nodeAddrs
[
0
],
ports
.
KubeletPort
,
gce
.
FirewallTestTcpTimeout
)
flag
,
_
=
framework
.
TestNotReachableHTTPTimeout
(
nodeAddrs
[
0
],
ports
.
ProxyStatus
Port
,
gce
.
FirewallTestTcpTimeout
)
assertNotReachableHTTPTimeout
(
nodeAddrs
[
0
],
ports
.
KubeletReadOnly
Port
,
gce
.
FirewallTestTcpTimeout
)
Expect
(
flag
)
.
To
(
BeTrue
()
)
assertNotReachableHTTPTimeout
(
nodeAddrs
[
0
],
ports
.
ProxyStatusPort
,
gce
.
FirewallTestTcpTimeout
)
})
})
})
})
func
assertNotReachableHTTPTimeout
(
ip
string
,
port
int
,
timeout
time
.
Duration
)
{
unreachable
,
err
:=
framework
.
TestNotReachableHTTPTimeout
(
ip
,
port
,
timeout
)
if
err
!=
nil
{
framework
.
Failf
(
"Unexpected error checking for reachability of %s:%d: %v"
,
ip
,
port
,
err
)
}
if
!
unreachable
{
framework
.
Failf
(
"Was unexpectedly able to reach %s:%d"
,
ip
,
port
)
}
}
test/e2e/scheduling/taint_based_evictions.go
View file @
a99e0048
...
@@ -128,12 +128,14 @@ var _ = SIGDescribe("TaintBasedEvictions [Serial]", func() {
...
@@ -128,12 +128,14 @@ var _ = SIGDescribe("TaintBasedEvictions [Serial]", func() {
// host, err = framework.GetNodeInternalIP(&node)
// host, err = framework.GetNodeInternalIP(&node)
// }
// }
framework
.
ExpectNoError
(
err
)
framework
.
ExpectNoError
(
err
)
master
:=
framework
.
GetMasterAddres
s
(
cs
)
master
Addresses
:=
framework
.
GetAllMasterAddresse
s
(
cs
)
taint
:=
newUnreachableNoExecuteTaint
()
taint
:=
newUnreachableNoExecuteTaint
()
defer
func
()
{
defer
func
()
{
By
(
fmt
.
Sprintf
(
"Unblocking traffic from node %s to the master"
,
node
.
Name
))
By
(
fmt
.
Sprintf
(
"Unblocking traffic from node %s to the master"
,
node
.
Name
))
framework
.
UnblockNetwork
(
host
,
master
)
for
_
,
masterAddress
:=
range
masterAddresses
{
framework
.
UnblockNetwork
(
host
,
masterAddress
)
}
if
CurrentGinkgoTestDescription
()
.
Failed
{
if
CurrentGinkgoTestDescription
()
.
Failed
{
framework
.
Failf
(
"Current e2e test has failed, so return from here."
)
framework
.
Failf
(
"Current e2e test has failed, so return from here."
)
...
@@ -147,7 +149,9 @@ var _ = SIGDescribe("TaintBasedEvictions [Serial]", func() {
...
@@ -147,7 +149,9 @@ var _ = SIGDescribe("TaintBasedEvictions [Serial]", func() {
framework
.
ExpectNoError
(
err
)
framework
.
ExpectNoError
(
err
)
}()
}()
framework
.
BlockNetwork
(
host
,
master
)
for
_
,
masterAddress
:=
range
masterAddresses
{
framework
.
BlockNetwork
(
host
,
masterAddress
)
}
By
(
fmt
.
Sprintf
(
"Expecting to see node %q becomes NotReady"
,
nodeName
))
By
(
fmt
.
Sprintf
(
"Expecting to see node %q becomes NotReady"
,
nodeName
))
if
!
framework
.
WaitForNodeToBeNotReady
(
cs
,
nodeName
,
time
.
Minute
*
3
)
{
if
!
framework
.
WaitForNodeToBeNotReady
(
cs
,
nodeName
,
time
.
Minute
*
3
)
{
...
...
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