blob: f4623f6a8db9004be9d0a3731b75aa8e366332cc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
|