fd83ec6526
* Enforce a etcd-proxy role to a k8s-cluster group members. This provides an HA layout for all of the k8s cluster internal clients. * Proxies to be run on each node in the group as a separate etcd instances with a readwrite proxy mode and listen the given endpoint, which is either the access_ip:2379 or the localhost:2379. * A notion for the 'kube_etcd_multiaccess' is: ignore endpoints and loadbalancers and use the etcd members IPs as a comma-separated list. Otherwise, clients shall use the local endpoint provided by a etcd-proxy instances on each etcd node. A Netwroking plugins always use that access mode. * Fix apiserver's etcd servers args to use the etcd_access_endpoint. * Fix networking plugins flannel/calico to use the etcd_endpoint. * Fix name env var for non masters to be set as well. * Fix etcd_client_url was not used anywhere and other etcd_* facts evaluation was duplicated in a few places. * Define proxy modes only in the env file, if not a master. Del an automatic proxy mode decisions for etcd nodes in init/unit scripts. * Use Wants= instead of Requires= as "This is the recommended way to hook start-up of one unit to the start-up of another unit" * Make apiserver/calico Wants= etcd-proxy to keep it always up Signed-off-by: Bogdan Dobrelya <bdobrelia@mirantis.com> Co-authored-by: Matthew Mosesohn <mmosesohn@mirantis.com>
116 lines
2.7 KiB
Django/Jinja
116 lines
2.7 KiB
Django/Jinja
#!/bin/sh
|
|
set -a
|
|
|
|
### BEGIN INIT INFO
|
|
# Provides: etcd
|
|
# Required-Start: $local_fs $network $syslog
|
|
# Required-Stop:
|
|
# Default-Start: 2 3 4 5
|
|
# Default-Stop: 0 1 6
|
|
# Short-Description: etcd distributed k/v store
|
|
# Description:
|
|
# etcd is a distributed, consistent key-value store for shared configuration and service discovery
|
|
### END INIT INFO
|
|
|
|
PATH=/sbin:/usr/sbin:/bin/:/usr/bin
|
|
DESC="etcd k/v store"
|
|
NAME=etcd
|
|
DAEMON={{ docker_bin_dir | default("/usr/bin") }}/docker
|
|
DAEMON_ARGS='--restart=always --env-file=/etc/etcd.env \
|
|
--net=host \
|
|
-v /usr/share/ca-certificates/:/etc/ssl/certs:ro \
|
|
-v /var/lib/etcd:/var/lib/etcd:rw \
|
|
--name={{ etcd_member_name | default("etcd") }} \
|
|
{{ etcd_image_repo }}:{{ etcd_image_tag }} \
|
|
{% if etcd_after_v3 %}
|
|
{{ etcd_container_bin_dir }}etcd
|
|
{% endif %}'
|
|
|
|
SCRIPTNAME=/etc/init.d/$NAME
|
|
DAEMON_USER=etcd
|
|
STOP_SCHEDULE="${STOP_SCHEDULE:-QUIT/5/TERM/5/KILL/5}"
|
|
PID=/var/run/etcd.pid
|
|
|
|
# Exit if the binary is not present
|
|
[ -x "$DAEMON" ] || exit 0
|
|
|
|
# Define LSB log_* functions.
|
|
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
|
|
# and status_of_proc is working.
|
|
. /lib/lsb/init-functions
|
|
|
|
do_status()
|
|
{
|
|
status_of_proc -p $PID "$DAEMON" "$NAME" && exit 0 || exit $?
|
|
}
|
|
|
|
# Function that starts the daemon/service
|
|
#
|
|
do_start()
|
|
{
|
|
start-stop-daemon --background --start --quiet --make-pidfile --pidfile $PID --user $DAEMON_USER --exec $DAEMON -- \
|
|
$DAEMON_ARGS \
|
|
|| return 2
|
|
}
|
|
|
|
#
|
|
# Function that stops the daemon/service
|
|
#
|
|
do_stop()
|
|
{
|
|
start-stop-daemon --stop --quiet --retry=$STOP_SCHEDULE --pidfile $PID --name $NAME
|
|
RETVAL="$?"
|
|
|
|
sleep 1
|
|
return "$RETVAL"
|
|
}
|
|
|
|
|
|
case "$1" in
|
|
start)
|
|
log_daemon_msg "Starting $DESC" "$NAME"
|
|
do_start
|
|
case "$?" in
|
|
0|1) log_end_msg 0 || exit 0 ;;
|
|
2) log_end_msg 1 || exit 1 ;;
|
|
esac
|
|
;;
|
|
stop)
|
|
log_daemon_msg "Stopping $DESC" "$NAME"
|
|
if do_stop; then
|
|
log_end_msg 0
|
|
else
|
|
log_failure_msg "Can't stop etcd"
|
|
log_end_msg 1
|
|
fi
|
|
;;
|
|
status)
|
|
if do_status; then
|
|
log_end_msg 0
|
|
else
|
|
log_failure_msg "etcd is not running"
|
|
log_end_msg 1
|
|
fi
|
|
;;
|
|
|
|
restart|force-reload)
|
|
log_daemon_msg "Restarting $DESC" "$NAME"
|
|
if do_stop; then
|
|
if do_start; then
|
|
log_end_msg 0
|
|
exit 0
|
|
else
|
|
rc="$?"
|
|
fi
|
|
else
|
|
rc="$?"
|
|
fi
|
|
log_failure_msg "Can't restart etcd"
|
|
log_end_msg ${rc}
|
|
;;
|
|
*)
|
|
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
|
|
exit 3
|
|
;;
|
|
esac
|
|
|