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
c705d348
Commit
c705d348
authored
Jun 08, 2022
by
Manuel Buil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add FlannelConfCNI flag
Signed-off-by:
Manuel Buil
<
mbuil@suse.com
>
parent
c00f953e
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
30 additions
and
2 deletions
+30
-2
config.go
pkg/agent/config/config.go
+1
-0
setup.go
pkg/agent/flannel/setup.go
+7
-2
file.go
pkg/agent/util/file.go
+13
-0
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 @
c705d348
...
@@ -533,6 +533,7 @@ func get(ctx context.Context, envInfo *cmds.Agent, proxy proxy.Proxy) (*config.N
...
@@ -533,6 +533,7 @@ func get(ctx context.Context, envInfo *cmds.Agent, proxy proxy.Proxy) (*config.N
}
}
nodeConfig
.
AgentConfig
.
CNIBinDir
=
filepath
.
Dir
(
hostLocal
)
nodeConfig
.
AgentConfig
.
CNIBinDir
=
filepath
.
Dir
(
hostLocal
)
nodeConfig
.
AgentConfig
.
CNIConfDir
=
filepath
.
Join
(
envInfo
.
DataDir
,
"agent"
,
"etc"
,
"cni"
,
"net.d"
)
nodeConfig
.
AgentConfig
.
CNIConfDir
=
filepath
.
Join
(
envInfo
.
DataDir
,
"agent"
,
"etc"
,
"cni"
,
"net.d"
)
nodeConfig
.
AgentConfig
.
FlannelCniConfFile
=
envInfo
.
FlannelCniConfFile
}
}
if
nodeConfig
.
ContainerRuntimeEndpoint
==
""
{
if
nodeConfig
.
ContainerRuntimeEndpoint
==
""
{
...
...
pkg/agent/flannel/setup.go
View file @
c705d348
...
@@ -91,7 +91,7 @@ const (
...
@@ -91,7 +91,7 @@ const (
)
)
func
Prepare
(
ctx
context
.
Context
,
nodeConfig
*
config
.
Node
)
error
{
func
Prepare
(
ctx
context
.
Context
,
nodeConfig
*
config
.
Node
)
error
{
if
err
:=
createCNIConf
(
nodeConfig
.
AgentConfig
.
CNIConfDir
);
err
!=
nil
{
if
err
:=
createCNIConf
(
nodeConfig
.
AgentConfig
.
CNIConfDir
,
nodeConfig
);
err
!=
nil
{
return
err
return
err
}
}
...
@@ -146,12 +146,17 @@ func waitForPodCIDR(ctx context.Context, nodeName string, nodes typedcorev1.Node
...
@@ -146,12 +146,17 @@ func waitForPodCIDR(ctx context.Context, nodeName string, nodes typedcorev1.Node
return
nil
return
nil
}
}
func
createCNIConf
(
dir
string
)
error
{
func
createCNIConf
(
dir
string
,
nodeConfig
*
config
.
Node
)
error
{
logrus
.
Debugf
(
"Creating the CNI conf in directory %s"
,
dir
)
logrus
.
Debugf
(
"Creating the CNI conf in directory %s"
,
dir
)
if
dir
==
""
{
if
dir
==
""
{
return
nil
return
nil
}
}
p
:=
filepath
.
Join
(
dir
,
"10-flannel.conflist"
)
p
:=
filepath
.
Join
(
dir
,
"10-flannel.conflist"
)
if
nodeConfig
.
AgentConfig
.
FlannelCniConfFile
!=
""
{
logrus
.
Debugf
(
"Using %s as the flannel CNI conf"
,
nodeConfig
.
AgentConfig
.
FlannelCniConfFile
)
return
util
.
CopyFile
(
nodeConfig
.
AgentConfig
.
FlannelCniConfFile
,
p
)
}
return
util
.
WriteFile
(
p
,
cniConf
)
return
util
.
WriteFile
(
p
,
cniConf
)
}
}
...
...
pkg/agent/util/file.go
View file @
c705d348
...
@@ -16,3 +16,16 @@ func WriteFile(name string, content string) error {
...
@@ -16,3 +16,16 @@ func WriteFile(name string, content string) error {
}
}
return
nil
return
nil
}
}
func
CopyFile
(
sourceFile
string
,
destinationFile
string
)
error
{
os
.
MkdirAll
(
filepath
.
Dir
(
destinationFile
),
0755
)
input
,
err
:=
ioutil
.
ReadFile
(
sourceFile
)
if
err
!=
nil
{
return
errors
.
Wrapf
(
err
,
"copying %s to %s"
,
sourceFile
,
destinationFile
)
}
err
=
ioutil
.
WriteFile
(
destinationFile
,
input
,
0644
)
if
err
!=
nil
{
return
errors
.
Wrapf
(
err
,
"copying %s to %s"
,
sourceFile
,
destinationFile
)
}
return
nil
}
pkg/cli/cmds/agent.go
View file @
c705d348
...
@@ -31,6 +31,7 @@ type Agent struct {
...
@@ -31,6 +31,7 @@ type Agent struct {
NoFlannel
bool
NoFlannel
bool
FlannelIface
string
FlannelIface
string
FlannelConf
string
FlannelConf
string
FlannelCniConfFile
string
Debug
bool
Debug
bool
Rootless
bool
Rootless
bool
RootlessAlreadyUnshared
bool
RootlessAlreadyUnshared
bool
...
@@ -135,6 +136,11 @@ var (
...
@@ -135,6 +136,11 @@ var (
Usage
:
"(agent/networking) Override default flannel config file"
,
Usage
:
"(agent/networking) Override default flannel config file"
,
Destination
:
&
AgentConfig
.
FlannelConf
,
Destination
:
&
AgentConfig
.
FlannelConf
,
}
}
FlannelCniConfFileFlag
=
cli
.
StringFlag
{
Name
:
"flannel-cni-conf"
,
Usage
:
"(agent/networking) Override default flannel cni config file"
,
Destination
:
&
AgentConfig
.
FlannelCniConfFile
,
}
ResolvConfFlag
=
cli
.
StringFlag
{
ResolvConfFlag
=
cli
.
StringFlag
{
Name
:
"resolv-conf"
,
Name
:
"resolv-conf"
,
Usage
:
"(agent/networking) Kubelet resolv.conf file"
,
Usage
:
"(agent/networking) Kubelet resolv.conf file"
,
...
@@ -258,6 +264,7 @@ func NewAgentCommand(action func(ctx *cli.Context) error) cli.Command {
...
@@ -258,6 +264,7 @@ func NewAgentCommand(action func(ctx *cli.Context) error) cli.Command {
ResolvConfFlag
,
ResolvConfFlag
,
FlannelIfaceFlag
,
FlannelIfaceFlag
,
FlannelConfFlag
,
FlannelConfFlag
,
FlannelCniConfFileFlag
,
ExtraKubeletArgs
,
ExtraKubeletArgs
,
ExtraKubeProxyArgs
,
ExtraKubeProxyArgs
,
ProtectKernelDefaultsFlag
,
ProtectKernelDefaultsFlag
,
...
...
pkg/cli/cmds/server.go
View file @
c705d348
...
@@ -439,6 +439,7 @@ var ServerFlags = []cli.Flag{
...
@@ -439,6 +439,7 @@ var ServerFlags = []cli.Flag{
ResolvConfFlag
,
ResolvConfFlag
,
FlannelIfaceFlag
,
FlannelIfaceFlag
,
FlannelConfFlag
,
FlannelConfFlag
,
FlannelCniConfFileFlag
,
ExtraKubeletArgs
,
ExtraKubeletArgs
,
ExtraKubeProxyArgs
,
ExtraKubeProxyArgs
,
ProtectKernelDefaultsFlag
,
ProtectKernelDefaultsFlag
,
...
...
pkg/daemons/config/types.go
View file @
c705d348
...
@@ -101,6 +101,7 @@ type Agent struct {
...
@@ -101,6 +101,7 @@ type Agent struct {
ImageCredProvBinDir
string
ImageCredProvBinDir
string
ImageCredProvConfig
string
ImageCredProvConfig
string
IPSECPSK
string
IPSECPSK
string
FlannelCniConfFile
string
StrongSwanDir
string
StrongSwanDir
string
PrivateRegistry
string
PrivateRegistry
string
SystemDefaultRegistry
string
SystemDefaultRegistry
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