Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add self-defined template configure file for embedded flannel #1531

Closed
Encore222 opened this issue Mar 13, 2020 · 3 comments
Closed

Add self-defined template configure file for embedded flannel #1531

Encore222 opened this issue Mar 13, 2020 · 3 comments
Labels
kind/enhancement An improvement to existing functionality
Milestone

Comments

@Encore222
Copy link

Encore222 commented Mar 13, 2020

Is your feature request related to a problem? Please describe.
I wanna set flannel to vxlan backend and directrouting. And I also wanna the "network" field in flannel conf is auto-generated by k3s according to its cluster cidr. But in fact if I go to set vxlan backend and directrouting, the only way is to set --flannel-conf in k3s to a self-defined conf, and then the "network" field is also sel-defined, too. Since on a productive env, to define every agent's ip range is an unfriendly and uneasy work, it's more reasonable to make a self-defined template of flannel conf to instantiate a real conf by args of k3s agent.

I got this by reading the source code in pkg/agent/flannel/setup.go
`
func createFlannelConf(nodeConfig *config.Node) error {
if nodeConfig.FlannelConf == "" {
return nil
}
if nodeConfig.FlannelConfOverride {
logrus.Infof("Using custom flannel conf defined at %s", nodeConfig.FlannelConf)
return nil
}
confJSON := strings.Replace(flannelConf, "%CIDR%", nodeConfig.AgentConfig.ClusterCIDR.String(), -1)

var backendConf string

switch nodeConfig.FlannelBackend {
case config.FlannelBackendVXLAN:
	backendConf = vxlanBackend
case config.FlannelBackendHostGW:
	backendConf = hostGWBackend
case config.FlannelBackendIPSEC:
	backendConf = strings.Replace(ipsecBackend, "%psk%", nodeConfig.AgentConfig.IPSECPSK, -1)
	if err := setupStrongSwan(nodeConfig); err != nil {
		return err
	}
case config.FlannelBackendWireguard:
	backendConf = wireguardBackend
default:
	return fmt.Errorf("Cannot configure unknown flannel backend '%s'", nodeConfig.FlannelBackend)
}
confJSON = strings.Replace(confJSON, "%backend%", backendConf, -1)

return util.WriteFile(nodeConfig.FlannelConf, confJSON)

}
`

Describe the solution you'd like
We can add an additional parameter to k3s agent like '--flannel-conf-tpl' to set a template of flannel conf. And render a real conf for embedded flannel.

Describe alternatives you've considered

  1. Add a new parameter as above described. (can extend to other field in flannel conf)
  2. Let driectrouting be a k3s' parameter passed by user. (simple and direct, but limit)
  3. Reuse the '--flannel-conf' to set a template file, and rander it no matter what it is, a normal file or a template file. Then generate a new conf for the embedded flannel. (maybe lead to confusion)
@Encore222 Encore222 changed the title Add self-defined template configure file of flannel Add self-defined template configure file for embedded flannel Mar 13, 2020
@davidnuzik davidnuzik added [zube]: To Triage kind/enhancement An improvement to existing functionality labels Mar 13, 2020
@davidnuzik davidnuzik added this to the v1.x - Backlog milestone Mar 13, 2020
@Encore222
Copy link
Author

@davidnuzik Do I need to commit my code?

Encore222 added a commit to Encore222/k3s that referenced this issue Mar 17, 2020
-Add an additional parameter to k3s agent like '--flannel-conf-tpl' to set a template of flannel conf.
-Use that to render a real conf for embedded flannel.
Issue k3s-io#1531
Encore222 added a commit to Encore222/k3s that referenced this issue Mar 17, 2020
-Add an additional parameter to k3s agent like '--flannel-conf-tpl' to set a template of flannel conf.
-Use that to render a real conf for embedded flannel.
Issue k3s-io#1531
@davidnuzik davidnuzik modified the milestones: v1.19 - Backlog, Backlog Oct 6, 2020
@caroline-suse-rancher caroline-suse-rancher moved this to To Be Sorted in K3s Backlog Nov 21, 2022
@caroline-suse-rancher caroline-suse-rancher moved this from To Be Sorted to Networking in K3s Backlog Nov 29, 2022
@rbrtbnfgl
Copy link
Contributor

Do we still need it? It feels like another flannel flag.

@caroline-suse-rancher
Copy link
Contributor

Closing due to age, and potential redundancy - can reopen if it becomes more important.

@github-project-automation github-project-automation bot moved this from Backlog to Done Issue in K3s Development Feb 21, 2023
@github-project-automation github-project-automation bot moved this from Networking to Closed in K3s Backlog Feb 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement An improvement to existing functionality
Projects
Status: Closed
Archived in project
Development

No branches or pull requests

4 participants