Created
June 5, 2016 06:55
-
-
Save jchauncey/8c1534681a8eab0c746f39b2143a3a0c to your computer and use it in GitHub Desktop.
get pod ips from kubernetes
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
export GET_PODS_URL=https://$KUBERNETES_SERVICE_HOST:$KUBERNETES_SERVICE_PORT/api/v1/namespaces/$POD_NAMESPACE/pods | |
pod_names=$(curl -s $GET_PODS_URL --header "Authorization: Bearer $TOKEN" --insecure | jq --raw-output '.items[].metadata.name' | grep deis-nsqlookupd) | |
while read -r pod; do | |
GET_POD_URL=https://$KUBERNETES_SERVICE_HOST:$KUBERNETES_SERVICE_PORT/api/v1/namespaces/$POD_NAMESPACE/pods/${pod} | |
pod_ip=$(curl -s $GET_POD_URL --header "Authorization: Bearer $TOKEN" --insecure | jq --raw-output '.status.podIP') | |
export LOOKUP_COMMAND="$LOOKUP_COMMAND -lookupd-tcp-address ${pod_ip}:4161" | |
done <<< "$pod_names" | |
exec nsqd -broadcast-address ${NODE_NAME} ${LOOKUP_COMMAND} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment