From c07ac367943093c315ceb4c511224bdf786a7097 Mon Sep 17 00:00:00 2001 From: Nont Date: Mon, 6 May 2024 17:50:26 -0500 Subject: [PATCH] Add healthcheck to Proxy --- Dockerfile.proxy | 4 +++- pkg/proxy/proxy.go | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Dockerfile.proxy b/Dockerfile.proxy index df4355866..da95193c0 100644 --- a/Dockerfile.proxy +++ b/Dockerfile.proxy @@ -7,11 +7,13 @@ ENV GOPATH=/root/go RUN mkdir -p /app WORKDIR /app +COPY . /app RUN make proxy FROM ${REGISTRY}/ubi8/ubi-minimal RUN microdnf update && microdnf clean all -COPY --from=builder /go/src/github.com/Azure/ARO-RP/proxy /usr/local/bin/ +COPY --from=builder /app/proxy /usr/local/bin/ ENTRYPOINT ["proxy"] EXPOSE 8443/tcp +EXPOSE 8080/tcp USER 1000 diff --git a/pkg/proxy/proxy.go b/pkg/proxy/proxy.go index 746a7d1c9..3bcd1e858 100644 --- a/pkg/proxy/proxy.go +++ b/pkg/proxy/proxy.go @@ -7,6 +7,7 @@ import ( "crypto/tls" "crypto/x509" "errors" + "fmt" "io" "net" "net/http" @@ -29,7 +30,16 @@ type Server struct { subnet *net.IPNet } +func health(w http.ResponseWriter, _ *http.Request) { + w.WriteHeader(http.StatusOK) + fmt.Fprintf(w, "Running.") +} + func (s *Server) Run() error { + healthMux := http.NewServeMux() + healthMux.HandleFunc("/", health) + go http.ListenAndServe(":8080", healthMux) + _, subnet, err := net.ParseCIDR(s.Subnet) if err != nil { return err