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
234ce8da
Commit
234ce8da
authored
Nov 29, 2017
by
George Kudrayvtsev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Makes modes OS-specific (+ fixes tests).
parent
54662ca7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
12 deletions
+27
-12
types.go
pkg/proxy/apis/kubeproxyconfig/types.go
+7
-5
validation.go
pkg/proxy/apis/kubeproxyconfig/validation/validation.go
+11
-3
validation_test.go
pkg/proxy/apis/kubeproxyconfig/validation/validation_test.go
+9
-4
No files found.
pkg/proxy/apis/kubeproxyconfig/types.go
View file @
234ce8da
...
@@ -152,11 +152,13 @@ type KubeProxyConfiguration struct {
...
@@ -152,11 +152,13 @@ type KubeProxyConfiguration struct {
ConfigSyncPeriod
metav1
.
Duration
ConfigSyncPeriod
metav1
.
Duration
}
}
// Currently two modes of proxying are available: 'userspace' (older, stable) or 'iptables'
// Currently, four modes of proxying are available total: 'userspace' (older, stable), 'iptables'
// (newer, faster). If blank, use the best-available proxy (currently iptables, but may
// (newer, faster), 'ipvs', and 'kernelspace' (Windows only, newer).
// change in future versions). If the iptables proxy is selected, regardless of how, but
//
// the system's kernel or iptables versions are insufficient, this always falls back to the
// If blank, use the best-available proxy (currently iptables, but may change in
// userspace proxy.
// future versions). If the iptables proxy is selected, regardless of how, but
// the system's kernel or iptables versions are insufficient, this always falls
// back to the userspace proxy.
type
ProxyMode
string
type
ProxyMode
string
const
(
const
(
...
...
pkg/proxy/apis/kubeproxyconfig/validation/validation.go
View file @
234ce8da
...
@@ -19,6 +19,7 @@ package validation
...
@@ -19,6 +19,7 @@ package validation
import
(
import
(
"fmt"
"fmt"
"net"
"net"
"runtime"
"strconv"
"strconv"
"strings"
"strings"
...
@@ -146,11 +147,18 @@ func validateProxyMode(mode kubeproxyconfig.ProxyMode, fldPath *field.Path) fiel
...
@@ -146,11 +147,18 @@ func validateProxyMode(mode kubeproxyconfig.ProxyMode, fldPath *field.Path) fiel
case
kubeproxyconfig
.
ProxyModeUserspace
:
case
kubeproxyconfig
.
ProxyModeUserspace
:
case
kubeproxyconfig
.
ProxyModeIPTables
:
case
kubeproxyconfig
.
ProxyModeIPTables
:
case
kubeproxyconfig
.
ProxyModeIPVS
:
case
kubeproxyconfig
.
ProxyModeIPVS
:
case
kubeproxyconfig
.
ProxyModeKernelspace
:
case
""
:
case
""
:
case
kubeproxyconfig
.
ProxyModeKernelspace
:
if
runtime
.
GOOS
!=
"windows"
{
errMsg
:=
fmt
.
Sprintf
(
"%s is only supported on Windows"
,
string
(
kubeproxyconfig
.
ProxyModeKernelspace
))
allErrs
=
append
(
allErrs
,
field
.
Invalid
(
fldPath
.
Child
(
"ProxyMode"
),
string
(
mode
),
errMsg
))
}
default
:
default
:
modes
:=
[]
string
{
string
(
kubeproxyconfig
.
ProxyModeUserspace
),
string
(
kubeproxyconfig
.
ProxyModeIPTables
),
string
(
kubeproxyconfig
.
ProxyModeIPVS
),
string
(
kubeproxyconfig
.
ProxyModeKernelspace
)}
modes
:=
[]
string
{
string
(
kubeproxyconfig
.
ProxyModeUserspace
),
string
(
kubeproxyconfig
.
ProxyModeIPTables
),
string
(
kubeproxyconfig
.
ProxyModeIPVS
)}
errMsg
:=
fmt
.
Sprintf
(
"must be %s or blank (blank means the best-available proxy (currently iptables)"
,
strings
.
Join
(
modes
,
","
))
if
runtime
.
GOOS
==
"windows"
{
modes
=
append
(
modes
,
string
(
kubeproxyconfig
.
ProxyModeKernelspace
))
}
errMsg
:=
fmt
.
Sprintf
(
"must be %s or blank (blank means the best-available proxy [currently iptables])"
,
strings
.
Join
(
modes
,
","
))
allErrs
=
append
(
allErrs
,
field
.
Invalid
(
fldPath
.
Child
(
"ProxyMode"
),
string
(
mode
),
errMsg
))
allErrs
=
append
(
allErrs
,
field
.
Invalid
(
fldPath
.
Child
(
"ProxyMode"
),
string
(
mode
),
errMsg
))
}
}
return
allErrs
return
allErrs
...
...
pkg/proxy/apis/kubeproxyconfig/validation/validation_test.go
View file @
234ce8da
...
@@ -18,6 +18,7 @@ package validation
...
@@ -18,6 +18,7 @@ package validation
import
(
import
(
"fmt"
"fmt"
"runtime"
"strings"
"strings"
"testing"
"testing"
"time"
"time"
...
@@ -488,11 +489,15 @@ func TestValidateProxyMode(t *testing.T) {
...
@@ -488,11 +489,15 @@ func TestValidateProxyMode(t *testing.T) {
newPath
:=
field
.
NewPath
(
"KubeProxyConfiguration"
)
newPath
:=
field
.
NewPath
(
"KubeProxyConfiguration"
)
successCases
:=
[]
kubeproxyconfig
.
ProxyMode
{
successCases
:=
[]
kubeproxyconfig
.
ProxyMode
{
kubeproxyconfig
.
ProxyModeUserspace
,
kubeproxyconfig
.
ProxyModeUserspace
,
kubeproxyconfig
.
ProxyModeIPTables
,
kubeproxyconfig
.
ProxyModeIPVS
,
kubeproxyconfig
.
ProxyMode
(
""
),
kubeproxyconfig
.
ProxyMode
(
""
),
}
}
if
runtime
.
GOOS
==
"windows"
{
successCases
=
append
(
successCases
,
kubeproxyconfig
.
ProxyModeKernelspace
)
}
else
{
successCases
=
append
(
successCases
,
kubeproxyconfig
.
ProxyModeIPTables
,
kubeproxyconfig
.
ProxyModeIPVS
)
}
for
_
,
successCase
:=
range
successCases
{
for
_
,
successCase
:=
range
successCases
{
if
errs
:=
validateProxyMode
(
successCase
,
newPath
.
Child
(
"ProxyMode"
));
len
(
errs
)
!=
0
{
if
errs
:=
validateProxyMode
(
successCase
,
newPath
.
Child
(
"ProxyMode"
));
len
(
errs
)
!=
0
{
t
.
Errorf
(
"expected success: %v"
,
errs
)
t
.
Errorf
(
"expected success: %v"
,
errs
)
...
@@ -505,13 +510,13 @@ func TestValidateProxyMode(t *testing.T) {
...
@@ -505,13 +510,13 @@ func TestValidateProxyMode(t *testing.T) {
}{
}{
{
{
mode
:
kubeproxyconfig
.
ProxyMode
(
"non-existing"
),
mode
:
kubeproxyconfig
.
ProxyMode
(
"non-existing"
),
msg
:
"or blank (blank means the best-available proxy
(currently iptables
)"
,
msg
:
"or blank (blank means the best-available proxy
[currently iptables]
)"
,
},
},
}
}
for
_
,
errorCase
:=
range
errorCases
{
for
_
,
errorCase
:=
range
errorCases
{
if
errs
:=
validateProxyMode
(
errorCase
.
mode
,
newPath
.
Child
(
"ProxyMode"
));
len
(
errs
)
==
0
{
if
errs
:=
validateProxyMode
(
errorCase
.
mode
,
newPath
.
Child
(
"ProxyMode"
));
len
(
errs
)
==
0
{
t
.
Errorf
(
"expected failure
for %s"
,
errorCase
.
msg
)
t
.
Errorf
(
"expected failure
%s for %v"
,
errorCase
.
msg
,
errorCase
.
mode
)
}
else
if
!
strings
.
Contains
(
errs
[
0
]
.
Error
(),
errorCase
.
msg
)
{
}
else
if
!
strings
.
Contains
(
errs
[
0
]
.
Error
(),
errorCase
.
msg
)
{
t
.
Errorf
(
"unexpected error: %v, expected: %s"
,
errs
[
0
],
errorCase
.
msg
)
t
.
Errorf
(
"unexpected error: %v, expected: %s"
,
errs
[
0
],
errorCase
.
msg
)
}
}
...
...
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