mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-16 23:29:21 +00:00
Update serve_hostname
1) FROM busybox 2) Log source IP 3) bump to v1.2
This commit is contained in:
parent
d04fce045e
commit
384bcbb21b
@ -1,4 +1,4 @@
|
|||||||
FROM scratch
|
FROM busybox
|
||||||
MAINTAINER Tim Hockin <thockin@google.com>
|
MAINTAINER Tim Hockin <thockin@google.com>
|
||||||
ADD serve_hostname /serve_hostname
|
ADD serve_hostname /serve_hostname
|
||||||
ADD serve_hostname.go /serve_hostname.go
|
ADD serve_hostname.go /serve_hostname.go
|
||||||
|
@ -1,17 +1,23 @@
|
|||||||
all: serve_hostname
|
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
|
serve_hostname: serve_hostname.go
|
||||||
CGO_ENABLED=0 go build -a -installsuffix cgo --ldflags '-w' ./serve_hostname.go
|
CGO_ENABLED=0 go build -a -installsuffix cgo --ldflags '-w' ./serve_hostname.go
|
||||||
|
|
||||||
container: serve_hostname
|
container: serve_hostname
|
||||||
sudo docker build -t gcr.io/google_containers/serve_hostname:$(TAG) .
|
docker build -t $(PREFIX)/serve_hostname:$(TAG) .
|
||||||
sudo docker tag gcr.io/google_containers/serve_hostname:$(TAG) gcr.io/_b_k8s_authenticated_test/serve_hostname:$(TAG)
|
if [ -n "$(TEST_PREFIX)" ]; then \
|
||||||
|
docker tag -f $(PREFIX)/serve_hostname:$(TAG) $(TEST_PREFIX)/serve_hostname:$(TAG); \
|
||||||
|
fi
|
||||||
|
|
||||||
push:
|
push:
|
||||||
gcloud docker push gcr.io/google_containers/serve_hostname:$(TAG)
|
gcloud docker push $(PREFIX)/serve_hostname:$(TAG)
|
||||||
gcloud docker push gcr.io/_b_k8s_authenticated_test/serve_hostname:$(TAG)
|
if [ -n "$(TEST_PREFIX)" ]; then \
|
||||||
|
gcloud docker push $(TEST_PREFIX)/serve_hostname:$(TAG); \
|
||||||
|
fi
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f serve_hostname
|
rm -f serve_hostname
|
||||||
|
@ -56,6 +56,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Error from Accept(): %s", err)
|
log.Fatalf("Error from Accept(): %s", err)
|
||||||
}
|
}
|
||||||
|
log.Printf("TCP request from %s", conn.RemoteAddr().String())
|
||||||
conn.Write([]byte(hostname))
|
conn.Write([]byte(hostname))
|
||||||
conn.Close()
|
conn.Close()
|
||||||
}
|
}
|
||||||
@ -77,12 +78,16 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Error from ReadFrom(): %s", err)
|
log.Fatalf("Error from ReadFrom(): %s", err)
|
||||||
}
|
}
|
||||||
|
log.Printf("UDP request from %s", cliAddr.String())
|
||||||
sock.WriteTo([]byte(hostname), cliAddr)
|
sock.WriteTo([]byte(hostname), cliAddr)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
if *doHttp {
|
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))
|
go log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", *port), nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user