Repository: prometheus/prometheus (language: go)

Issue:
Cannot create 'kubernetes_sd_config' service discovery with 'no Auth Provider found for name \"gcp\"'
**What did you do?**
My Prometheus is outside of k8s clsuter.

I added a new service discovery config:
```- job_name: k8s_nodes
  kubernetes_sd_configs:
  - kubeconfig_file: /etc/prometheus/kube.config
    role: node
```
The kube config is created using `gcloud` to work with GKE (google managed k8s).

kube.config:
```
apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: ***
    server: https://*.*.*.*
  name: foo
contexts:
- context:
    cluster: foo
    user: bar
  name: foo
current-context: foo
kind: Config
preferences: {}
users:
- name: bar
  user:
    auth-provider:
      config:
        access-token: ***
        cmd-args: config config-helper --format=json
        cmd-path: /usr/lib/google-cloud-sdk/bin/gcloud
        expiry: "2022-03-30T16:50:08Z"
        expiry-key: '{.credential.token_expiry}'
        token-key: '{.credential.access_token}'
      name: gcp
```

**What did you expect to see?**
New service discovery.

**What did you see instead? Under which circumstances?**
An error reporting: 

> caller=manager.go:317 level=error component="discovery manager scrape" msg="Cannot create service discovery" err="no Auth Provider found for name \"gcp\"" type=kubernetes

**Environment**

* System information:
	Linux 5.13.0-1021-gcp x86_64

* Prometheus version:
> prometheus, version 2.34.0 (branch: HEAD, revision: 881111fec4332c33094a6fb2680c71fffc427275)
  build user:       root@121ad7ea5487
  build date:       20220315-15:18:00
  go version:       go1.17.8
  platform:         linux/amd64

* Alertmanager version:

* Prometheus configuration file:
```
alerting: {}
global: {}
remote_read: []
remote_write:
- url: http://localhost:2003/write
  write_relabel_configs:
  - action: drop
    regex: '1'
    source_labels:
    - nographite
  - action: keep
    regex: '[0-9]+'
    source_labels:
    - nested_count
rule_files:
- /etc/prometheus/rules.d/*.yaml
scrape_configs:
- job_name: k8s_nodes
  kubernetes_sd_configs:
  - kubeconfig_file: /etc/prometheus/kube.config
    role: node
```
* Logs:
```
caller=manager.go:317 level=error component="discovery manager scrape" msg="Cannot create service discovery" err="no Auth Provider found for name \"gcp\"" type=kubernetes
```
I made some research looking for such errors and found that starting from some point explicit import of *gcp* auth plugin is required (`k8s.io/client-go/plugin/pkg/client/auth/gcp`). Something like described at terraform issue  https://github.com/hashicorp/terraform/issues/15244. Frankly speaking I haven't understand how exactly prometheus code works while parsing kubeconfig, just that it imports a piece of k8s - "k8s.io/client-go/tools/clientcmd" but looks like it's not enough in my case.


Discussion / hints:
Yeah, I'm not sure when this happened, but I also noticed in other projects that adding this import is now required:

```
	// Required to get the GCP auth provider working.
	_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
```

I would say let's add that to here: 

https://github.com/prometheus/prometheus/blob/c31a3e4c92bf30ce8d9237e18752a9aaa39d91f4/discovery/kubernetes/kubernetes.go#L43-L46

Would you like to do give this a try?
> Would you like to do give this a try?

Yes, I could try.

Fix patch:
diff --git a/discovery/kubernetes/kubernetes.go b/discovery/kubernetes/kubernetes.go
index 506d6882f87..4fa561b6eb4 100644
--- a/discovery/kubernetes/kubernetes.go
+++ b/discovery/kubernetes/kubernetes.go
@@ -45,6 +45,9 @@ import (
 	"k8s.io/client-go/tools/cache"
 	"k8s.io/client-go/tools/clientcmd"
 
+	// Required to get the GCP auth provider working.
+	_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
+
 	"github.com/prometheus/prometheus/discovery"
 	"github.com/prometheus/prometheus/discovery/targetgroup"
 )


Test patch: