added proxyprotocol options

This commit is contained in:
ston1th 2021-04-10 02:42:55 +02:00
commit 5de98614da
4 changed files with 23 additions and 19 deletions

10
TODO
View file

@ -1,7 +1,5 @@
test etcd
* user/password
* multi node
VIP for haproxy-lb
* take from pool?
* extra config?
usr arp lib https://godoc.org/github.com/mdlayher/arp ?
* https://github.com/metallb/metallb/blob/main/internal/layer2/arp.go#L50
add google copyright to arp ocde?
test api in followers

View file

@ -23,6 +23,8 @@ type LoadBalancer struct {
type Options struct {
Frontend []string `json:"frontend,omitempty"`
Backend []string `json:"backend,omitempty"`
ProxyProtocol string `json:"proxyProtocol,omitempty"`
CheckProxyProtocol bool `json:"checkProxyProtocol,omitempty"`
DefaultServer string `json:"defaultServer,omitempty`
}

View file

@ -28,6 +28,8 @@ type LoadBalancer struct {
type Options struct {
Frontend []string `json:"frontend"`
Backend []string `json:"backend"`
ProxyProtocol string `json:"proxyProtocol"`
CheckProxyProtocol bool `json:"checkProxyProtocol"`
DefaultServer string `json:"defaultServer"`
}

View file

@ -2,6 +2,7 @@ package haproxy
const haproxyConfigTemplate = `global
daemon
# TODO
#chroot /var/lib/haproxy
chroot /usr/share/haproxy
pidfile /run/haproxy.pid
@ -31,20 +32,21 @@ frontend fr_{{ $item.Name }}_{{ $port.Port }}
{{- range $opt := $item.Options.Frontend }}
option {{ $opt }}
{{- end }}
# option tcplog
# option splice-request
default_backend ba_{{ $item.Name }}_{{ $port.Port }}
backend ba_{{ $item.Name }}_{{ $port.Port }}
balance roundrobin
{{- range $opt := $item.Options.Backend }}
option {{ $opt }}
{{- end }}
# option splice-response
# option httpchk GET /
default-server inter 3s downinter 10s fall 2 rise 2 on-marked-down shutdown-sessions {{ $item.Options.DefaultServer }}
# send-proxy-v2
# check-send-proxy
# port <healthCheckNodePort>
{{- if eq $item.Options.ProxyProtocol "v1" }}
send-proxy
{{- else if eq $item.Options.ProxyProtocol "v2" }}
send-proxy-v2
{{- end }}
{{- if $item.Options.CheckProxyProtocol }}
check-send-proxy
{{- end }}
{{- range $srv := $port.Servers }}
server {{ $srv.Name }} {{ $srv.IP }}:{{ $srv.Port }} check
{{- end }}