Created
May 4, 2016 22:41
-
-
Save bakins/b636cf13d0a3c3d3928b39fa10fd983d to your computer and use it in GitHub Desktop.
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
# get our hostip if running under kubernetes | |
if [[ -n "${KUBERNETES_NAMESPACE}" && -n "${KUBERNETES_PODNAME}" ]] ; then | |
KUBERNETES_HOSTIP="" | |
while true; do | |
KUBERNETES_HOSTIP=`kubectl get pods --namespace=${KUBERNETES_NAMESPACE} ${KUBERNETES_PODNAME} -o json | jq -r .status.hostIP` | |
if [ -n "${KUBERNETES_HOSTIP}" ] && [ "${KUBERNETES_HOSTIP}" != "null" ]; then | |
break | |
fi | |
sleep 1 | |
done | |
export KUBERNETES_HOSTIP | |
KUBERNETES_NODENAME=`kubectl get pods --namespace=${KUBERNETES_NAMESPACE} ${KUBERNETES_PODNAME} -o json | jq -r .spec.nodeName` | |
export KUBERNETES_NODENAME | |
fi | |
# set statsd if not set | |
if [ -z "${STATSD_SERVER}" ]; then | |
# if running under kubernetes, we assume a statsd server is running on | |
# port 8125 on the host IP | |
if [ -n "${KUBERNETES_HOSTIP}" ]; then | |
STATSD_SERVER="${KUBERNETES_HOSTIP}:8125" | |
else | |
STATSD_SERVER=127.0.0.1:8125 | |
fi | |
fi | |
export STATSD_SERVER |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment