When none of the CLI tools like istioctl or glooctl are available, use wget/curl | jq/grep to find all the hostnames configured in Envoy
Assuming Envoy admin port is 19000. Invoke below script to invoke Envoy admin API
$ cat collect-gloo-upstream.sh
#!/usr/bin/env sh
kubectl -n $1 exec -it $2 -- wget -O - http://127.0.0.1:19000/clusters?format=json
$ /bin/sh ./collect-gloo-upstream.sh ${my-ns} ${envoy-pod-name} > ${envoy-pod-name}-cluster.json
$ grep '"hostname": "' ${envoy-pod-name}-cluster.json
# Count number of hostnames
$ grep '"hostname": "' ${envoy-pod-name}-cluster.json | wc -l
Use grep to remove any 'null' hostname when host_statuses array is empty due to un-resolvable hostnames.
$ jq ".cluster_statuses[].host_statuses[]?.hostname" ${envoy-pod-name}-cluster.json | grep -v 'null'