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
a9123de9
Commit
a9123de9
authored
Sep 30, 2016
by
Steve Leon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moving validateNodeIP to kubelet_node_status.go
parent
6efa1172
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
39 deletions
+41
-39
kubelet.go
pkg/kubelet/kubelet.go
+0
-6
kubelet_network.go
pkg/kubelet/kubelet_network.go
+0
-33
kubelet_node_status.go
pkg/kubelet/kubelet_node_status.go
+41
-0
No files found.
pkg/kubelet/kubelet.go
View file @
a9123de9
...
@@ -495,12 +495,6 @@ func NewMainKubelet(kubeCfg *componentconfig.KubeletConfiguration, kubeDeps *Kub
...
@@ -495,12 +495,6 @@ func NewMainKubelet(kubeCfg *componentconfig.KubeletConfiguration, kubeDeps *Kub
klet
.
flannelHelper
=
NewFlannelHelper
()
klet
.
flannelHelper
=
NewFlannelHelper
()
glog
.
Infof
(
"Flannel is in charge of podCIDR and overlay networking."
)
glog
.
Infof
(
"Flannel is in charge of podCIDR and overlay networking."
)
}
}
if
klet
.
nodeIP
!=
nil
{
if
err
:=
klet
.
validateNodeIP
();
err
!=
nil
{
return
nil
,
err
}
glog
.
Infof
(
"Using node IP: %q"
,
klet
.
nodeIP
.
String
())
}
if
mode
,
err
:=
effectiveHairpinMode
(
componentconfig
.
HairpinMode
(
kubeCfg
.
HairpinMode
),
kubeCfg
.
ContainerRuntime
,
kubeCfg
.
ConfigureCBR0
,
kubeCfg
.
NetworkPluginName
);
err
!=
nil
{
if
mode
,
err
:=
effectiveHairpinMode
(
componentconfig
.
HairpinMode
(
kubeCfg
.
HairpinMode
),
kubeCfg
.
ContainerRuntime
,
kubeCfg
.
ConfigureCBR0
,
kubeCfg
.
NetworkPluginName
);
err
!=
nil
{
// This is a non-recoverable error. Returning it up the callstack will just
// This is a non-recoverable error. Returning it up the callstack will just
...
...
pkg/kubelet/kubelet_network.go
View file @
a9123de9
...
@@ -81,39 +81,6 @@ func effectiveHairpinMode(hairpinMode componentconfig.HairpinMode, containerRunt
...
@@ -81,39 +81,6 @@ func effectiveHairpinMode(hairpinMode componentconfig.HairpinMode, containerRunt
return
hairpinMode
,
nil
return
hairpinMode
,
nil
}
}
// Validate given node IP belongs to the current host
func
(
kl
*
Kubelet
)
validateNodeIP
()
error
{
if
kl
.
nodeIP
==
nil
{
return
nil
}
// Honor IP limitations set in setNodeStatus()
if
kl
.
nodeIP
.
IsLoopback
()
{
return
fmt
.
Errorf
(
"nodeIP can't be loopback address"
)
}
if
kl
.
nodeIP
.
To4
()
==
nil
{
return
fmt
.
Errorf
(
"nodeIP must be IPv4 address"
)
}
addrs
,
err
:=
net
.
InterfaceAddrs
()
if
err
!=
nil
{
return
err
}
for
_
,
addr
:=
range
addrs
{
var
ip
net
.
IP
switch
v
:=
addr
.
(
type
)
{
case
*
net
.
IPNet
:
ip
=
v
.
IP
case
*
net
.
IPAddr
:
ip
=
v
.
IP
}
if
ip
!=
nil
&&
ip
.
Equal
(
kl
.
nodeIP
)
{
return
nil
}
}
return
fmt
.
Errorf
(
"Node IP: %q not found in the host's network interfaces"
,
kl
.
nodeIP
.
String
())
}
// providerRequiresNetworkingConfiguration returns whether the cloud provider
// providerRequiresNetworkingConfiguration returns whether the cloud provider
// requires special networking configuration.
// requires special networking configuration.
func
(
kl
*
Kubelet
)
providerRequiresNetworkingConfiguration
()
bool
{
func
(
kl
*
Kubelet
)
providerRequiresNetworkingConfiguration
()
bool
{
...
...
pkg/kubelet/kubelet_node_status.go
View file @
a9123de9
...
@@ -359,6 +359,14 @@ func (kl *Kubelet) recordNodeStatusEvent(eventtype, event string) {
...
@@ -359,6 +359,14 @@ func (kl *Kubelet) recordNodeStatusEvent(eventtype, event string) {
// Set IP addresses for the node.
// Set IP addresses for the node.
func
(
kl
*
Kubelet
)
setNodeAddress
(
node
*
api
.
Node
)
error
{
func
(
kl
*
Kubelet
)
setNodeAddress
(
node
*
api
.
Node
)
error
{
if
kl
.
nodeIP
!=
nil
{
if
err
:=
kl
.
validateNodeIP
();
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to validate nodeIP: %v"
,
err
)
}
glog
.
V
(
2
)
.
Infof
(
"Using node IP: %q"
,
kl
.
nodeIP
.
String
())
}
if
kl
.
cloud
!=
nil
{
if
kl
.
cloud
!=
nil
{
instances
,
ok
:=
kl
.
cloud
.
Instances
()
instances
,
ok
:=
kl
.
cloud
.
Instances
()
if
!
ok
{
if
!
ok
{
...
@@ -861,3 +869,36 @@ func SetNodeStatus(f func(*api.Node) error) Option {
...
@@ -861,3 +869,36 @@ func SetNodeStatus(f func(*api.Node) error) Option {
k
.
setNodeStatusFuncs
=
append
(
k
.
setNodeStatusFuncs
,
f
)
k
.
setNodeStatusFuncs
=
append
(
k
.
setNodeStatusFuncs
,
f
)
}
}
}
}
// Validate given node IP belongs to the current host
func
(
kl
*
Kubelet
)
validateNodeIP
()
error
{
if
kl
.
nodeIP
==
nil
{
return
nil
}
// Honor IP limitations set in setNodeStatus()
if
kl
.
nodeIP
.
IsLoopback
()
{
return
fmt
.
Errorf
(
"nodeIP can't be loopback address"
)
}
if
kl
.
nodeIP
.
To4
()
==
nil
{
return
fmt
.
Errorf
(
"nodeIP must be IPv4 address"
)
}
addrs
,
err
:=
net
.
InterfaceAddrs
()
if
err
!=
nil
{
return
err
}
for
_
,
addr
:=
range
addrs
{
var
ip
net
.
IP
switch
v
:=
addr
.
(
type
)
{
case
*
net
.
IPNet
:
ip
=
v
.
IP
case
*
net
.
IPAddr
:
ip
=
v
.
IP
}
if
ip
!=
nil
&&
ip
.
Equal
(
kl
.
nodeIP
)
{
return
nil
}
}
return
fmt
.
Errorf
(
"Node IP: %q not found in the host's network interfaces"
,
kl
.
nodeIP
.
String
())
}
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