From 09074a858970b4b686f3300e3f5a0c630ff2501f Mon Sep 17 00:00:00 2001 From: Sylvain Rabot Date: Thu, 11 Jun 2020 17:13:10 +0200 Subject: [PATCH] Configure User-Agent Signed-off-by: Sylvain Rabot --- cmd/nginx/main.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cmd/nginx/main.go b/cmd/nginx/main.go index d67b17232..5252574ec 100644 --- a/cmd/nginx/main.go +++ b/cmd/nginx/main.go @@ -24,6 +24,8 @@ import ( "net/http/pprof" "os" "os/signal" + "path/filepath" + "runtime" "syscall" "time" @@ -201,10 +203,21 @@ func handleSigterm(ngx *controller.NGINXController, exit exiter) { // the in-cluster config is missing or fails, we fallback to the default config. func createApiserverClient(apiserverHost, rootCAFile, kubeConfig string) (*kubernetes.Clientset, error) { cfg, err := clientcmd.BuildConfigFromFlags(apiserverHost, kubeConfig) + if err != nil { return nil, err } + // Configure the User-Agent used for the HTTP requests made to the API server. + cfg.UserAgent = fmt.Sprintf( + "%s/%s (%s/%s) ingress-nginx/%s", + filepath.Base(os.Args[0]), + version.RELEASE, + runtime.GOOS, + runtime.GOARCH, + version.COMMIT, + ) + if apiserverHost != "" && rootCAFile != "" { tlsClientConfig := rest.TLSClientConfig{}