Skip to content

Instantly share code, notes, and snippets.

@mattf
Created February 19, 2015 15:04
Show Gist options
  • Save mattf/5f96a9cba41147a82bec to your computer and use it in GitHub Desktop.
Save mattf/5f96a9cba41147a82bec to your computer and use it in GitHub Desktop.
fake hostname for running kubelet with asymmetric name resolution
#!/bin/sh
# mv /bin/hostname /bin/hostname.real
# install $0 as /bin/hostname (a+rx)
TARGET="kubelet"
IFACE=eth0
PARENT=$(ps -oucmd= $PPID)
if [ "$PARENT" = "$TARGET" ]; then
IP=$(ip addr show dev $IFACE | grep 'inet ' | sed 's,.*inet \(.*\)/.*,\1,')
echo $IP
else
exec hostname.real $*
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment