diff options
| author | Suren A. Chilingaryan <csa@suren.me> | 2025-12-09 16:14:26 +0000 |
|---|---|---|
| committer | Suren A. Chilingaryan <csa@suren.me> | 2025-12-09 16:14:26 +0000 |
| commit | 77aa9c433f9255d713394e3b25987fa2b4a03a1a (patch) | |
| tree | ddc5d87bf838bd589f36b43b53955ad8207796a2 /scripts/disaster/gluster_endpoints/remove_endpoints.sh | |
| parent | d35216ee0cbf9f1a84a6d4151daf870b1ff00395 (diff) | |
| download | ands-master.tar.gz ands-master.tar.bz2 ands-master.tar.xz ands-master.zip | |
Diffstat (limited to 'scripts/disaster/gluster_endpoints/remove_endpoints.sh')
| -rw-r--r-- | scripts/disaster/gluster_endpoints/remove_endpoints.sh | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/scripts/disaster/gluster_endpoints/remove_endpoints.sh b/scripts/disaster/gluster_endpoints/remove_endpoints.sh new file mode 100644 index 0000000..f4623f6 --- /dev/null +++ b/scripts/disaster/gluster_endpoints/remove_endpoints.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +TARGET_IP="192.168.12.1" + +for ns in $(oc get ns --no-headers | awk '{print $1}'); do + for epname in gfs glusterfs-dynamic-etcd glusterfs-dynamic-metrics-cassandra-1 glusterfs-dynamic-mongodb glusterfs-dynamic-registry-claim glusterfs-dynamic-sharelatex-docker; do + ep=$(oc get endpoints "$epname" -n "$ns" -o json 2>/dev/null) || continue + + modified="$(printf '%s' "$ep" | jq \ + --arg ip "$TARGET_IP" \ + '(.subsets[]?.addresses |= map(select(.ip != $ip)))' + )" + + if diff <(echo "$ep") <(echo "$modified") >/dev/null; then + continue + fi + + echo -n "Namespace: $ns/$epname:" + echo -n "$ep" | jq '.subsets[].addresses' + echo -n " ===> " + echo -n "$modified" | jq '.subsets[].addresses' + echo + + # When verified, uncomment the following line to APPLY: + echo "$modified" | oc replace -f - -n "$ns" + done +done |
