From 2b0183eb294fe1e342e3045bac2155cdafbc8832 Mon Sep 17 00:00:00 2001 From: Daniel Muehlbachler Date: Mon, 21 Jan 2019 15:05:15 +0100 Subject: [PATCH] add notify script via environment variable --- pkg/controller/keepalived.go | 2 ++ pkg/controller/main.go | 3 +++ rootfs/Dockerfile | 1 + rootfs/keepalived.tmpl | 6 ++++-- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/controller/keepalived.go b/pkg/controller/keepalived.go index 1416e10c..8e2d2291 100644 --- a/pkg/controller/keepalived.go +++ b/pkg/controller/keepalived.go @@ -64,6 +64,7 @@ type keepalived struct { ipt iptables.Interface vrid int proxyMode bool + notify string } // WriteCfg creates a new keepalived configuration file. @@ -91,6 +92,7 @@ func (k *keepalived) WriteCfg(svcs []vip) error { conf["iface"] = k.iface conf["proxyMode"] = k.proxyMode conf["vipIsEmpty"] = len(k.vips) == 0 + conf["notify"] = k.notify if glog.V(2) { b, _ := json.Marshal(conf) diff --git a/pkg/controller/main.go b/pkg/controller/main.go index 45eb434e..0bb446cd 100644 --- a/pkg/controller/main.go +++ b/pkg/controller/main.go @@ -386,6 +386,8 @@ func NewIPVSController(kubeClient *kubernetes.Clientset, namespace string, useUn } neighbors := getNodeNeighbors(nodeInfo, clusterNodes) + notify := os.Getenv("KEEPALIVED_NOTIFY") + if iface == "" { iface = nodeInfo.iface glog.Info("No interface was provided, proceeding with the node's default: ", iface) @@ -405,6 +407,7 @@ func NewIPVSController(kubeClient *kubernetes.Clientset, namespace string, useUn ipt: iptInterface, vrid: vrid, proxyMode: proxyMode, + notify: notify, } ipvsc.syncQueue = task.NewTaskQueue(ipvsc.sync) diff --git a/rootfs/Dockerfile b/rootfs/Dockerfile index 4720e5d0..3fa09304 100644 --- a/rootfs/Dockerfile +++ b/rootfs/Dockerfile @@ -32,6 +32,7 @@ RUN clean-install \ curl \ ipvsadm \ bash \ + jq \ dumb-init ADD keepalived.tar.gz / diff --git a/rootfs/keepalived.tmpl b/rootfs/keepalived.tmpl index 90e17f83..b09e4be9 100644 --- a/rootfs/keepalived.tmpl +++ b/rootfs/keepalived.tmpl @@ -29,6 +29,8 @@ vrrp_instance vips { {{ $iface }} } + {{ if .notify }} notify {{ .notify }} {{ end }} + {{ if .useUnicast }} unicast_src_ip {{ .myIP }} unicast_peer { {{ range .nodes }} @@ -53,8 +55,8 @@ vrrp_instance vips { {{ if not .proxyMode }} {{ range $i, $svc := .svcs }} -{{ if eq $svc.LVSMethod "VIP" }} -# VIP Service with no pods: {{ $svc.IP }} +{{ if eq $svc.LVSMethod "VIP" }} +# VIP Service with no pods: {{ $svc.IP }} {{ else }} # Service: {{ $svc.Name }} virtual_server {{ $svc.IP }} {{ $svc.Port }} {