Skip to content
This repository has been archived by the owner on Aug 19, 2020. It is now read-only.

Commit

Permalink
Add flag to make ipvs reset optional
Browse files Browse the repository at this point in the history
* implement flag --release-vips default true. If it true, add --release-vips to keepalived args
  • Loading branch information
mshaverdo authored and Timofey Titovets committed May 2, 2019
1 parent 9b88838 commit f65d20d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
4 changes: 3 additions & 1 deletion pkg/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -137,7 +139,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)

ipvsc.Start()
}
Expand Down
12 changes: 7 additions & 5 deletions pkg/controller/keepalived.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ type keepalived struct {
vrid int
proxyMode bool
notify string
releaseVips bool
}

// WriteCfg creates a new keepalived configuration file.
Expand Down Expand Up @@ -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
Expand Down
23 changes: 12 additions & 11 deletions pkg/controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit f65d20d

Please sign in to comment.