Skip to content

Commit

Permalink
main.go: add the "net-config-path" flag
Browse files Browse the repository at this point in the history
Add the flag "net-config-path" that holds the path
for the network configuration.

Set the default value to "/etc/kube-flannel/net-conf.json".

Signed-off-by: Lubomir I. Ivanov <lubomirivanov@vmware.com>
  • Loading branch information
neolit123 committed May 15, 2019
1 parent ba49cd4 commit aac870e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions Documentation/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ The following configuration illustrates the use of most options with `udp` backe
--iface-regex="": regex expression to match the first interface to use (IP or name) for inter-host communication. If unspecified, will default to the interface for the default route on the machine. This can be specified multiple times to check each regex in order. Returns the first match found. This option is superseded by the iface option and will only be used if nothing matches any option specified in the iface options.
--iptables-resync=5: resync period for iptables rules, in seconds. Defaults to 5 seconds, if you see a large amount of contention for the iptables lock increasing this will probably help.
--subnet-file=/run/flannel/subnet.env: filename where env variables (subnet and MTU values) will be written to.
--net-config-path=/etc/kube-flannel/net-conf.json: path to the network configuration file to use
--subnet-lease-renew-margin=60: subnet lease renewal margin, in minutes.
--ip-masq=false: setup IP masquerade for traffic destined for outside the flannel network. Flannel assumes that the default policy is ACCEPT in the NAT POSTROUTING chain.
-v=0: log level for V logs. Set to 1 to see messages related to data path.
Expand Down
6 changes: 4 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ type CmdLineOpts struct {
charonViciUri string
iptablesResyncSeconds int
iptablesForwardRules bool
netConfPath string
}

var (
Expand Down Expand Up @@ -130,6 +131,7 @@ func init() {
flannelFlags.IntVar(&opts.healthzPort, "healthz-port", 0, "the port for healthz server to listen(0 to disable)")
flannelFlags.IntVar(&opts.iptablesResyncSeconds, "iptables-resync", 5, "resync period for iptables rules, in seconds")
flannelFlags.BoolVar(&opts.iptablesForwardRules, "iptables-forward-rules", true, "add default accept rules to FORWARD chain in iptables")
flannelFlags.StringVar(&opts.netConfPath, "net-config-path", "/etc/kube-flannel/net-conf.json", "path to the network configuration file")

// glog will log to tmp files by default. override so all entries
// can flow into journald (if running under systemd)
Expand Down Expand Up @@ -159,7 +161,7 @@ func usage() {

func newSubnetManager() (subnet.Manager, error) {
if opts.kubeSubnetMgr {
return kube.NewSubnetManager(opts.kubeApiUrl, opts.kubeConfigFile, opts.kubeAnnotationPrefix)
return kube.NewSubnetManager(opts.kubeApiUrl, opts.kubeConfigFile, opts.kubeAnnotationPrefix, opts.netConfPath)
}

cfg := &etcdv2.EtcdConfig{
Expand Down Expand Up @@ -349,7 +351,7 @@ func recycleIPTables(nw ip.IP4Net, lease *subnet.Lease) error {
prevNetwork := ReadCIDRFromSubnetFile(opts.subnetFile, "FLANNEL_NETWORK")
prevSubnet := ReadCIDRFromSubnetFile(opts.subnetFile, "FLANNEL_SUBNET")
// recycle iptables rules only when network configured or subnet leased is not equal to current one.
if prevNetwork != nw && prevSubnet != lease.Subnet{
if prevNetwork != nw && prevSubnet != lease.Subnet {
log.Infof("Current network or subnet (%v, %v) is not equal to previous one (%v, %v), trying to recycle old iptables rules", nw, lease.Subnet, prevNetwork, prevSubnet)
lease := &subnet.Lease{
Subnet: prevSubnet,
Expand Down
4 changes: 1 addition & 3 deletions subnet/kube/kube.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ var (
const (
resyncPeriod = 5 * time.Minute
nodeControllerSyncTimeout = 10 * time.Minute

netConfPath = "/etc/kube-flannel/net-conf.json"
)

type kubeSubnetManager struct {
Expand All @@ -64,7 +62,7 @@ type kubeSubnetManager struct {
events chan subnet.Event
}

func NewSubnetManager(apiUrl, kubeconfig, prefix string) (subnet.Manager, error) {
func NewSubnetManager(apiUrl, kubeconfig, prefix, netConfPath string) (subnet.Manager, error) {

var cfg *rest.Config
var err error
Expand Down

0 comments on commit aac870e

Please sign in to comment.