Add scripts for dropping and readding nodes to the cluster
parent
fdd2932d3e
commit
cdd59e6ebb
|
@ -0,0 +1,22 @@
|
|||
#!/bin/bash
|
||||
|
||||
#Parameter NODE is the ID of the node you wish to drop from the cluster
|
||||
#Example usage: `./remove_node_from_cluster.sh 1` to remove node xmpp1
|
||||
|
||||
NODE=$1
|
||||
CONTAINER_TO_REMOVE=openfire-docker-compose_xmpp"$NODE"_1
|
||||
CONTAINER_NAME=pumba_node"$NODE"
|
||||
|
||||
echo "About to be removed from cluster: $CONTAINER_TO_REMOVE"
|
||||
|
||||
docker run -d --rm \
|
||||
--name "$CONTAINER_NAME" \
|
||||
-v /var/run/docker.sock:/var/run/docker.sock \
|
||||
gaiaadm/pumba netem --tc-image fishbowler/iproute2 --target 172.60.0.10 --target 172.60.0.20 --target 172.60.0.30 \
|
||||
--duration 24h \
|
||||
loss --percent 100 \
|
||||
"$CONTAINER_TO_REMOVE"
|
||||
|
||||
sleep 1s
|
||||
|
||||
[[ $(docker ps --filter "name=$CONTAINER_NAME" --format '{{.Names}}') == "$CONTAINER_NAME" ]] || (echo "Failed to block traffic. The cluster likely needs restarting" && exit 1)
|
|
@ -0,0 +1,12 @@
|
|||
#!/bin/bash
|
||||
|
||||
stop_if_exists(){
|
||||
CONTAINER_NAME=$1
|
||||
[[ $(docker ps --filter "name=$CONTAINER_NAME" --format '{{.Names}}') == "$CONTAINER_NAME" ]] && docker stop "$CONTAINER_NAME"
|
||||
}
|
||||
|
||||
stop_if_exists "pumba_node1"
|
||||
stop_if_exists "pumba_node2"
|
||||
stop_if_exists "pumba_node3"
|
||||
|
||||
exit 0
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
|
||||
NODE=$1
|
||||
CONTAINER_NAME=pumba_node"$NODE"
|
||||
|
||||
[[ $(docker ps --filter "name=$CONTAINER_NAME" --format '{{.Names}}') == "$CONTAINER_NAME" ]] \
|
||||
&& CONTAINER_EXISTS=1 || CONTAINER_EXISTS=0
|
||||
|
||||
if [ $CONTAINER_EXISTS == 1 ]; then
|
||||
docker stop "$CONTAINER_NAME"
|
||||
else
|
||||
echo "No container to remove. Are you sure this node was blocked?"
|
||||
fi
|
Loading…
Reference in New Issue