Last active
March 20, 2018 21:13
-
-
Save bloo/50b0acc00b51493df32c246d7ba2023f to your computer and use it in GitHub Desktop.
Upgrade an entire Docker Swarm cluster's `docker.service` settings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
pem=${1} | |
shift | |
nodes="${@}" | |
if [ -z ${pem} ] || [ -z "${nodes}" ]; then | |
echo "Usage `basename ${0}` <pem-file> <ip1> <ip2> .." | |
exit 1 | |
fi | |
set -e | |
function _ssh() { | |
ip=${1} | |
shift | |
cmd="${@}" | |
echo "" | |
echo "Running: ${cmd}" | |
ssh -t -o "StrictHostKeyChecking no" -i ${pem} core@${ip} "sudo ${cmd}" | |
} | |
for ip in ${nodes}; do | |
echo "------ node ${ip} ----------------------------------------" | |
# read -p "continue? y/N: " YN | |
YN=y | |
if [[ ${YN} =~ [Yy] ]]; then | |
confDir=/etc/systemd/system/docker.service.d | |
_ssh ${ip} sed -i.bak "'s/--log-driver=journald/--log-driver=json-file --log-opt=max-size=10m --log-opt=max-file=2/'" ${confDir}/20-clct-docker.conf | |
# _ssh ${ip} sed -i.bak "'s/--log-driver=json-file --log-opt=max-size=10m --log-opt=max-file=2/--log-driver=journald/'" ${confDir}/20-clct-docker.conf | |
_ssh ${ip} systemctl daemon-reload | |
_ssh ${ip} systemctl restart docker.service | |
_ssh ${ip} systemctl --no-pager status docker.service | |
sleep 30 | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Given that:
ips.txt
pem
for the AWS EC2 secret the cluster node's are linked to exists at/creds/services-cluster-nodes.live.pem
Run:
./update_cluster.sh /creds/services-cluster-nodes.live.pem $(cat ips.txt)