From 6cab2ffcb97e956880164847ebb2de22424b9bf4 Mon Sep 17 00:00:00 2001 From: Cornelius Keller Date: Sun, 3 Jun 2018 21:14:47 +0200 Subject: [PATCH 1/3] add option to use notfy scripts for keepalived --- keepalived-vip/Dockerfile | 3 ++- keepalived-vip/controller.go | 3 +++ keepalived-vip/keepalived.go | 2 ++ keepalived-vip/keepalived.tmpl | 1 + 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/keepalived-vip/Dockerfile b/keepalived-vip/Dockerfile index 0df3eac952..eff6712f56 100644 --- a/keepalived-vip/Dockerfile +++ b/keepalived-vip/Dockerfile @@ -29,7 +29,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ ca-certificates \ iproute2 \ ipvsadm \ - bash && \ + bash \ + curl && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* diff --git a/keepalived-vip/controller.go b/keepalived-vip/controller.go index 18a86f58b0..9827727190 100755 --- a/keepalived-vip/controller.go +++ b/keepalived-vip/controller.go @@ -337,6 +337,8 @@ func newIPVSController(kubeClient *unversioned.Client, namespace string, useUnic neighbors := getNodeNeighbors(nodeInfo, clusterNodes) + notify := os.Getenv("KEEPALIVED_NOTIFY") + execer := exec.New() dbus := utildbus.New() iptInterface := utiliptables.New(execer, dbus, utiliptables.ProtocolIpv4) @@ -352,6 +354,7 @@ func newIPVSController(kubeClient *unversioned.Client, namespace string, useUnic ipt: iptInterface, vrid: vrid, vrrpVersion: vrrpVersion, + notify: notify, } ipvsc.syncQueue = NewTaskQueue(ipvsc.sync) diff --git a/keepalived-vip/keepalived.go b/keepalived-vip/keepalived.go index 028a14b083..2510f55331 100755 --- a/keepalived-vip/keepalived.go +++ b/keepalived-vip/keepalived.go @@ -51,6 +51,7 @@ type keepalived struct { ipt iptables.Interface vrid int vrrpVersion int + notify string } // WriteCfg creates a new keepalived configuration file. @@ -76,6 +77,7 @@ func (k *keepalived) WriteCfg(svcs []vip) error { conf["useUnicast"] = k.useUnicast conf["vrid"] = k.vrid conf["vrrpVersion"] = k.vrrpVersion + conf["notify"] = k.notify if glog.V(2) { b, _ := json.Marshal(conf) diff --git a/keepalived-vip/keepalived.tmpl b/keepalived-vip/keepalived.tmpl index 26aeaa3010..7d9f721480 100755 --- a/keepalived-vip/keepalived.tmpl +++ b/keepalived-vip/keepalived.tmpl @@ -16,6 +16,7 @@ vrrp_instance vips { track_interface { {{ $iface }} } + {{ if .notify }} notify {{ .notify }} {{ end }} {{ if .useUnicast }} unicast_src_ip {{ .myIP }} From 9f8d7112e633de85760ed1ed2a1f159c1b6b9682 Mon Sep 17 00:00:00 2001 From: Cornelius Keller Date: Mon, 4 Jun 2018 22:55:51 +0200 Subject: [PATCH 2/3] gofmt --- keepalived-vip/controller.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keepalived-vip/controller.go b/keepalived-vip/controller.go index 9827727190..98e3e85d77 100755 --- a/keepalived-vip/controller.go +++ b/keepalived-vip/controller.go @@ -354,7 +354,7 @@ func newIPVSController(kubeClient *unversioned.Client, namespace string, useUnic ipt: iptInterface, vrid: vrid, vrrpVersion: vrrpVersion, - notify: notify, + notify: notify, } ipvsc.syncQueue = NewTaskQueue(ipvsc.sync) From 5124fda4ed29a0196ac851d2e7c8b26a79ea3230 Mon Sep 17 00:00:00 2001 From: Cornelius Keller Date: Tue, 5 Jun 2018 21:15:45 +0200 Subject: [PATCH 3/3] add jq to better interact with json apis --- keepalived-vip/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/keepalived-vip/Dockerfile b/keepalived-vip/Dockerfile index eff6712f56..401a191f67 100644 --- a/keepalived-vip/Dockerfile +++ b/keepalived-vip/Dockerfile @@ -30,6 +30,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ iproute2 \ ipvsadm \ bash \ + jq \ curl && \ apt-get clean && \ rm -rf /var/lib/apt/lists/*