diff --git a/contrib/for-demos/serve_hostname/Dockerfile b/contrib/for-demos/serve_hostname/Dockerfile index 07b614b74cf..7af2369d9af 100644 --- a/contrib/for-demos/serve_hostname/Dockerfile +++ b/contrib/for-demos/serve_hostname/Dockerfile @@ -1,4 +1,4 @@ -FROM scratch +FROM busybox MAINTAINER Tim Hockin ADD serve_hostname /serve_hostname ADD serve_hostname.go /serve_hostname.go diff --git a/contrib/for-demos/serve_hostname/Makefile b/contrib/for-demos/serve_hostname/Makefile index 6fe4b980d20..7b5910a533d 100644 --- a/contrib/for-demos/serve_hostname/Makefile +++ b/contrib/for-demos/serve_hostname/Makefile @@ -1,17 +1,23 @@ all: serve_hostname -TAG = 1.1 +TAG = v1.2 +PREFIX = gcr.io/google_containers +TEST_PREFIX = gcr.io/_b_k8s_authenticated_test serve_hostname: serve_hostname.go CGO_ENABLED=0 go build -a -installsuffix cgo --ldflags '-w' ./serve_hostname.go container: serve_hostname - sudo docker build -t gcr.io/google_containers/serve_hostname:$(TAG) . - sudo docker tag gcr.io/google_containers/serve_hostname:$(TAG) gcr.io/_b_k8s_authenticated_test/serve_hostname:$(TAG) + docker build -t $(PREFIX)/serve_hostname:$(TAG) . + if [ -n "$(TEST_PREFIX)" ]; then \ + docker tag -f $(PREFIX)/serve_hostname:$(TAG) $(TEST_PREFIX)/serve_hostname:$(TAG); \ + fi push: - gcloud docker push gcr.io/google_containers/serve_hostname:$(TAG) - gcloud docker push gcr.io/_b_k8s_authenticated_test/serve_hostname:$(TAG) + gcloud docker push $(PREFIX)/serve_hostname:$(TAG) + if [ -n "$(TEST_PREFIX)" ]; then \ + gcloud docker push $(TEST_PREFIX)/serve_hostname:$(TAG); \ + fi clean: rm -f serve_hostname diff --git a/contrib/for-demos/serve_hostname/serve_hostname.go b/contrib/for-demos/serve_hostname/serve_hostname.go index 7032602eb2c..3ae7562219c 100644 --- a/contrib/for-demos/serve_hostname/serve_hostname.go +++ b/contrib/for-demos/serve_hostname/serve_hostname.go @@ -56,6 +56,7 @@ func main() { if err != nil { log.Fatalf("Error from Accept(): %s", err) } + log.Printf("TCP request from %s", conn.RemoteAddr().String()) conn.Write([]byte(hostname)) conn.Close() } @@ -77,12 +78,16 @@ func main() { if err != nil { log.Fatalf("Error from ReadFrom(): %s", err) } + log.Printf("UDP request from %s", cliAddr.String()) sock.WriteTo([]byte(hostname), cliAddr) } }() } if *doHttp { - http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "%s", hostname) }) + http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + log.Printf("HTTP request from %s", r.RemoteAddr) + fmt.Fprintf(w, "%s", hostname) + }) go log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", *port), nil)) }