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

Commit

Permalink
Merge pull request #79 from muhlba91/notify_script
Browse files Browse the repository at this point in the history
add notify script via environment variable
  • Loading branch information
aledbf authored Jan 23, 2019
2 parents f3b9e29 + 2b0183e commit 826d2e3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions pkg/controller/keepalived.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ type keepalived struct {
ipt iptables.Interface
vrid int
proxyMode bool
notify string
}

// WriteCfg creates a new keepalived configuration file.
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions pkg/controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions rootfs/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ RUN clean-install \
curl \
ipvsadm \
bash \
jq \
dumb-init

ADD keepalived.tar.gz /
Expand Down
6 changes: 4 additions & 2 deletions rootfs/keepalived.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ vrrp_instance vips {
{{ $iface }}
}

{{ if .notify }} notify {{ .notify }} {{ end }}

{{ if .useUnicast }}
unicast_src_ip {{ .myIP }}
unicast_peer { {{ range .nodes }}
Expand All @@ -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 }} {
Expand Down

0 comments on commit 826d2e3

Please sign in to comment.