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
6762a865
Commit
6762a865
authored
Mar 13, 2018
by
Lion-Wei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix ipvs esipp
parent
35386768
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
43 deletions
+42
-43
ipset.go
pkg/proxy/ipvs/ipset.go
+10
-4
proxier.go
pkg/proxy/ipvs/proxier.go
+0
-0
proxier_test.go
pkg/proxy/ipvs/proxier_test.go
+32
-39
No files found.
pkg/proxy/ipvs/ipset.go
View file @
6762a865
...
...
@@ -40,8 +40,8 @@ const (
// KubeLoadBalancerSet is used to store service load balancer ingress ip + port, it is the service lb portal.
KubeLoadBalancerSet
=
"KUBE-LOAD-BALANCER"
// KubeLoadBalancer
MasqSet is used to store service load balancer ingress ip + port for masquerade purpose
.
KubeLoadBalancer
MasqSet
=
"KUBE-LOAD-BALANCER-MASQ
"
// KubeLoadBalancer
IngressLocalSet is used to store service load balancer ingress ip + port with externalTrafficPolicy=local
.
KubeLoadBalancer
IngressLocalSet
=
"KUBE-LB-INGRESS-LOCAL
"
// KubeLoadBalancerSourceIPSet is used to store service load balancer ingress ip + port + source IP for packet filter purpose.
KubeLoadBalancerSourceIPSet
=
"KUBE-LOAD-BALANCER-SOURCE-IP"
...
...
@@ -49,11 +49,17 @@ const (
// KubeLoadBalancerSourceCIDRSet is used to store service load balancer ingress ip + port + source cidr for packet filter purpose.
KubeLoadBalancerSourceCIDRSet
=
"KUBE-LOAD-BALANCER-SOURCE-CIDR"
// KubeNodePortSetTCP is used to store nodeport TCP port for masquerade purpose.
// KubeNodePortSetTCP is used to store
the
nodeport TCP port for masquerade purpose.
KubeNodePortSetTCP
=
"KUBE-NODE-PORT-TCP"
// KubeNodePortSetUDP is used to store nodeport UDP port for masquerade purpose.
// KubeNodePortLocalSetTCP is used to store the nodeport TCP port with externalTrafficPolicy=local.
KubeNodePortLocalSetTCP
=
"KUBE-NODE-PORT-LOCAL-TCP"
// KubeNodePortSetUDP is used to store the nodeport UDP port for masquerade purpose.
KubeNodePortSetUDP
=
"KUBE-NODE-PORT-UDP"
// KubeNodePortLocalSetUDP is used to store the nodeport UDP port with externalTrafficPolicy=local.
KubeNodePortLocalSetUDP
=
"KUBE-NODE-PORT-LOCAL-UDP"
)
// IPSetVersioner can query the current ipset version.
...
...
pkg/proxy/ipvs/proxier.go
View file @
6762a865
This diff is collapsed.
Click to expand it.
pkg/proxy/ipvs/proxier_test.go
View file @
6762a865
...
...
@@ -120,36 +120,38 @@ func NewFakeProxier(ipt utiliptables.Interface, ipvs utilipvs.Interface, ipset u
LookPathFunc
:
func
(
cmd
string
)
(
string
,
error
)
{
return
cmd
,
nil
},
}
return
&
Proxier
{
exec
:
fexec
,
serviceMap
:
make
(
proxy
.
ServiceMap
),
serviceChanges
:
proxy
.
NewServiceChangeTracker
(
newServiceInfo
,
nil
,
nil
),
endpointsMap
:
make
(
proxy
.
EndpointsMap
),
endpointsChanges
:
proxy
.
NewEndpointChangeTracker
(
testHostname
,
nil
,
nil
,
nil
),
iptables
:
ipt
,
ipvs
:
ipvs
,
ipset
:
ipset
,
clusterCIDR
:
"10.0.0.0/24"
,
hostname
:
testHostname
,
portsMap
:
make
(
map
[
utilproxy
.
LocalPort
]
utilproxy
.
Closeable
),
portMapper
:
&
fakePortOpener
{[]
*
utilproxy
.
LocalPort
{}},
healthChecker
:
newFakeHealthChecker
(),
ipvsScheduler
:
DefaultScheduler
,
ipGetter
:
&
fakeIPGetter
{
nodeIPs
:
nodeIPs
},
iptablesData
:
bytes
.
NewBuffer
(
nil
),
natChains
:
bytes
.
NewBuffer
(
nil
),
natRules
:
bytes
.
NewBuffer
(
nil
),
netlinkHandle
:
netlinktest
.
NewFakeNetlinkHandle
(),
loopbackSet
:
NewIPSet
(
ipset
,
KubeLoopBackIPSet
,
utilipset
.
HashIPPortIP
,
false
),
clusterIPSet
:
NewIPSet
(
ipset
,
KubeClusterIPSet
,
utilipset
.
HashIPPort
,
false
),
externalIPSet
:
NewIPSet
(
ipset
,
KubeExternalIPSet
,
utilipset
.
HashIPPort
,
false
),
lbIngressSet
:
NewIPSet
(
ipset
,
KubeLoadBalancerSet
,
utilipset
.
HashIPPort
,
false
),
lbMasqSet
:
NewIPSet
(
ipset
,
KubeLoadBalancerMasqSet
,
utilipset
.
HashIPPort
,
false
),
lbWhiteListIPSet
:
NewIPSet
(
ipset
,
KubeLoadBalancerSourceIPSet
,
utilipset
.
HashIPPortIP
,
false
),
lbWhiteListCIDRSet
:
NewIPSet
(
ipset
,
KubeLoadBalancerSourceCIDRSet
,
utilipset
.
HashIPPortNet
,
false
),
nodePortSetTCP
:
NewIPSet
(
ipset
,
KubeNodePortSetTCP
,
utilipset
.
BitmapPort
,
false
),
nodePortSetUDP
:
NewIPSet
(
ipset
,
KubeNodePortSetUDP
,
utilipset
.
BitmapPort
,
false
),
nodePortAddresses
:
make
([]
string
,
0
),
networkInterfacer
:
proxyutiltest
.
NewFakeNetwork
(),
exec
:
fexec
,
serviceMap
:
make
(
proxy
.
ServiceMap
),
serviceChanges
:
proxy
.
NewServiceChangeTracker
(
newServiceInfo
,
nil
,
nil
),
endpointsMap
:
make
(
proxy
.
EndpointsMap
),
endpointsChanges
:
proxy
.
NewEndpointChangeTracker
(
testHostname
,
nil
,
nil
,
nil
),
iptables
:
ipt
,
ipvs
:
ipvs
,
ipset
:
ipset
,
clusterCIDR
:
"10.0.0.0/24"
,
hostname
:
testHostname
,
portsMap
:
make
(
map
[
utilproxy
.
LocalPort
]
utilproxy
.
Closeable
),
portMapper
:
&
fakePortOpener
{[]
*
utilproxy
.
LocalPort
{}},
healthChecker
:
newFakeHealthChecker
(),
ipvsScheduler
:
DefaultScheduler
,
ipGetter
:
&
fakeIPGetter
{
nodeIPs
:
nodeIPs
},
iptablesData
:
bytes
.
NewBuffer
(
nil
),
natChains
:
bytes
.
NewBuffer
(
nil
),
natRules
:
bytes
.
NewBuffer
(
nil
),
netlinkHandle
:
netlinktest
.
NewFakeNetlinkHandle
(),
loopbackSet
:
NewIPSet
(
ipset
,
KubeLoopBackIPSet
,
utilipset
.
HashIPPortIP
,
false
),
clusterIPSet
:
NewIPSet
(
ipset
,
KubeClusterIPSet
,
utilipset
.
HashIPPort
,
false
),
externalIPSet
:
NewIPSet
(
ipset
,
KubeExternalIPSet
,
utilipset
.
HashIPPort
,
false
),
lbIngressSet
:
NewIPSet
(
ipset
,
KubeLoadBalancerSet
,
utilipset
.
HashIPPort
,
false
),
lbIngressLocalSet
:
NewIPSet
(
ipset
,
KubeLoadBalancerIngressLocalSet
,
utilipset
.
HashIPPort
,
false
),
lbWhiteListIPSet
:
NewIPSet
(
ipset
,
KubeLoadBalancerSourceIPSet
,
utilipset
.
HashIPPortIP
,
false
),
lbWhiteListCIDRSet
:
NewIPSet
(
ipset
,
KubeLoadBalancerSourceCIDRSet
,
utilipset
.
HashIPPortNet
,
false
),
nodePortSetTCP
:
NewIPSet
(
ipset
,
KubeNodePortSetTCP
,
utilipset
.
BitmapPort
,
false
),
nodePortLocalSetTCP
:
NewIPSet
(
ipset
,
KubeNodePortLocalSetTCP
,
utilipset
.
BitmapPort
,
false
),
nodePortLocalSetUDP
:
NewIPSet
(
ipset
,
KubeNodePortLocalSetUDP
,
utilipset
.
BitmapPort
,
false
),
nodePortSetUDP
:
NewIPSet
(
ipset
,
KubeNodePortSetUDP
,
utilipset
.
BitmapPort
,
false
),
nodePortAddresses
:
make
([]
string
,
0
),
networkInterfacer
:
proxyutiltest
.
NewFakeNetwork
(),
}
}
...
...
@@ -976,12 +978,6 @@ func TestLoadBalanceSourceRanges(t *testing.T) {
Protocol
:
strings
.
ToLower
(
string
(
api
.
ProtocolTCP
)),
SetType
:
utilipset
.
HashIPPort
,
},
KubeLoadBalancerMasqSet
:
{
IP
:
svcLBIP
,
Port
:
svcPort
,
Protocol
:
strings
.
ToLower
(
string
(
api
.
ProtocolTCP
)),
SetType
:
utilipset
.
HashIPPort
,
},
KubeLoadBalancerSourceCIDRSet
:
{
IP
:
svcLBIP
,
Port
:
svcPort
,
...
...
@@ -1004,9 +1000,6 @@ func TestLoadBalanceSourceRanges(t *testing.T) {
// Check iptables chain and rules
kubeSvcRules
:=
ipt
.
GetRules
(
string
(
kubeServicesChain
))
kubeFWRules
:=
ipt
.
GetRules
(
string
(
KubeFireWallChain
))
if
!
hasJump
(
kubeSvcRules
,
string
(
KubeMarkMasqChain
),
KubeLoadBalancerMasqSet
)
{
t
.
Errorf
(
"Didn't find jump from chain %v match set %v to MASQUERADE"
,
kubeServicesChain
,
KubeLoadBalancerMasqSet
)
}
if
!
hasJump
(
kubeSvcRules
,
string
(
KubeFireWallChain
),
KubeLoadBalancerSet
)
{
t
.
Errorf
(
"Didn't find jump from chain %v match set %v to %v"
,
kubeServicesChain
,
KubeLoadBalancerSet
,
KubeFireWallChain
)
...
...
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