Skip to content

Instantly share code, notes, and snippets.

@mattf
Created February 19, 2015 15:04

Revisions

  1. mattf created this gist Feb 19, 2015.
    17 changes: 17 additions & 0 deletions kubelet_hostname
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    #!/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