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 package main
3 import (
4 "fmt"
5 "github.com/GoogleCloudPlatform/kubernetes/pkg/client"
6 "os"
7 )
9 func main() {
10 k8s, err := client.NewInCluster()
11 if err != nil {
12 panic(err)
13 }
14 hostname, err := os.Hostname()
15 if err != nil {
16 panic(err)
17 }
18 pod, err := k8s.Pods("default").Get(hostname)
19 if err != nil {
20 panic(err)
21 }
22 fmt.Println(pod.Status.PodIP)
23 }