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
cbe94df8
Commit
cbe94df8
authored
Aug 26, 2018
by
Laszlo Janosi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gofmt update
parent
e466bdc6
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
55 additions
and
60 deletions
+55
-60
validation.go
pkg/apis/core/validation/validation.go
+1
-1
validation_test.go
pkg/apis/core/validation/validation_test.go
+1
-1
validation.go
pkg/apis/networking/validation/validation.go
+2
-2
validation_test.go
pkg/apis/networking/validation/validation_test.go
+4
-4
azure_loadbalancer.go
pkg/cloudprovider/providers/azure/azure_loadbalancer.go
+1
-1
kube_features.go
pkg/features/kube_features.go
+0
-3
hostport_manager.go
pkg/kubelet/dockershim/network/hostport/hostport_manager.go
+2
-2
hostport_manager_test.go
...elet/dockershim/network/hostport/hostport_manager_test.go
+27
-27
hostport_syncer.go
pkg/kubelet/dockershim/network/hostport/hostport_syncer.go
+3
-3
proxier_test.go
pkg/proxy/iptables/proxier_test.go
+4
-4
ipset.go
pkg/proxy/ipvs/ipset.go
+1
-1
proxier.go
pkg/proxy/ipvs/proxier.go
+4
-6
ipset_test.go
pkg/util/ipset/ipset_test.go
+4
-4
ipvs_linux.go
pkg/util/ipvs/ipvs_linux.go
+1
-1
No files found.
pkg/apis/core/validation/validation.go
View file @
cbe94df8
...
...
@@ -3826,7 +3826,7 @@ func validateServicePort(sp *core.ServicePort, requireName, isHeadlessService bo
for
_
,
msg
:=
range
validation
.
IsValidPortNum
(
int
(
sp
.
Port
))
{
allErrs
=
append
(
allErrs
,
field
.
Invalid
(
fldPath
.
Child
(
"port"
),
sp
.
Port
,
msg
))
}
if
len
(
sp
.
Protocol
)
==
0
{
allErrs
=
append
(
allErrs
,
field
.
Required
(
fldPath
.
Child
(
"protocol"
),
""
))
}
else
if
!
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
SCTPSupport
)
&&
sp
.
Protocol
==
core
.
ProtocolSCTP
{
...
...
pkg/apis/core/validation/validation_test.go
View file @
cbe94df8
...
...
@@ -8592,7 +8592,7 @@ func makeValidService() core.Service {
func
TestValidateService
(
t
*
testing
.
T
)
{
defer
utilfeaturetesting
.
SetFeatureGateDuringTest
(
t
,
utilfeature
.
DefaultFeatureGate
,
features
.
SCTPSupport
,
true
)()
testCases
:=
[]
struct
{
name
string
tweakSvc
func
(
svc
*
core
.
Service
)
// given a basic valid service, each test case can customize it
...
...
pkg/apis/networking/validation/validation.go
View file @
cbe94df8
...
...
@@ -23,10 +23,10 @@ import (
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/validation"
"k8s.io/apimachinery/pkg/util/validation/field"
utilfeature
"k8s.io/apiserver/pkg/util/feature"
api
"k8s.io/kubernetes/pkg/apis/core"
apivalidation
"k8s.io/kubernetes/pkg/apis/core/validation"
"k8s.io/kubernetes/pkg/apis/networking"
utilfeature
"k8s.io/apiserver/pkg/util/feature"
"k8s.io/kubernetes/pkg/features"
)
...
...
@@ -44,7 +44,7 @@ func ValidateNetworkPolicyPort(port *networking.NetworkPolicyPort, portPath *fie
allErrs
=
append
(
allErrs
,
field
.
NotSupported
(
portPath
.
Child
(
"protocol"
),
*
port
.
Protocol
,
[]
string
{
string
(
api
.
ProtocolTCP
),
string
(
api
.
ProtocolUDP
),
string
(
api
.
ProtocolSCTP
)}))
}
}
else
if
port
.
Protocol
!=
nil
&&
*
port
.
Protocol
!=
api
.
ProtocolTCP
&&
*
port
.
Protocol
!=
api
.
ProtocolUDP
{
allErrs
=
append
(
allErrs
,
field
.
NotSupported
(
portPath
.
Child
(
"protocol"
),
*
port
.
Protocol
,
[]
string
{
string
(
api
.
ProtocolTCP
),
string
(
api
.
ProtocolUDP
)}))
allErrs
=
append
(
allErrs
,
field
.
NotSupported
(
portPath
.
Child
(
"protocol"
),
*
port
.
Protocol
,
[]
string
{
string
(
api
.
ProtocolTCP
),
string
(
api
.
ProtocolUDP
)}))
}
if
port
.
Port
!=
nil
{
if
port
.
Port
.
Type
==
intstr
.
Int
{
...
...
pkg/apis/networking/validation/validation_test.go
View file @
cbe94df8
...
...
@@ -21,10 +21,10 @@ import (
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
api
"k8s.io/kubernetes/pkg/apis/core"
"k8s.io/kubernetes/pkg/apis/networking"
utilfeature
"k8s.io/apiserver/pkg/util/feature"
utilfeaturetesting
"k8s.io/apiserver/pkg/util/feature/testing"
api
"k8s.io/kubernetes/pkg/apis/core"
"k8s.io/kubernetes/pkg/apis/networking"
"k8s.io/kubernetes/pkg/features"
)
...
...
@@ -33,7 +33,7 @@ func TestValidateNetworkPolicy(t *testing.T) {
protocolUDP
:=
api
.
ProtocolUDP
protocolICMP
:=
api
.
Protocol
(
"ICMP"
)
protocolSCTP
:=
api
.
ProtocolSCTP
defer
utilfeaturetesting
.
SetFeatureGateDuringTest
(
t
,
utilfeature
.
DefaultFeatureGate
,
features
.
SCTPSupport
,
true
)()
successCases
:=
[]
networking
.
NetworkPolicy
{
...
...
@@ -284,7 +284,7 @@ func TestValidateNetworkPolicy(t *testing.T) {
}
// Success cases are expected to pass validation.
for
k
,
v
:=
range
successCases
{
if
errs
:=
ValidateNetworkPolicy
(
&
v
);
len
(
errs
)
!=
0
{
t
.
Errorf
(
"Expected success for %d, got %v"
,
k
,
errs
)
...
...
pkg/cloudprovider/providers/azure/azure_loadbalancer.go
View file @
cbe94df8
...
...
@@ -736,7 +736,7 @@ func (az *Cloud) reconcileLoadBalancer(clusterName string, service *v1.Service,
// compatible with UDP (it uses an HTTP check)
return
nil
,
fmt
.
Errorf
(
"services requiring health checks are incompatible with UDP ports"
)
}
if
port
.
Protocol
==
v1
.
ProtocolSCTP
{
// ERROR: this isn't supported
// health check (aka source ip preservation) is not
...
...
pkg/features/kube_features.go
View file @
cbe94df8
...
...
@@ -422,11 +422,8 @@ var defaultKubernetesFeatureGates = map[utilfeature.Feature]utilfeature.FeatureS
ResourceQuotaScopeSelectors
:
{
Default
:
true
,
PreRelease
:
utilfeature
.
Beta
},
CSIBlockVolume
:
{
Default
:
false
,
PreRelease
:
utilfeature
.
Alpha
},
RuntimeClass
:
{
Default
:
false
,
PreRelease
:
utilfeature
.
Alpha
},
<<<<<<<
HEAD
NodeLease
:
{
Default
:
false
,
PreRelease
:
utilfeature
.
Alpha
},
=======
SCTPSupport
:
{
Default
:
false
,
PreRelease
:
utilfeature
.
Alpha
},
>>>>>>>
Changes
according
to
the
approved
KEP
.
SCTP
is
supported
for
HostPort
and
LoadBalancer
.
Alpha
feature
flag
SCTPSupport
controls
the
support
of
SCTP
.
Kube
-
proxy
config
parameter
is
removed
.
// inherited features from generic apiserver, relisted here to get a conflict if it is changed
// unintentionally on either side:
...
...
pkg/kubelet/dockershim/network/hostport/hostport_manager.go
View file @
cbe94df8
...
...
@@ -264,12 +264,12 @@ func (hm *hostportManager) openHostports(podPortMapping *PodPortMapping) (map[ho
if
pm
.
HostPort
<=
0
{
continue
}
// We do not open host ports for SCTP ports, as we agreed in the Support of SCTP KEP
if
pm
.
Protocol
==
v1
.
ProtocolSCTP
{
continue
}
hp
:=
portMappingToHostport
(
pm
)
socket
,
err
:=
hm
.
portOpener
(
&
hp
)
if
err
!=
nil
{
...
...
pkg/kubelet/dockershim/network/hostport/hostport_manager_test.go
View file @
cbe94df8
...
...
@@ -203,10 +203,10 @@ func TestHostportManager(t *testing.T) {
Protocol
:
v1
.
ProtocolUDP
,
},
{
HostPort
:
8083
,
ContainerPort
:
83
,
Protocol
:
v1
.
ProtocolSCTP
,
},
HostPort
:
8083
,
ContainerPort
:
83
,
Protocol
:
v1
.
ProtocolSCTP
,
},
},
},
expectError
:
false
,
...
...
@@ -287,29 +287,29 @@ func TestHostportManager(t *testing.T) {
lines
:=
strings
.
Split
(
string
(
raw
.
Bytes
()),
"
\n
"
)
expectedLines
:=
map
[
string
]
bool
{
`*nat`
:
true
,
`:KUBE-HOSTPORTS - [0:0]`
:
true
,
`:OUTPUT - [0:0]`
:
true
,
`:PREROUTING - [0:0]`
:
true
,
`:POSTROUTING - [0:0]`
:
true
,
`:KUBE-HP-IJHALPHTORMHHPPK - [0:0]`
:
true
,
`:KUBE-HP-63UPIDJXVRSZGSUZ - [0:0]`
:
true
,
`:KUBE-HP-WFBOALXEP42XEMJK - [0:0]`
:
true
,
`:KUBE-HP-XU6AWMMJYOZOFTFZ - [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 KUBE-HOSTPORTS -m comment --comment
\"
pod1_ns1 hostport 8083
\"
-m sctp -p sctp --dport 8083 -j KUBE-HP-XU6AWMMJYOZOFTFZ"
:
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-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-XU6AWMMJYOZOFTFZ -m comment --comment
\"
pod1_ns1 hostport 8083
\"
-s 10.1.1.2/32 -j KUBE-MARK-MASQ"
:
true
,
"-A KUBE-HP-XU6AWMMJYOZOFTFZ -m comment --comment
\"
pod1_ns1 hostport 8083
\"
-m sctp -p sctp -j DNAT --to-destination 10.1.1.2:83"
:
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
,
`:KUBE-HOSTPORTS - [0:0]`
:
true
,
`:OUTPUT - [0:0]`
:
true
,
`:PREROUTING - [0:0]`
:
true
,
`:POSTROUTING - [0:0]`
:
true
,
`:KUBE-HP-IJHALPHTORMHHPPK - [0:0]`
:
true
,
`:KUBE-HP-63UPIDJXVRSZGSUZ - [0:0]`
:
true
,
`:KUBE-HP-WFBOALXEP42XEMJK - [0:0]`
:
true
,
`:KUBE-HP-XU6AWMMJYOZOFTFZ - [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 KUBE-HOSTPORTS -m comment --comment
\"
pod1_ns1 hostport 8083
\"
-m sctp -p sctp --dport 8083 -j KUBE-HP-XU6AWMMJYOZOFTFZ"
:
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-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-XU6AWMMJYOZOFTFZ -m comment --comment
\"
pod1_ns1 hostport 8083
\"
-s 10.1.1.2/32 -j KUBE-MARK-MASQ"
:
true
,
"-A KUBE-HP-XU6AWMMJYOZOFTFZ -m comment --comment
\"
pod1_ns1 hostport 8083
\"
-m sctp -p sctp -j DNAT --to-destination 10.1.1.2:83"
:
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
{
...
...
pkg/kubelet/dockershim/network/hostport/hostport_syncer.go
View file @
cbe94df8
...
...
@@ -27,9 +27,9 @@ import (
"github.com/golang/glog"
"k8s.io/api/core/v1"
iptablesproxy
"k8s.io/kubernetes/pkg/proxy/iptables"
utiliptables
"k8s.io/kubernetes/pkg/util/iptables"
"k8s.io/api/core/v1"
)
// HostportSyncer takes a list of PodPortMappings and implements hostport all at once
...
...
@@ -75,12 +75,12 @@ func (h *hostportSyncer) openHostports(podHostportMapping *PodPortMapping) error
// Assume hostport is not specified in this portmapping. So skip
continue
}
// We do not open host ports for SCTP ports, as we agreed in the Support of SCTP KEP
if
port
.
Protocol
==
v1
.
ProtocolSCTP
{
continue
}
hp
:=
hostport
{
port
:
port
.
HostPort
,
protocol
:
strings
.
ToLower
(
string
(
port
.
Protocol
)),
...
...
pkg/proxy/iptables/proxier_test.go
View file @
cbe94df8
...
...
@@ -161,8 +161,8 @@ func newFakeServiceInfo(service proxy.ServicePortName, ip net.IP, port int, prot
func
TestDeleteEndpointConnections
(
t
*
testing
.
T
)
{
const
(
UDP
=
v1
.
ProtocolUDP
TCP
=
v1
.
ProtocolTCP
UDP
=
v1
.
ProtocolUDP
TCP
=
v1
.
ProtocolTCP
SCTP
=
v1
.
ProtocolSCTP
)
testCases
:=
[]
struct
{
...
...
@@ -189,14 +189,14 @@ func TestDeleteEndpointConnections(t *testing.T) {
svcPort
:
80
,
protocol
:
TCP
,
endpoint
:
"10.240.0.4:80"
,
},{
},
{
description
:
"V4 SCTP"
,
svcName
:
"v4-sctp"
,
svcIP
:
"10.96.3.3"
,
svcPort
:
80
,
protocol
:
SCTP
,
endpoint
:
"10.240.0.5:80"
,
},{
},
{
description
:
"V4 UDP, nothing to delete, benign error"
,
svcName
:
"v4-udp-nothing-to-delete"
,
svcIP
:
"10.96.1.1"
,
...
...
pkg/proxy/ipvs/ipset.go
View file @
cbe94df8
...
...
@@ -64,7 +64,7 @@ const (
kubeNodePortLocalSetUDPComment
=
"Kubernetes nodeport UDP port with externalTrafficPolicy=local"
kubeNodePortLocalSetUDP
=
"KUBE-NODE-PORT-LOCAL-UDP"
kubeNodePortSetSCTPComment
=
"Kubernetes nodeport SCTP port for masquerade purpose"
kubeNodePortSetSCTP
=
"KUBE-NODE-PORT-SCTP"
...
...
pkg/proxy/ipvs/proxier.go
View file @
cbe94df8
...
...
@@ -47,8 +47,6 @@ import (
utilnet
"k8s.io/kubernetes/pkg/util/net"
utilsysctl
"k8s.io/kubernetes/pkg/util/sysctl"
utilexec
"k8s.io/utils/exec"
)
const
(
...
...
@@ -811,8 +809,8 @@ func (proxier *Proxier) syncProxyRules() {
for
_
,
externalIP
:=
range
svcInfo
.
ExternalIPs
{
if
local
,
err
:=
utilproxy
.
IsLocalIP
(
externalIP
);
err
!=
nil
{
glog
.
Errorf
(
"can't determine if IP is local, assuming not: %v"
,
err
)
// We do not start listening on SCTP ports, according to our agreement in the
// SCTP support KEP
// We do not start listening on SCTP ports, according to our agreement in the
// SCTP support KEP
}
else
if
local
&&
(
svcInfo
.
GetProtocol
()
!=
v1
.
ProtocolSCTP
)
{
lp
:=
utilproxy
.
LocalPort
{
Description
:
"externalIP for "
+
svcNameString
,
...
...
@@ -1012,8 +1010,8 @@ func (proxier *Proxier) syncProxyRules() {
if
proxier
.
portsMap
[
lp
]
!=
nil
{
glog
.
V
(
4
)
.
Infof
(
"Port %s was open before and is still needed"
,
lp
.
String
())
replacementPortsMap
[
lp
]
=
proxier
.
portsMap
[
lp
]
// We do not start listening on SCTP ports, according to our agreement in the
// SCTP support KEP
// We do not start listening on SCTP ports, according to our agreement in the
// SCTP support KEP
}
else
if
svcInfo
.
GetProtocol
()
!=
v1
.
ProtocolSCTP
{
socket
,
err
:=
proxier
.
portMapper
.
OpenLocalPort
(
&
lp
)
if
err
!=
nil
{
...
...
pkg/util/ipset/ipset_test.go
View file @
cbe94df8
...
...
@@ -1425,11 +1425,11 @@ func TestValidateEntry(t *testing.T) {
},
{
// case[19]
entry
:
&
Entry
{
SetType
:
HashIPPortIP
,
IP
:
"10.20.30.40"
,
SetType
:
HashIPPortIP
,
IP
:
"10.20.30.40"
,
Protocol
:
ProtocolSCTP
,
Port
:
8090
,
IP2
:
"10.20.30.41"
,
Port
:
8090
,
IP2
:
"10.20.30.41"
,
},
set
:
&
IPSet
{
Name
:
"sctp"
,
...
...
pkg/util/ipvs/ipvs_linux.go
View file @
cbe94df8
...
...
@@ -252,7 +252,7 @@ func stringToProtocol(protocol string) uint16 {
return
uint16
(
syscall
.
IPPROTO_TCP
)
case
"udp"
:
return
uint16
(
syscall
.
IPPROTO_UDP
)
case
"sctp"
:
case
"sctp"
:
return
uint16
(
syscall
.
IPPROTO_SCTP
)
}
return
uint16
(
0
)
...
...
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