Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion manifests/baremetal/keepalived.conf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
state BACKUP
interface {{.VRRPInterface}}
virtual_router_id {{.Cluster.APIVirtualRouterID }}
priority 50
priority 70
advert_int 1
{{ if .EnableUnicast }}
unicast_src_ip {{.NonVirtualIP}}
Expand Down
27 changes: 18 additions & 9 deletions manifests/baremetal/keepalived.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@ spec:
- name: run-dir
empty-dir: {}
containers:
- name: keepalived-unicast
image: {{ .Images.BaremetalRuntimeCfgBootstrap }}
command:
- unicastipserver
- "--api-vip"
- "{{ .ControllerConfig.Infra.Status.PlatformStatus.BareMetal.APIServerInternalIP }}"
- "--ingress-vip"
- "{{ .ControllerConfig.Infra.Status.PlatformStatus.BareMetal.IngressIP }}"
- name: keepalived
securityContext:
privileged: true
Expand All @@ -52,20 +44,36 @@ spec:
/usr/sbin/keepalived -f /etc/keepalived/keepalived.conf --dont-fork --vrrp --log-detail --log-console &
fi
}
stop_keepalived()
{
echo "Keepalived process stopped" >> /var/run/keepalived/stopped
if pid=$(pgrep -o keepalived); then
kill -s TERM "$pid"
fi
}

msg_handler()
{
while read -r line; do
echo "The client sent: $line" >&2
# currently only 'reload' msg is supported
# currently only 'reload' and 'stop' msgs are supported
Comment thread
yboaron marked this conversation as resolved.
if [ "$line" = reload ]; then
reload_keepalived
elif [ "$line" = stop ]; then
stop_keepalived
fi
done
}
set -ex
declare -r keepalived_sock="/var/run/keepalived/keepalived.sock"
export -f msg_handler
export -f reload_keepalived
export -f stop_keepalived

while [ -s "/var/run/keepalived/stopped" ]; do
echo "Container stopped"
sleep 60
done
if [ -s "/etc/keepalived/keepalived.conf" ]; then
/usr/sbin/keepalived -f /etc/keepalived/keepalived.conf --dont-fork --vrrp --log-detail --log-console &
fi
Expand All @@ -87,6 +95,7 @@ spec:
- -c
- |
[[ -s /etc/keepalived/keepalived.conf ]] || \
[[ -s /var/run/keepalived/stopped ]] || \
kill -s SIGUSR1 "$(pgrep -o keepalived)" && ! grep -q "State = FAULT" /tmp/keepalived.data
initialDelaySeconds: 20
terminationMessagePolicy: FallbackToLogsOnError
Expand Down
29 changes: 19 additions & 10 deletions pkg/operator/assets/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.