k8s-helpers/get_pod_ip

Paddy 2015-07-18 Child:a88caff12445

0:278dc70f8696 Go to Latest

k8s-helpers/get_pod_ip/get_pod_ip.go

First commit. Let's try and get this working. Basically, just a small container that will find the IP of the current pod in kubernetes.

History
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/get_pod_ip.go	Sat Jul 18 06:02:52 2015 -0400
     1.3 @@ -0,0 +1,23 @@
     1.4 +package main
     1.5 +
     1.6 +import (
     1.7 +	"fmt"
     1.8 +	"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
     1.9 +	"os"
    1.10 +)
    1.11 +
    1.12 +func main() {
    1.13 +	k8s, err := client.NewInCluster()
    1.14 +	if err != nil {
    1.15 +		panic(err)
    1.16 +	}
    1.17 +	hostname, err := os.Hostname()
    1.18 +	if err != nil {
    1.19 +		panic(err)
    1.20 +	}
    1.21 +	pod, err := k8s.Pods("default").Get(hostname)
    1.22 +	if err != nil {
    1.23 +		panic(err)
    1.24 +	}
    1.25 +	fmt.Println(pod.Status.PodIP)
    1.26 +}