summaryrefslogtreecommitdiffstats
path: root/scripts/disaster/gluster_endpoints/add_endpoints.sh
blob: 4badee95f3e2ab45c2595486287a01be9be6819f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[[ $# -ne 1 ]] && { echo "Usage: $0 <NEW_NODE_IP>"; exit 1; }

NEW_IP="$1"

oc get namespaces -o name | sed 's/namespaces\///' | \
while read NS; do
  if oc -n "$NS" get endpoints gfs &>/dev/null; then
    echo "✓ Patching $NS/gfs with $NEW_IP"
#    echo oc -n "$NS" patch endpoints gfs --type=strategic --patch="{\"subsets\":[{\"addresses\":[{\"ip\":\"$NEW_IP\"}]}]}"
#    echo oc -n "$NS" patch ep gfs --type=strategic --patch='{"subsets":[{"addresses":[{"ip":"'"$NEW_IP"'"}]}]}'
     oc -n "$NS" patch ep gfs --type=json -p='[{"op": "add", "path": "/subsets/0/addresses/-", "value": {"ip": "'"$NEW_IP"'"}}]'
  else
    echo "✗ No gfs endpoint in $NS (skipping)"
  fi
done

echo "Done. Verify: oc get ep gfs -A -o wide"