feat: add worker nodes to docker swarm setup

This commit is contained in:
Alexander Navarro 2024-12-10 16:26:17 -03:00
parent 22d7e4a318
commit d318880600
10 changed files with 252 additions and 112 deletions

61
roles/docker/files/openrc.sh Executable file
View file

@ -0,0 +1,61 @@
#!/sbin/openrc-run
supervisor=supervise-daemon
name="Docker Daemon"
description="Persistent process that manages docker containers"
description_reload="Reload configuration without exiting"
command="${DOCKERD_BINARY:-/usr/bin/dockerd}"
command_args="${DOCKER_OPTS}"
DOCKER_LOGFILE="${DOCKER_LOGFILE:-/var/log/${RC_SVCNAME}.log}"
DOCKER_ERRFILE="${DOCKER_ERRFILE:-${DOCKER_LOGFILE}}"
DOCKER_OUTFILE="${DOCKER_OUTFILE:-${DOCKER_LOGFILE}}"
if [ "$DOCKER_ERRFILE" = "$DOCKER_OUTFILE" ]; then
LOGPROXY_OPTS="$LOGPROXY_OPTS -m"
fi
export \
LOGPROXY_CHMOD="${LOGPROXY_CHMOD:-0644}" \
LOGPROXY_LOG_DIRECTORY="${LOGPROXY_LOG_DIRECTORY:-/var/log}" \
LOGPROXY_ROTATION_SIZE="${LOGPROXY_ROTATION_SIZE:-104857600}" \
LOGPROXY_ROTATION_TIME="${LOGPROXY_ROTATION_TIME:-86400}" \
LOGPROXY_ROTATION_SUFFIX="${LOGPROXY_ROTATION_SUFFIX:-.%Y%m%d%H%M%S}" \
LOGPROXY_ROTATED_FILES="${LOGPROXY_ROTATE_FILES:-5}"
output_logger="log_proxy $LOGPROXY_OPTS $DOCKER_OUTFILE"
error_logger="log_proxy $LOGPROXY_OPTS $DOCKER_ERRFILE"
extra_started_commands="reload"
rc_ulimit=""
RC_ULIMIT=""
if [ "$1" = "start" ]; then
if [ $BASH ]; then
rc_ulimit="${DOCKER_ULIMIT:--c unlimited -n 1048576 -u unlimited}"
else
ulimit -c unlimited
ulimit -n 1048576
ulimit -p unlimited
fi
fi
retry="${DOCKER_RETRY:-TERM/60/KILL/10}"
if [ -e /etc/profile.d/proxy.sh ]; then
. /etc/profile.d/proxy.sh
fi
depend() {
need sysfs cgroups net
after firewall
}
start_pre() {
checkpath -f -m 0644 -o root:docker "$DOCKER_ERRFILE" "$DOCKER_OUTFILE"
}
reload() {
ebegin "Reloading configuration"
$supervisor $RC_SVCNAME --signal HUP
eend $?
}