mirror of https://github.com/k3s-io/k3s
parent
b004f4d578
commit
05592ad015
|
@ -530,6 +530,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.Docker && nodeConfig.ContainerRuntimeEndpoint == "" {
|
if !nodeConfig.Docker && nodeConfig.ContainerRuntimeEndpoint == "" {
|
||||||
|
|
|
@ -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
|
||||||
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
@ -134,6 +135,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",
|
||||||
|
@ -259,6 +265,7 @@ func NewAgentCommand(action func(ctx *cli.Context) error) cli.Command {
|
||||||
ResolvConfFlag,
|
ResolvConfFlag,
|
||||||
FlannelIfaceFlag,
|
FlannelIfaceFlag,
|
||||||
FlannelConfFlag,
|
FlannelConfFlag,
|
||||||
|
FlannelCniConfFileFlag,
|
||||||
ExtraKubeletArgs,
|
ExtraKubeletArgs,
|
||||||
ExtraKubeProxyArgs,
|
ExtraKubeProxyArgs,
|
||||||
ProtectKernelDefaultsFlag,
|
ProtectKernelDefaultsFlag,
|
||||||
|
|
|
@ -439,6 +439,7 @@ var ServerFlags = []cli.Flag{
|
||||||
ResolvConfFlag,
|
ResolvConfFlag,
|
||||||
FlannelIfaceFlag,
|
FlannelIfaceFlag,
|
||||||
FlannelConfFlag,
|
FlannelConfFlag,
|
||||||
|
FlannelCniConfFileFlag,
|
||||||
ExtraKubeletArgs,
|
ExtraKubeletArgs,
|
||||||
ExtraKubeProxyArgs,
|
ExtraKubeProxyArgs,
|
||||||
ProtectKernelDefaultsFlag,
|
ProtectKernelDefaultsFlag,
|
||||||
|
|
|
@ -111,6 +111,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
|
||||||
|
|
Loading…
Reference in New Issue