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 #19 from aledbf/fix-vrid
Browse files Browse the repository at this point in the history
Use vrid flag in template
  • Loading branch information
aledbf authored Sep 18, 2017
2 parents 9006844 + bcfc3e6 commit 4c35010
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
all: push

# 0.0 shouldn't clobber any release builds
TAG = 0.19
TAG = 0.20
PREFIX = aledbf/kube-keepalived-vip
BUILD_IMAGE = build-keepalived
PKG = github.com/aledbf/kube-keepalived-vip
Expand Down
16 changes: 16 additions & 0 deletions pkg/controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,22 @@ func (ipvsc *ipvsControllerController) getServices(cfgMap *apiv1.ConfigMap) []vi
// k -> IP to use
// v -> <namespace>/<service name>:<lvs method>
for externalIP, nsSvcLvs := range cfgMap.Data {
if nsSvcLvs == "" {
// if target is empty string we will not forward to any service but
// instead just configure the IP on the machine and let it up to
// another Pod or daemon to bind to the IP address
svcs = append(svcs, vip{
Name: "",
IP: externalIP,
Port: 0,
LVSMethod: "VIP",
Backends: nil,
Protocol: "TCP",
})
glog.V(2).Infof("Adding VIP only service: %v", externalIP)
continue
}

ns, svc, lvsm, err := parseNsSvcLVS(nsSvcLvs)
if err != nil {
glog.Warningf("%v", err)
Expand Down
5 changes: 4 additions & 1 deletion rootfs/keepalived.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ vrrp_script chk_haproxy {
vrrp_instance vips {
state BACKUP
interface {{ $iface }}
virtual_router_id 50
virtual_router_id {{ .vrid }}
priority {{ .priority }}
nopreempt
advert_int 1
Expand Down Expand Up @@ -51,6 +51,9 @@ vrrp_instance vips {

{{ if not .proxyMode }}
{{ range $i, $svc := .svcs }}
{{ if eq $svc.LVSMethod "VIP" }}
# VIP Service with no pods: {{ $svc.IP }}
{{ else }}
# Service: {{ $svc.Name }}
virtual_server {{ $svc.IP }} {{ $svc.Port }} {
delay_loop 5
Expand Down
2 changes: 1 addition & 1 deletion vip-daemonset-proxy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ spec:
volumeMounts:
- name: haproxy
mountPath: /etc/haproxy
- image: aledbf/kube-keepalived-vip:0.19
- image: aledbf/kube-keepalived-vip:0.20
name: kube-keepalived-vip
securityContext:
privileged: true
Expand Down
2 changes: 1 addition & 1 deletion vip-daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ spec:
spec:
hostNetwork: true
containers:
- image: aledbf/kube-keepalived-vip:0.19
- image: aledbf/kube-keepalived-vip:0.20
name: kube-keepalived-vip
imagePullPolicy: Always
securityContext:
Expand Down

0 comments on commit 4c35010

Please sign in to comment.