Skip to content

Instantly share code, notes, and snippets.

@iocanel
Created August 31, 2015 13:20
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save iocanel/41f2923a9cbddb6d509d to your computer and use it in GitHub Desktop.
Save iocanel/41f2923a9cbddb6d509d to your computer and use it in GitHub Desktop.
Get the docker host ip inside Kubernetes
#!/bin/bash
KUBERNETES=https://$KUBERNETES_SERVICE_HOST:$KUBERNETES_SERVICE_PORT
TOKEN=`cat /var/run/secrets/kubernetes.io/serviceaccount/token`
POD=`hostname`
curl -s -k -H "Authorization: Bearer $TOKEN" $KUBERNETES/api/v1/namespaces/$KUBERNETES_NAMESPACE/pods/$POD | grep -i hostIp | cut -d "\"" -f 4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment