diff --git a/prow/kube/BUILD.bazel b/prow/kube/BUILD.bazel index 48e218baebd1..4e0fcf7d6a67 100644 --- a/prow/kube/BUILD.bazel +++ b/prow/kube/BUILD.bazel @@ -40,6 +40,7 @@ go_library( "//prow/apis/prowjobs/v1:go_default_library", "//prow/client/clientset/versioned:go_default_library", "//prow/client/clientset/versioned/typed/prowjobs/v1:go_default_library", + "//prow/version:go_default_library", "@com_github_prometheus_client_golang//prometheus:go_default_library", "@com_github_sirupsen_logrus//:go_default_library", "@io_k8s_api//core/v1:go_default_library", diff --git a/prow/kube/config.go b/prow/kube/config.go index f8c38e35fb59..282bf271ad33 100644 --- a/prow/kube/config.go +++ b/prow/kube/config.go @@ -23,6 +23,8 @@ import ( "github.com/sirupsen/logrus" "k8s.io/client-go/rest" "k8s.io/client-go/tools/clientcmd" + + "k8s.io/test-infra/prow/version" ) func kubeConfigs(kubeconfig string) (map[string]rest.Config, string, error) { @@ -48,6 +50,8 @@ func kubeConfigs(kubeconfig string) (map[string]rest.Config, string, error) { if err != nil { return nil, "", fmt.Errorf("create %s client: %v", context, err) } + // This ends up being used for the managed fields owner name, so do not include the version here + contextCfg.UserAgent = version.UserAgent() configs[context] = *contextCfg logrus.Infof("Parsed kubeconfig context: %s", context) } @@ -86,6 +90,8 @@ func LoadClusterConfigs(kubeconfig, projectedTokenFile string) (map[string]rest. localCfg, err := rest.InClusterConfig() if err != nil { logrus.WithError(err).Warn("Could not create in-cluster config (expected when running outside the cluster).") + } else { + localCfg.UserAgent = version.UserAgent() } if localCfg != nil && projectedTokenFile != "" { localCfg.BearerToken = ""