Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify healthcheck endpoint port with application port #229

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ Usage of amazon-eks-pod-identity-webhook:
--log_file string If non-empty, use this log file
--log_file_max_size uint Defines the maximum size a log file can grow to. Unit is megabytes. If the value is 0, the maximum file size is unlimited. (default 1800)
--logtostderr log to standard error instead of files (default true)
--metrics-port int Port to listen on for metrics and healthz (http) (default 9999)
--metrics-port int Port to listen on for metrics (http) (default 9999)
--namespace string (in-cluster) The namespace name this webhook, the TLS secret, and configmap resides in (default "eks")
--port int Port to listen on (default 443)
--service-name string (in-cluster) The service name fronting this webhook (default "pod-identity-webhook")
Expand Down
9 changes: 7 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ var webhookVersion = "v0.1.0"

func main() {
port := flag.Int("port", 443, "Port to listen on")
metricsPort := flag.Int("metrics-port", 9999, "Port to listen on for metrics and healthz (http)")
metricsPort := flag.Int("metrics-port", 9999, "Port to listen on for metrics (http)")

// TODO Group in help text in-cluster/out-of-cluster/business logic flags
// out-of-cluster kubeconfig / TLS options
Expand Down Expand Up @@ -220,9 +220,14 @@ func main() {
handler.Logging(),
)
mux.Handle("/mutate", baseHandler)
mux.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "ok")
})

metricsMux := http.NewServeMux()
metricsMux.Handle("/metrics", promhttp.Handler())
// TODO: Remove this extra healthz endpoint once we've migrated
// the health check service to the application port:
metricsMux.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "ok")
})
Expand Down Expand Up @@ -311,7 +316,7 @@ func main() {
}
}()

klog.Infof("Listening on %s for metrics and healthz", metricsAddr)
klog.Infof("Listening on %s for metrics", metricsAddr)
if err := metricsServer.ListenAndServe(); err != http.ErrServerClosed {
klog.Fatalf("Error listening: %q", err)
}
Expand Down
Loading