diff --git a/pkg/agent/config/config.go b/pkg/agent/config/config.go index b20afecc563e..20f0c04f7eab 100644 --- a/pkg/agent/config/config.go +++ b/pkg/agent/config/config.go @@ -470,9 +470,9 @@ func get(envInfo *cmds.Agent, proxy proxy.Proxy) (*config.Node, error) { } if envInfo.FlannelConf == "" { - nodeConfig.FlannelConf = filepath.Join(envInfo.DataDir, "agent", "etc", "flannel", "net-conf.json") + nodeConfig.FlannelConfFile = filepath.Join(envInfo.DataDir, "agent", "etc", "flannel", "net-conf.json") } else { - nodeConfig.FlannelConf = envInfo.FlannelConf + nodeConfig.FlannelConfFile = envInfo.FlannelConf nodeConfig.FlannelConfOverride = true } nodeConfig.AgentConfig.CNIBinDir = filepath.Dir(hostLocal) diff --git a/pkg/agent/flannel/setup.go b/pkg/agent/flannel/setup.go index 9ed7f12a0323..28c0b718b2c4 100644 --- a/pkg/agent/flannel/setup.go +++ b/pkg/agent/flannel/setup.go @@ -78,6 +78,7 @@ func Prepare(ctx context.Context, nodeConfig *config.Node) error { } func Run(ctx context.Context, nodeConfig *config.Node, nodes v1.NodeInterface) error { + logrus.Infof("Starting flannel with backend %s", nodeConfig.FlannelBackend) nodeName := nodeConfig.AgentConfig.NodeName for { @@ -92,10 +93,10 @@ func Run(ctx context.Context, nodeConfig *config.Node, nodes v1.NodeInterface) e } time.Sleep(2 * time.Second) } - logrus.Info("Node CIDR assigned for: " + nodeName) + logrus.Info("Flannel found PodCIDR assigned for: " + nodeName) go func() { - err := flannel(ctx, nodeConfig.FlannelIface, nodeConfig.FlannelConf, nodeConfig.AgentConfig.KubeConfigKubelet) + err := flannel(ctx, nodeConfig.FlannelIface, nodeConfig.FlannelConfFile, nodeConfig.AgentConfig.KubeConfigKubelet) logrus.Fatalf("flannel exited: %v", err) }() @@ -103,6 +104,7 @@ func Run(ctx context.Context, nodeConfig *config.Node, nodes v1.NodeInterface) e } func createCNIConf(dir string) error { + logrus.Debugf("Creating the CNI conf in directory %s", dir) if dir == "" { return nil } @@ -111,11 +113,12 @@ func createCNIConf(dir string) error { } func createFlannelConf(nodeConfig *config.Node) error { - if nodeConfig.FlannelConf == "" { - return nil + logrus.Debugf("Creating the flannel configuration for backend %s in file %s", nodeConfig.FlannelBackend, nodeConfig.FlannelConfFile) + if nodeConfig.FlannelConfFile == "" { + return fmt.Errorf("Flannel configuration not defined") } if nodeConfig.FlannelConfOverride { - logrus.Infof("Using custom flannel conf defined at %s", nodeConfig.FlannelConf) + logrus.Infof("Using custom flannel conf defined at %s", nodeConfig.FlannelConfFile) return nil } confJSON := strings.Replace(flannelConf, "%CIDR%", nodeConfig.AgentConfig.ClusterCIDR.String(), -1) @@ -139,7 +142,8 @@ func createFlannelConf(nodeConfig *config.Node) error { } confJSON = strings.Replace(confJSON, "%backend%", backendConf, -1) - return util.WriteFile(nodeConfig.FlannelConf, confJSON) + logrus.Debugf("The flannel configuration is %s", confJSON) + return util.WriteFile(nodeConfig.FlannelConfFile, confJSON) } func setupStrongSwan(nodeConfig *config.Node) error { diff --git a/pkg/daemons/config/types.go b/pkg/daemons/config/types.go index 179cbc5ad554..ced8614d4658 100644 --- a/pkg/daemons/config/types.go +++ b/pkg/daemons/config/types.go @@ -31,7 +31,7 @@ type Node struct { NoFlannel bool SELinux bool FlannelBackend string - FlannelConf string + FlannelConfFile string FlannelConfOverride bool FlannelIface *net.Interface Containerd Containerd