initial commit
This commit is contained in:
17
scripts/bs-label-workers.sh
Normal file
17
scripts/bs-label-workers.sh
Normal file
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
# label nodes into pools based on hostname: *wordpressPool*/*mysqlPool*/*redisPool*/*phpPool*/*nginxPool*
|
||||
set -euo pipefail
|
||||
docker node inspect -f '{{ .ID }} {{ .Description.Hostname }} {{ .Spec.Role }}' $(docker node ls -q) \
|
||||
| while read -r id host role; do
|
||||
[[ "$role" == "worker" ]] || continue
|
||||
case "$host" in
|
||||
*wordPressPool*) val=wordpress ;;
|
||||
*mysqlPool*) val=mysql ;;
|
||||
*redisPool*) val=redis ;;
|
||||
*phpPool*) val=php ;;
|
||||
*nginxPool*) val=nginx ;;
|
||||
*) val="" ;;
|
||||
esac
|
||||
[[ -n "$val" ]] && docker node update --label-add "pool=$val" "$id"
|
||||
done
|
||||
echo "Worker labels updated."
|
||||
Reference in New Issue
Block a user