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
b0dfa4ad
Commit
b0dfa4ad
authored
Dec 17, 2016
by
Klaus Ma
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add event when failed to open local port.
parent
0d80ee0b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
3 deletions
+41
-3
server.go
cmd/kube-proxy/app/server.go
+13
-1
BUILD
pkg/proxy/iptables/BUILD
+2
-0
proxier.go
pkg/proxy/iptables/proxier.go
+26
-2
No files found.
cmd/kube-proxy/app/server.go
View file @
b0dfa4ad
...
@@ -219,7 +219,19 @@ func NewProxyServerDefault(config *options.ProxyServerConfig) (*ProxyServer, err
...
@@ -219,7 +219,19 @@ func NewProxyServerDefault(config *options.ProxyServerConfig) (*ProxyServer, err
// IPTablesMasqueradeBit must be specified or defaulted.
// IPTablesMasqueradeBit must be specified or defaulted.
return
nil
,
fmt
.
Errorf
(
"Unable to read IPTablesMasqueradeBit from config"
)
return
nil
,
fmt
.
Errorf
(
"Unable to read IPTablesMasqueradeBit from config"
)
}
}
proxierIPTables
,
err
:=
iptables
.
NewProxier
(
iptInterface
,
utilsysctl
.
New
(),
execer
,
config
.
IPTablesSyncPeriod
.
Duration
,
config
.
IPTablesMinSyncPeriod
.
Duration
,
config
.
MasqueradeAll
,
int
(
*
config
.
IPTablesMasqueradeBit
),
config
.
ClusterCIDR
,
hostname
,
getNodeIP
(
client
,
hostname
))
proxierIPTables
,
err
:=
iptables
.
NewProxier
(
iptInterface
,
utilsysctl
.
New
(),
execer
,
config
.
IPTablesSyncPeriod
.
Duration
,
config
.
IPTablesMinSyncPeriod
.
Duration
,
config
.
MasqueradeAll
,
int
(
*
config
.
IPTablesMasqueradeBit
),
config
.
ClusterCIDR
,
hostname
,
getNodeIP
(
client
,
hostname
),
recorder
,
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Fatalf
(
"Unable to create proxier: %v"
,
err
)
glog
.
Fatalf
(
"Unable to create proxier: %v"
,
err
)
}
}
...
...
pkg/proxy/iptables/BUILD
View file @
b0dfa4ad
...
@@ -15,6 +15,8 @@ go_library(
...
@@ -15,6 +15,8 @@ go_library(
deps = [
deps = [
"//pkg/api:go_default_library",
"//pkg/api:go_default_library",
"//pkg/api/service:go_default_library",
"//pkg/api/service:go_default_library",
"//pkg/api/v1:go_default_library",
"//pkg/client/record:go_default_library",
"//pkg/proxy:go_default_library",
"//pkg/proxy:go_default_library",
"//pkg/proxy/healthcheck:go_default_library",
"//pkg/proxy/healthcheck:go_default_library",
"//pkg/types:go_default_library",
"//pkg/types:go_default_library",
...
...
pkg/proxy/iptables/proxier.go
View file @
b0dfa4ad
...
@@ -36,6 +36,8 @@ import (
...
@@ -36,6 +36,8 @@ import (
"github.com/golang/glog"
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
apiservice
"k8s.io/kubernetes/pkg/api/service"
apiservice
"k8s.io/kubernetes/pkg/api/service"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/client/record"
"k8s.io/kubernetes/pkg/proxy"
"k8s.io/kubernetes/pkg/proxy"
"k8s.io/kubernetes/pkg/proxy/healthcheck"
"k8s.io/kubernetes/pkg/proxy/healthcheck"
"k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/types"
...
@@ -180,6 +182,7 @@ type Proxier struct {
...
@@ -180,6 +182,7 @@ type Proxier struct {
hostname
string
hostname
string
nodeIP
net
.
IP
nodeIP
net
.
IP
portMapper
portOpener
portMapper
portOpener
recorder
record
.
EventRecorder
}
}
type
localPort
struct
{
type
localPort
struct
{
...
@@ -219,7 +222,18 @@ var _ proxy.ProxyProvider = &Proxier{}
...
@@ -219,7 +222,18 @@ var _ proxy.ProxyProvider = &Proxier{}
// An error will be returned if iptables fails to update or acquire the initial lock.
// An error will be returned if iptables fails to update or acquire the initial lock.
// Once a proxier is created, it will keep iptables up to date in the background and
// Once a proxier is created, it will keep iptables up to date in the background and
// will not terminate if a particular iptables call fails.
// will not terminate if a particular iptables call fails.
func
NewProxier
(
ipt
utiliptables
.
Interface
,
sysctl
utilsysctl
.
Interface
,
exec
utilexec
.
Interface
,
syncPeriod
time
.
Duration
,
minSyncPeriod
time
.
Duration
,
masqueradeAll
bool
,
masqueradeBit
int
,
clusterCIDR
string
,
hostname
string
,
nodeIP
net
.
IP
)
(
*
Proxier
,
error
)
{
func
NewProxier
(
ipt
utiliptables
.
Interface
,
sysctl
utilsysctl
.
Interface
,
exec
utilexec
.
Interface
,
syncPeriod
time
.
Duration
,
minSyncPeriod
time
.
Duration
,
masqueradeAll
bool
,
masqueradeBit
int
,
clusterCIDR
string
,
hostname
string
,
nodeIP
net
.
IP
,
recorder
record
.
EventRecorder
,
)
(
*
Proxier
,
error
)
{
// check valid user input
// check valid user input
if
minSyncPeriod
>
syncPeriod
{
if
minSyncPeriod
>
syncPeriod
{
return
nil
,
fmt
.
Errorf
(
"min-sync (%v) must be < sync(%v)"
,
minSyncPeriod
,
syncPeriod
)
return
nil
,
fmt
.
Errorf
(
"min-sync (%v) must be < sync(%v)"
,
minSyncPeriod
,
syncPeriod
)
...
@@ -278,6 +292,7 @@ func NewProxier(ipt utiliptables.Interface, sysctl utilsysctl.Interface, exec ut
...
@@ -278,6 +292,7 @@ func NewProxier(ipt utiliptables.Interface, sysctl utilsysctl.Interface, exec ut
hostname
:
hostname
,
hostname
:
hostname
,
nodeIP
:
nodeIP
,
nodeIP
:
nodeIP
,
portMapper
:
&
listenPortOpener
{},
portMapper
:
&
listenPortOpener
{},
recorder
:
recorder
,
},
nil
},
nil
}
}
...
@@ -989,7 +1004,16 @@ func (proxier *Proxier) syncProxyRules() {
...
@@ -989,7 +1004,16 @@ func (proxier *Proxier) syncProxyRules() {
}
else
{
}
else
{
socket
,
err
:=
proxier
.
portMapper
.
OpenLocalPort
(
&
lp
)
socket
,
err
:=
proxier
.
portMapper
.
OpenLocalPort
(
&
lp
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"can't open %s, skipping this externalIP: %v"
,
lp
.
String
(),
err
)
msg
:=
fmt
.
Sprintf
(
"can't open %s, skipping this externalIP: %v"
,
lp
.
String
(),
err
)
proxier
.
recorder
.
Eventf
(
&
v1
.
ObjectReference
{
Kind
:
"Node"
,
Name
:
proxier
.
hostname
,
UID
:
types
.
UID
(
proxier
.
hostname
),
Namespace
:
""
,
},
api
.
EventTypeWarning
,
err
.
Error
(),
msg
)
glog
.
Error
(
msg
)
continue
continue
}
}
replacementPortsMap
[
lp
]
=
socket
replacementPortsMap
[
lp
]
=
socket
...
...
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