diff --git a/pkg/cmd/main.go b/pkg/cmd/main.go index 9858efc7..56aa505c 100644 --- a/pkg/cmd/main.go +++ b/pkg/cmd/main.go @@ -81,6 +81,8 @@ var ( default interface will be used instead`) httpPort = flags.Int("http-port", 8080, `The HTTP port to use for health checks`) + + releaseVips = flags.Bool("release-vips", true, `add --release-vips to keepalived args`) ) func main() { @@ -132,7 +134,7 @@ func main() { } glog.Info("starting LVS configuration") - ipvsc := controller.NewIPVSController(kubeClient, *watchNamespace, *useUnicast, *configMapName, *vrid, *proxyMode, *iface, *httpPort) + ipvsc := controller.NewIPVSController(kubeClient, *watchNamespace, *useUnicast, *configMapName, *vrid, *proxyMode, *iface, *httpPort, *releaseVips) // If kube-proxy running in ipvs mode // Reset of IPVS lead to connection loss with API server diff --git a/pkg/controller/keepalived.go b/pkg/controller/keepalived.go index 9e93e5bc..1d5b316e 100644 --- a/pkg/controller/keepalived.go +++ b/pkg/controller/keepalived.go @@ -65,6 +65,7 @@ type keepalived struct { vrid int proxyMode bool notify string + releaseVips bool } // WriteCfg creates a new keepalived configuration file. @@ -141,11 +142,12 @@ func (k *keepalived) Start() { glog.V(2).Infof("chain %v already existed", iptablesChain) } - k.cmd = exec.Command("keepalived", - "--dont-fork", - "--log-console", - "--release-vips", - "--log-detail") + args := []string{"--dont-fork", "--log-console", "--log-detail"} + if k.releaseVips { + args = append(args, "--release-vips") + } + + k.cmd = exec.Command("keepalived", args...) k.cmd.Stdout = os.Stdout k.cmd.Stderr = os.Stderr diff --git a/pkg/controller/main.go b/pkg/controller/main.go index 4d49cc2f..2ab643f4 100644 --- a/pkg/controller/main.go +++ b/pkg/controller/main.go @@ -353,7 +353,7 @@ func (ipvsc *ipvsControllerController) Stop() error { } // NewIPVSController creates a new controller from the given config. -func NewIPVSController(kubeClient *kubernetes.Clientset, namespace string, useUnicast bool, configMapName string, vrid int, proxyMode bool, iface string, httpPort int) *ipvsControllerController { +func NewIPVSController(kubeClient *kubernetes.Clientset, namespace string, useUnicast bool, configMapName string, vrid int, proxyMode bool, iface string, httpPort int, releaseVips bool) *ipvsControllerController { ipvsc := ipvsControllerController{ client: kubeClient, reloadRateLimiter: flowcontrol.NewTokenBucketRateLimiter(0.5, 1), @@ -392,17 +392,18 @@ func NewIPVSController(kubeClient *kubernetes.Clientset, namespace string, useUn iptInterface := utiliptables.New(execer, dbus, utiliptables.ProtocolIpv4) ipvsc.keepalived = &keepalived{ - iface: iface, - ip: nodeInfo.ip, - netmask: nodeInfo.netmask, - nodes: clusterNodes, - neighbors: neighbors, - priority: getNodePriority(nodeInfo.ip, clusterNodes), - useUnicast: useUnicast, - ipt: iptInterface, - vrid: vrid, - proxyMode: proxyMode, + iface: iface, + ip: nodeInfo.ip, + netmask: nodeInfo.netmask, + nodes: clusterNodes, + neighbors: neighbors, + priority: getNodePriority(nodeInfo.ip, clusterNodes), + useUnicast: useUnicast, + ipt: iptInterface, + vrid: vrid, + proxyMode: proxyMode, notify: notify, + releaseVips: releaseVips, } ipvsc.syncQueue = task.NewTaskQueue(ipvsc.sync)