Commit 3cd807a6 authored by Erik Wilson's avatar Erik Wilson

Add --flannel-conf flag

parent 73d31f5b
......@@ -362,7 +362,12 @@ func get(envInfo *cmds.Agent) (*config.Node, error) {
nodeConfig.ServerAddress = serverURLParsed.Host
nodeConfig.Certificate = servingCert
if !nodeConfig.NoFlannel {
nodeConfig.FlannelConf = filepath.Join(envInfo.DataDir, "etc/flannel/net-conf.json")
if envInfo.FlannelConf == "" {
nodeConfig.FlannelConf = filepath.Join(envInfo.DataDir, "etc/flannel/net-conf.json")
} else {
nodeConfig.FlannelConf = envInfo.FlannelConf
nodeConfig.FlannelConfOverride = true
}
nodeConfig.AgentConfig.CNIBinDir = filepath.Dir(hostLocal)
nodeConfig.AgentConfig.CNIConfDir = filepath.Join(envInfo.DataDir, "etc/cni/net.d")
}
......
......@@ -98,6 +98,10 @@ func createFlannelConf(config *config.Node) error {
if config.FlannelConf == "" {
return nil
}
if config.FlannelConfOverride {
logrus.Infof("Using custom flannel conf defined at %s", config.FlannelConf)
return nil
}
return util.WriteFile(config.FlannelConf,
strings.Replace(netJSON, "%CIDR%", config.AgentConfig.ClusterCIDR.String(), -1))
}
......@@ -22,6 +22,7 @@ type Agent struct {
ContainerRuntimeEndpoint string
NoFlannel bool
FlannelIface string
FlannelConf string
Debug bool
Rootless bool
AgentShared
......@@ -64,6 +65,11 @@ var (
Usage: "(agent) Override default flannel interface",
Destination: &AgentConfig.FlannelIface,
}
FlannelConfFlag = cli.StringFlag{
Name: "flannel-conf",
Usage: "(agent) Override default flannel config file",
Destination: &AgentConfig.FlannelConf,
}
CRIEndpointFlag = cli.StringFlag{
Name: "container-runtime-endpoint",
Usage: "(agent) Disable embedded containerd and use alternative CRI implementation",
......@@ -151,6 +157,7 @@ func NewAgentCommand(action func(ctx *cli.Context) error) cli.Command {
DockerFlag,
FlannelFlag,
FlannelIfaceFlag,
FlannelConfFlag,
NodeNameFlag,
NodeIPFlag,
CRIEndpointFlag,
......
......@@ -194,6 +194,7 @@ func NewServerCommand(action func(*cli.Context) error) cli.Command {
DockerFlag,
FlannelFlag,
FlannelIfaceFlag,
FlannelConfFlag,
CRIEndpointFlag,
PauseImageFlag,
ResolvConfFlag,
......
......@@ -18,6 +18,7 @@ type Node struct {
ContainerRuntimeEndpoint string
NoFlannel bool
FlannelConf string
FlannelConfOverride bool
FlannelIface *net.Interface
Containerd Containerd
Images string
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment