Merge pull request #5700 from sylr/user-agent

Configure User-Agent
This commit is contained in:
Kubernetes Prow Robot 2020-06-12 18:47:55 -07:00 committed by GitHub
commit e9a08abffe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -24,6 +24,8 @@ import (
"net/http/pprof"
"os"
"os/signal"
"path/filepath"
"runtime"
"syscall"
"time"
@ -199,10 +201,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{}