Skip to content

Instantly share code, notes, and snippets.

View ivnilv's full-sized avatar
🟢

ivnilv

🟢
View GitHub Profile
@ivnilv
ivnilv / get-host.ip.sh
Created October 17, 2023 20:21 — forked from iocanel/get-host.ip.sh
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