Created
December 9, 2016 09:48
-
-
Save goblain/d8a2a1c557988040f453c7cd296d5a3c to your computer and use it in GitHub Desktop.
bash script to fetch service endpoints list as comma separated string from kubernetes api
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# bash script to fetch service endpoints list as comma separated string from kubernetes api | |
# example will list kube-dns endpoints | |
export NAMESPACE=kube-system | |
export SERVICE=kube-dns | |
curl -s --header "Authorization: Bearer `cat /var/run/secrets/kubernetes.io/serviceaccount/token`" -k https://kubernetes.default/api/v1/namespaces/$NAMESPACE/endpoints/$SERVICE | jq '.subsets | map(.addresses) | reduce .[] as $item ([];. + $item) | map(.ip) | join(",")' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment