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
93f9b54c
Commit
93f9b54c
authored
Sep 26, 2016
by
bprashanth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
NodePorts understand OnlyLocal
parent
5f4c8c24
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
4 deletions
+18
-4
proxier.go
pkg/proxy/iptables/proxier.go
+18
-4
No files found.
pkg/proxy/iptables/proxier.go
View file @
93f9b54c
...
...
@@ -1070,10 +1070,14 @@ func (proxier *Proxier) syncProxyRules() {
"-m"
,
protocol
,
"-p"
,
protocol
,
"--dport"
,
fmt
.
Sprintf
(
"%d"
,
svcInfo
.
nodePort
),
}
// Nodeports need SNAT.
writeLine
(
natRules
,
append
(
args
,
"-j"
,
string
(
KubeMarkMasqChain
))
...
)
// Jump to the service chain.
writeLine
(
natRules
,
append
(
args
,
"-j"
,
string
(
svcChain
))
...
)
if
!
svcInfo
.
onlyNodeLocalEndpoints
{
// Nodeports need SNAT, unless they're local.
writeLine
(
natRules
,
append
(
args
,
"-j"
,
string
(
KubeMarkMasqChain
))
...
)
// Jump to the service chain.
writeLine
(
natRules
,
append
(
args
,
"-j"
,
string
(
svcChain
))
...
)
}
else
{
writeLine
(
natRules
,
append
(
args
,
"-j"
,
string
(
svcXlbChain
))
...
)
}
}
// If the service has no endpoints then reject packets.
...
...
@@ -1173,6 +1177,16 @@ func (proxier *Proxier) syncProxyRules() {
localEndpointChains
=
append
(
localEndpointChains
,
endpointChains
[
i
])
}
}
// First rule in the chain redirects all pod -> external vip traffic to the
// Service's ClusterIP instead. This happens whether or not we have local
// endpoints.
args
=
[]
string
{
"-A"
,
string
(
svcXlbChain
),
"-m"
,
"comment"
,
"--comment"
,
fmt
.
Sprintf
(
`"Redirect pods trying to reach external loadbalancer VIP to clusterIP"`
),
}
writeLine
(
natRules
,
append
(
args
,
"-s"
,
proxier
.
clusterCIDR
,
"-j"
,
string
(
svcChain
))
...
)
numLocalEndpoints
:=
len
(
localEndpointChains
)
if
numLocalEndpoints
==
0
{
// Blackhole all traffic since there are no local endpoints
...
...
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