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) { ...@@ -362,7 +362,12 @@ func get(envInfo *cmds.Agent) (*config.Node, error) {
nodeConfig.ServerAddress = serverURLParsed.Host nodeConfig.ServerAddress = serverURLParsed.Host
nodeConfig.Certificate = servingCert nodeConfig.Certificate = servingCert
if !nodeConfig.NoFlannel { 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.CNIBinDir = filepath.Dir(hostLocal)
nodeConfig.AgentConfig.CNIConfDir = filepath.Join(envInfo.DataDir, "etc/cni/net.d") nodeConfig.AgentConfig.CNIConfDir = filepath.Join(envInfo.DataDir, "etc/cni/net.d")
} }
......
...@@ -98,6 +98,10 @@ func createFlannelConf(config *config.Node) error { ...@@ -98,6 +98,10 @@ func createFlannelConf(config *config.Node) error {
if config.FlannelConf == "" { if config.FlannelConf == "" {
return nil return nil
} }
if config.FlannelConfOverride {
logrus.Infof("Using custom flannel conf defined at %s", config.FlannelConf)
return nil
}
return util.WriteFile(config.FlannelConf, return util.WriteFile(config.FlannelConf,
strings.Replace(netJSON, "%CIDR%", config.AgentConfig.ClusterCIDR.String(), -1)) strings.Replace(netJSON, "%CIDR%", config.AgentConfig.ClusterCIDR.String(), -1))
} }
...@@ -22,6 +22,7 @@ type Agent struct { ...@@ -22,6 +22,7 @@ type Agent struct {
ContainerRuntimeEndpoint string ContainerRuntimeEndpoint string
NoFlannel bool NoFlannel bool
FlannelIface string FlannelIface string
FlannelConf string
Debug bool Debug bool
Rootless bool Rootless bool
AgentShared AgentShared
...@@ -64,6 +65,11 @@ var ( ...@@ -64,6 +65,11 @@ var (
Usage: "(agent) Override default flannel interface", Usage: "(agent) Override default flannel interface",
Destination: &AgentConfig.FlannelIface, Destination: &AgentConfig.FlannelIface,
} }
FlannelConfFlag = cli.StringFlag{
Name: "flannel-conf",
Usage: "(agent) Override default flannel config file",
Destination: &AgentConfig.FlannelConf,
}
CRIEndpointFlag = cli.StringFlag{ CRIEndpointFlag = cli.StringFlag{
Name: "container-runtime-endpoint", Name: "container-runtime-endpoint",
Usage: "(agent) Disable embedded containerd and use alternative CRI implementation", Usage: "(agent) Disable embedded containerd and use alternative CRI implementation",
...@@ -151,6 +157,7 @@ func NewAgentCommand(action func(ctx *cli.Context) error) cli.Command { ...@@ -151,6 +157,7 @@ func NewAgentCommand(action func(ctx *cli.Context) error) cli.Command {
DockerFlag, DockerFlag,
FlannelFlag, FlannelFlag,
FlannelIfaceFlag, FlannelIfaceFlag,
FlannelConfFlag,
NodeNameFlag, NodeNameFlag,
NodeIPFlag, NodeIPFlag,
CRIEndpointFlag, CRIEndpointFlag,
......
...@@ -194,6 +194,7 @@ func NewServerCommand(action func(*cli.Context) error) cli.Command { ...@@ -194,6 +194,7 @@ func NewServerCommand(action func(*cli.Context) error) cli.Command {
DockerFlag, DockerFlag,
FlannelFlag, FlannelFlag,
FlannelIfaceFlag, FlannelIfaceFlag,
FlannelConfFlag,
CRIEndpointFlag, CRIEndpointFlag,
PauseImageFlag, PauseImageFlag,
ResolvConfFlag, ResolvConfFlag,
......
...@@ -18,6 +18,7 @@ type Node struct { ...@@ -18,6 +18,7 @@ type Node struct {
ContainerRuntimeEndpoint string ContainerRuntimeEndpoint string
NoFlannel bool NoFlannel bool
FlannelConf string FlannelConf string
FlannelConfOverride bool
FlannelIface *net.Interface FlannelIface *net.Interface
Containerd Containerd Containerd Containerd
Images string 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