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
2268e028
Commit
2268e028
authored
Mar 19, 2019
by
Stuart Wallace
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ability to override flannel interface
parent
af2fc722
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
29 additions
and
8 deletions
+29
-8
config.go
pkg/agent/config/config.go
+9
-0
flannel.go
pkg/agent/flannel/flannel.go
+10
-7
setup.go
pkg/agent/flannel/setup.go
+1
-1
agent.go
pkg/cli/cmds/agent.go
+7
-0
server.go
pkg/cli/cmds/server.go
+1
-0
types.go
pkg/daemons/config/types.go
+1
-0
No files found.
pkg/agent/config/config.go
View file @
2268e028
...
...
@@ -206,11 +206,20 @@ func get(envInfo *cmds.Agent) (*config.Node, error) {
return
nil
,
errors
.
Wrapf
(
err
,
"failed to find host-local"
)
}
var
flannelIface
*
sysnet
.
Interface
if
!
envInfo
.
NoFlannel
&&
len
(
envInfo
.
FlannelIface
)
>
0
{
flannelIface
,
err
=
sysnet
.
InterfaceByName
(
envInfo
.
FlannelIface
)
if
err
!=
nil
{
return
nil
,
errors
.
Wrapf
(
err
,
"unable to find interface"
)
}
}
nodeConfig
:=
&
config
.
Node
{
Docker
:
envInfo
.
Docker
,
NoFlannel
:
envInfo
.
NoFlannel
,
ContainerRuntimeEndpoint
:
envInfo
.
ContainerRuntimeEndpoint
,
}
nodeConfig
.
FlannelIface
=
flannelIface
nodeConfig
.
LocalAddress
=
localAddress
(
controlConfig
)
nodeConfig
.
Images
=
filepath
.
Join
(
envInfo
.
DataDir
,
"images"
)
nodeConfig
.
AgentConfig
.
NodeIP
=
nodeIP
...
...
pkg/agent/flannel/flannel.go
View file @
2268e028
...
...
@@ -36,8 +36,8 @@ const (
subnetFile
=
"/run/flannel/subnet.env"
)
func
flannel
(
ctx
context
.
Context
,
flannelConf
,
kubeConfigFile
string
)
error
{
extIface
,
err
:=
LookupExtIface
()
func
flannel
(
ctx
context
.
Context
,
flannel
Iface
*
net
.
Interface
,
flannel
Conf
,
kubeConfigFile
string
)
error
{
extIface
,
err
:=
LookupExtIface
(
flannelIface
)
if
err
!=
nil
{
return
err
}
...
...
@@ -81,14 +81,17 @@ func flannel(ctx context.Context, flannelConf, kubeConfigFile string) error {
return
nil
}
func
LookupExtIface
()
(
*
backend
.
ExternalInterface
,
error
)
{
var
iface
*
net
.
Interface
func
LookupExtIface
(
iface
*
net
.
Interface
)
(
*
backend
.
ExternalInterface
,
error
)
{
var
ifaceAddr
net
.
IP
var
err
error
log
.
Info
(
"Determining IP address of default interface"
)
if
iface
,
err
=
ip
.
GetDefaultGatewayIface
();
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to get default interface: %s"
,
err
)
if
iface
==
nil
{
log
.
Info
(
"Determining IP address of default interface"
)
if
iface
,
err
=
ip
.
GetDefaultGatewayIface
();
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to get default interface: %s"
,
err
)
}
}
else
{
log
.
Info
(
"Determining IP address of specified interface: "
,
iface
.
Name
)
}
ifaceAddr
,
err
=
ip
.
GetIfaceIP4Addr
(
iface
)
...
...
pkg/agent/flannel/setup.go
View file @
2268e028
...
...
@@ -79,7 +79,7 @@ func Run(ctx context.Context, config *config.Node) error {
}
go
func
()
{
err
:=
flannel
(
ctx
,
config
.
FlannelConf
,
config
.
AgentConfig
.
KubeConfig
)
err
:=
flannel
(
ctx
,
config
.
Flannel
Iface
,
config
.
Flannel
Conf
,
config
.
AgentConfig
.
KubeConfig
)
logrus
.
Fatalf
(
"flannel exited: %v"
,
err
)
}()
...
...
pkg/cli/cmds/agent.go
View file @
2268e028
...
...
@@ -19,6 +19,7 @@ type Agent struct {
Docker
bool
ContainerRuntimeEndpoint
string
NoFlannel
bool
FlannelIface
string
Debug
bool
Rootless
bool
AgentShared
...
...
@@ -54,6 +55,11 @@ var (
Usage
:
"(agent) Disable embedded flannel"
,
Destination
:
&
AgentConfig
.
NoFlannel
,
}
FlannelIfaceFlag
=
cli
.
StringFlag
{
Name
:
"flannel-iface"
,
Usage
:
"(agent) Override default flannel interface"
,
Destination
:
&
AgentConfig
.
FlannelIface
,
}
CRIEndpointFlag
=
cli
.
StringFlag
{
Name
:
"container-runtime-endpoint"
,
Usage
:
"(agent) Disable embedded containerd and use alternative CRI implementation"
,
...
...
@@ -121,6 +127,7 @@ func NewAgentCommand(action func(ctx *cli.Context) error) cli.Command {
},
DockerFlag
,
FlannelFlag
,
FlannelIfaceFlag
,
NodeNameFlag
,
NodeIPFlag
,
CRIEndpointFlag
,
...
...
pkg/cli/cmds/server.go
View file @
2268e028
...
...
@@ -134,6 +134,7 @@ func NewServerCommand(action func(*cli.Context) error) cli.Command {
NodeNameFlag
,
DockerFlag
,
FlannelFlag
,
FlannelIfaceFlag
,
CRIEndpointFlag
,
ResolvConfFlag
,
ExtraKubeletArgs
,
...
...
pkg/daemons/config/types.go
View file @
2268e028
...
...
@@ -15,6 +15,7 @@ type Node struct {
ContainerRuntimeEndpoint
string
NoFlannel
bool
FlannelConf
string
FlannelIface
*
net
.
Interface
LocalAddress
string
Containerd
Containerd
Images
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