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
5d23dd82
Commit
5d23dd82
authored
Nov 08, 2017
by
Chun Chen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove bugy chains as well to clean up old chain/rule
parent
932cf077
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
12 deletions
+21
-12
hostport_manager.go
pkg/kubelet/network/hostport/hostport_manager.go
+9
-0
hostport_manager_test.go
pkg/kubelet/network/hostport/hostport_manager_test.go
+12
-12
No files found.
pkg/kubelet/network/hostport/hostport_manager.go
View file @
5d23dd82
...
...
@@ -178,6 +178,8 @@ func (hm *hostportManager) Remove(id string, podPortMapping *PodPortMapping) (er
chainsToRemove
:=
[]
utiliptables
.
Chain
{}
for
_
,
pm
:=
range
hostportMappings
{
chainsToRemove
=
append
(
chainsToRemove
,
getHostportChain
(
id
,
pm
))
// TODO remove this, please refer https://github.com/kubernetes/kubernetes/pull/55153
chainsToRemove
=
append
(
chainsToRemove
,
getBugyHostportChain
(
id
,
pm
))
}
// remove rules that consists of target chains
...
...
@@ -253,6 +255,13 @@ func getHostportChain(id string, pm *PortMapping) utiliptables.Chain {
return
utiliptables
.
Chain
(
kubeHostportChainPrefix
+
encoded
[
:
16
])
}
// TODO remove this, please refer https://github.com/kubernetes/kubernetes/pull/55153
func
getBugyHostportChain
(
id
string
,
pm
*
PortMapping
)
utiliptables
.
Chain
{
hash
:=
sha256
.
Sum256
([]
byte
(
id
+
string
(
pm
.
HostPort
)
+
string
(
pm
.
Protocol
)))
encoded
:=
base32
.
StdEncoding
.
EncodeToString
(
hash
[
:
])
return
utiliptables
.
Chain
(
kubeHostportChainPrefix
+
encoded
[
:
16
])
}
// gatherHostportMappings returns all the PortMappings which has hostport for a pod
func
gatherHostportMappings
(
podPortMapping
*
PodPortMapping
)
[]
*
PortMapping
{
mappings
:=
[]
*
PortMapping
{}
...
...
pkg/kubelet/network/hostport/hostport_manager_test.go
View file @
5d23dd82
...
...
@@ -144,21 +144,21 @@ func TestHostportManager(t *testing.T) {
`:OUTPUT - [0:0]`
:
true
,
`:PREROUTING - [0:0]`
:
true
,
`:POSTROUTING - [0:0]`
:
true
,
`:KUBE-HP-
4YVONL46AKYWSKS3
- [0:0]`
:
true
,
`:KUBE-HP-
7THKRFSEH4GIIXK7
- [0:0]`
:
true
,
`:KUBE-HP-
5N7UH5JAXCVP5UJR
- [0:0]`
:
true
,
"-A KUBE-HOSTPORTS -m comment --comment
\"
pod3_ns1 hostport 8443
\"
-m tcp -p tcp --dport 8443 -j KUBE-HP-
5N7UH5JAXCVP5UJR
"
:
true
,
"-A KUBE-HOSTPORTS -m comment --comment
\"
pod1_ns1 hostport 8081
\"
-m udp -p udp --dport 8081 -j KUBE-HP-
7THKRFSEH4GIIXK7
"
:
true
,
"-A KUBE-HOSTPORTS -m comment --comment
\"
pod1_ns1 hostport 8080
\"
-m tcp -p tcp --dport 8080 -j KUBE-HP-
4YVONL46AKYWSKS3
"
:
true
,
`:KUBE-HP-
IJHALPHTORMHHPPK
- [0:0]`
:
true
,
`:KUBE-HP-
63UPIDJXVRSZGSUZ
- [0:0]`
:
true
,
`:KUBE-HP-
WFBOALXEP42XEMJK
- [0:0]`
:
true
,
"-A KUBE-HOSTPORTS -m comment --comment
\"
pod3_ns1 hostport 8443
\"
-m tcp -p tcp --dport 8443 -j KUBE-HP-
WFBOALXEP42XEMJK
"
:
true
,
"-A KUBE-HOSTPORTS -m comment --comment
\"
pod1_ns1 hostport 8081
\"
-m udp -p udp --dport 8081 -j KUBE-HP-
63UPIDJXVRSZGSUZ
"
:
true
,
"-A KUBE-HOSTPORTS -m comment --comment
\"
pod1_ns1 hostport 8080
\"
-m tcp -p tcp --dport 8080 -j KUBE-HP-
IJHALPHTORMHHPPK
"
:
true
,
"-A OUTPUT -m comment --comment
\"
kube hostport portals
\"
-m addrtype --dst-type LOCAL -j KUBE-HOSTPORTS"
:
true
,
"-A PREROUTING -m comment --comment
\"
kube hostport portals
\"
-m addrtype --dst-type LOCAL -j KUBE-HOSTPORTS"
:
true
,
"-A POSTROUTING -m comment --comment
\"
SNAT for localhost access to hostports
\"
-o cbr0 -s 127.0.0.0/8 -j MASQUERADE"
:
true
,
"-A KUBE-HP-
4YVONL46AKYWSKS3
-m comment --comment
\"
pod1_ns1 hostport 8080
\"
-s 10.1.1.2/32 -j KUBE-MARK-MASQ"
:
true
,
"-A KUBE-HP-
4YVONL46AKYWSKS3
-m comment --comment
\"
pod1_ns1 hostport 8080
\"
-m tcp -p tcp -j DNAT --to-destination 10.1.1.2:80"
:
true
,
"-A KUBE-HP-
7THKRFSEH4GIIXK7
-m comment --comment
\"
pod1_ns1 hostport 8081
\"
-s 10.1.1.2/32 -j KUBE-MARK-MASQ"
:
true
,
"-A KUBE-HP-
7THKRFSEH4GIIXK7
-m comment --comment
\"
pod1_ns1 hostport 8081
\"
-m udp -p udp -j DNAT --to-destination 10.1.1.2:81"
:
true
,
"-A KUBE-HP-
5N7UH5JAXCVP5UJR
-m comment --comment
\"
pod3_ns1 hostport 8443
\"
-s 10.1.1.4/32 -j KUBE-MARK-MASQ"
:
true
,
"-A KUBE-HP-
5N7UH5JAXCVP5UJR
-m comment --comment
\"
pod3_ns1 hostport 8443
\"
-m tcp -p tcp -j DNAT --to-destination 10.1.1.4:443"
:
true
,
"-A KUBE-HP-
IJHALPHTORMHHPPK
-m comment --comment
\"
pod1_ns1 hostport 8080
\"
-s 10.1.1.2/32 -j KUBE-MARK-MASQ"
:
true
,
"-A KUBE-HP-
IJHALPHTORMHHPPK
-m comment --comment
\"
pod1_ns1 hostport 8080
\"
-m tcp -p tcp -j DNAT --to-destination 10.1.1.2:80"
:
true
,
"-A KUBE-HP-
63UPIDJXVRSZGSUZ
-m comment --comment
\"
pod1_ns1 hostport 8081
\"
-s 10.1.1.2/32 -j KUBE-MARK-MASQ"
:
true
,
"-A KUBE-HP-
63UPIDJXVRSZGSUZ
-m comment --comment
\"
pod1_ns1 hostport 8081
\"
-m udp -p udp -j DNAT --to-destination 10.1.1.2:81"
:
true
,
"-A KUBE-HP-
WFBOALXEP42XEMJK
-m comment --comment
\"
pod3_ns1 hostport 8443
\"
-s 10.1.1.4/32 -j KUBE-MARK-MASQ"
:
true
,
"-A KUBE-HP-
WFBOALXEP42XEMJK
-m comment --comment
\"
pod3_ns1 hostport 8443
\"
-m tcp -p tcp -j DNAT --to-destination 10.1.1.4:443"
:
true
,
`COMMIT`
:
true
,
}
for
_
,
line
:=
range
lines
{
...
...
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