Skip to content

Commit

Permalink
Merge pull request #229 from modulitos/modulitos/amazon-eks-pod-ident…
Browse files Browse the repository at this point in the history
…ity-webhook

Unify healthcheck endpoint port with application port
  • Loading branch information
kmala committed Jul 3, 2024
2 parents 96f297f + 2d5b665 commit 88006e0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
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

0 comments on commit 88006e0

Please sign in to comment.