Skip to content
This repository has been archived by the owner on Apr 17, 2019. It is now read-only.

Commit

Permalink
Add ability to specify VRRP V2 (as opposed to default of 3). Current …
Browse files Browse the repository at this point in the history
…release has a problem with V3 when there are more than 2 nodes (acassen/keepalived#642).  This has been fixed in master, but not part of a release yet.  Using VRRP V2 bypasses the issue.
  • Loading branch information
dseeley committed Sep 22, 2017
1 parent 4b2d86c commit 3769019
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 3 deletions.
7 changes: 6 additions & 1 deletion keepalived-vip/controller.go 100644 → 100755
Expand Up @@ -300,7 +300,7 @@ func (ipvsc *ipvsControllerController) Stop() error {
}

// newIPVSController creates a new controller from the given config.
func newIPVSController(kubeClient *unversioned.Client, namespace string, useUnicast bool, configMapName string, vrid int) *ipvsControllerController {
func newIPVSController(kubeClient *unversioned.Client, namespace string, useUnicast bool, configMapName string, vrid int, vrrpVersion int) *ipvsControllerController {
ipvsc := ipvsControllerController{
client: kubeClient,
reloadRateLimiter: flowcontrol.NewTokenBucketRateLimiter(reloadQPS, int(reloadQPS)),
Expand Down Expand Up @@ -331,6 +331,10 @@ func newIPVSController(kubeClient *unversioned.Client, namespace string, useUnic
glog.Fatalf("Error using VRID %d, only values between 0 and 255 are allowed.", vrid)
}

if vrrpVersion < 2 || vrrpVersion > 3 {
glog.Fatalf("Error using VRRP %d, only values between 2 and 3 are allowed.", vrrpVersion)
}

neighbors := getNodeNeighbors(nodeInfo, clusterNodes)

execer := exec.New()
Expand All @@ -347,6 +351,7 @@ func newIPVSController(kubeClient *unversioned.Client, namespace string, useUnic
useUnicast: useUnicast,
ipt: iptInterface,
vrid: vrid,
vrrpVersion: vrrpVersion,
}

ipvsc.syncQueue = NewTaskQueue(ipvsc.sync)
Expand Down
2 changes: 2 additions & 0 deletions keepalived-vip/keepalived.go 100644 → 100755
Expand Up @@ -50,6 +50,7 @@ type keepalived struct {
cmd *exec.Cmd
ipt iptables.Interface
vrid int
vrrpVersion int
}

// WriteCfg creates a new keepalived configuration file.
Expand All @@ -74,6 +75,7 @@ func (k *keepalived) WriteCfg(svcs []vip) error {
conf["priority"] = k.priority
conf["useUnicast"] = k.useUnicast
conf["vrid"] = k.vrid
conf["vrrpVersion"] = k.vrrpVersion

if glog.V(2) {
b, _ := json.Marshal(conf)
Expand Down
2 changes: 1 addition & 1 deletion keepalived-vip/keepalived.tmpl 100644 → 100755
@@ -1,7 +1,7 @@
{{ $iface := .iface }}{{ $netmask := .netmask }}

global_defs {
vrrp_version 3
vrrp_version {{ .vrrpVersion }}
vrrp_iptables {{ .iptablesChain }}
}

Expand Down
4 changes: 3 additions & 1 deletion keepalived-vip/main.go 100644 → 100755
Expand Up @@ -43,6 +43,8 @@ var (
useUnicast = flags.Bool("use-unicast", false, `use unicast instead of multicast for communication
with other keepalived instances`)

vrrpVersion = flags.Int("vrrp-version", 3, `Which VRRP version to use (2 or 3)`)

configMapName = flags.String("services-configmap", "",
`Name of the ConfigMap that contains the definition of the services to expose.
The key in the map indicates the external IP to use. The value is the name of the
Expand Down Expand Up @@ -122,7 +124,7 @@ func main() {
if *useUnicast {
glog.Info("keepalived will use unicast to sync the nodes")
}
ipvsc := newIPVSController(kubeClient, namespace, *useUnicast, *configMapName, *vrid)
ipvsc := newIPVSController(kubeClient, namespace, *useUnicast, *configMapName, *vrid, *vrrpVersion)
go ipvsc.epController.Run(wait.NeverStop)
go ipvsc.svcController.Run(wait.NeverStop)

Expand Down
2 changes: 2 additions & 0 deletions keepalived-vip/vip-daemonset.yaml 100644 → 100755
Expand Up @@ -37,6 +37,8 @@ spec:
# unicast uses the ip of the nodes instead of multicast
# this is useful if running in cloud providers (like AWS)
#- --use-unicast=true
# vrrp version can be set to 2. Default 3.
#- --vrrp-version=2
volumes:
- name: modules
hostPath:
Expand Down

0 comments on commit 3769019

Please sign in to comment.