forked from aledbf/kube-keepalived-vip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkeepalived.tmpl
80 lines (66 loc) · 1.39 KB
/
keepalived.tmpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
{{ $iface := .iface }}{{ $netmask := .netmask }}
global_defs {
vrrp_version 3
vrrp_iptables {{ .iptablesChain }}
}
#Check if the VIP list is empty
{{ if not .vipIsEmpty }}
{{ if .proxyMode }}
vrrp_script chk_haproxy {
script "/haproxy-check.sh"
interval 1
}
{{ end }}
vrrp_instance vips {
state BACKUP
interface {{ $iface }}
virtual_router_id {{ .vrid }}
priority {{ .priority }}
nopreempt
advert_int 1
track_interface {
{{ $iface }}
}
{{ if .useUnicast }}
unicast_src_ip {{ .myIP }}
unicast_peer { {{ range .nodes }}
{{ . }}{{ end }}
}
{{ end }}
virtual_ipaddress { {{ range .vips }}
{{ . }}{{ end }}
}
{{ if .proxyMode }}
# In proxy mode there is no need to create virtual servers
track_script {
chk_haproxy weight 1
}
{{ end }}
}
{{ 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
lvs_sched wlc
lvs_method {{ $svc.LVSMethod }}
persistence_timeout 1800
protocol {{ $svc.Protocol }}
{{ range $j, $backend := $svc.Backends }}
real_server {{ $backend.IP }} {{ $backend.Port }} {
weight 1
TCP_CHECK {
connect_port {{ $backend.Port }}
connect_timeout 3
}
}
{{ end }}
}
{{ end }}
{{ end }}
#End if vip list is empty
{{ end }}
{{ end }}