Commit 5728c16a authored by kaiyou's avatar kaiyou
Browse files

Send the subnetfile to the CNI

parent fcd7d1f6
Pipeline #727 failed with stage
in 41 seconds
......@@ -10,6 +10,7 @@ import (
"time"
"github.com/rancher/k3s/pkg/agent/util"
"github.com/rancher/k3s/pkg/agent/templates"
"github.com/rancher/k3s/pkg/daemons/config"
"github.com/sirupsen/logrus"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
......@@ -22,7 +23,8 @@ const (
"cniVersion":"0.3.1",
"plugins":[
{
"type":"flannel",
"type":"flannel",
"subnetFile": "{{ .NodeConfig.FlannelSubnetFile }}"
"delegate":{
"hairpinMode":true,
"forceAddress":true,
......@@ -70,7 +72,7 @@ const (
)
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
}
......@@ -101,12 +103,16 @@ func Run(ctx context.Context, nodeConfig *config.Node, nodes v1.NodeInterface) e
return nil
}
func createCNIConf(dir string) error {
func createCNIConf(dir string, nodeConfig *config.Node) error {
parsedTemplate, err := templates.ParseTemplateFromConfig(cniConf, nodeConfig)
if err != nil {
return err
}
if dir == "" {
return nil
}
p := filepath.Join(dir, "10-flannel.conflist")
return util.WriteFile(p, cniConf)
return util.WriteFile(p, parsedTemplate)
}
func createFlannelConf(nodeConfig *config.Node) error {
......
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