mirror of https://github.com/k3s-io/k3s
Merge pull request #73003 from liggitt/client-go-plugin-examples
Add docs around importing auth pluginspull/564/head
commit
2d6834b539
|
@ -3,6 +3,25 @@
|
|||
This directory contains examples that cover various use cases and functionality
|
||||
for client-go.
|
||||
|
||||
### Auth plugins
|
||||
|
||||
Client configuration is typically loaded from kubeconfig files containing server and credential configuration.
|
||||
Several plugins for obtaining credentials from external sources are available, but are not loaded by default.
|
||||
To enable these plugins in your program, import them in your main package.
|
||||
|
||||
You can load all auth plugins:
|
||||
```go
|
||||
import _ "k8s.io/client-go/plugin/pkg/client/auth
|
||||
```
|
||||
|
||||
Or you can load specific auth plugins:
|
||||
```go
|
||||
import _ "k8s.io/client-go/plugin/pkg/client/auth/azure"
|
||||
import _ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
|
||||
import _ "k8s.io/client-go/plugin/pkg/client/auth/oidc"
|
||||
import _ "k8s.io/client-go/plugin/pkg/client/auth/openstack"
|
||||
```
|
||||
|
||||
### Configuration
|
||||
|
||||
- [**Authenticate in cluster**](./in-cluster-client-configuration): Configure a
|
||||
|
|
|
@ -31,8 +31,15 @@ import (
|
|||
"k8s.io/client-go/tools/clientcmd"
|
||||
"k8s.io/client-go/util/homedir"
|
||||
"k8s.io/client-go/util/retry"
|
||||
// Uncomment the following line to load the gcp plugin (only required to authenticate against GKE clusters).
|
||||
//
|
||||
// Uncomment to load all auth plugins
|
||||
// _ "k8s.io/client-go/plugin/pkg/client/auth
|
||||
//
|
||||
// Or uncomment to load specific auth plugins
|
||||
// _ "k8s.io/client-go/plugin/pkg/client/auth/azure"
|
||||
// _ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
|
||||
// _ "k8s.io/client-go/plugin/pkg/client/auth/oidc"
|
||||
// _ "k8s.io/client-go/plugin/pkg/client/auth/openstack"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
|
@ -25,6 +25,15 @@ import (
|
|||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
"k8s.io/client-go/rest"
|
||||
//
|
||||
// Uncomment to load all auth plugins
|
||||
// _ "k8s.io/client-go/plugin/pkg/client/auth
|
||||
//
|
||||
// Or uncomment to load specific auth plugins
|
||||
// _ "k8s.io/client-go/plugin/pkg/client/auth/azure"
|
||||
// _ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
|
||||
// _ "k8s.io/client-go/plugin/pkg/client/auth/oidc"
|
||||
// _ "k8s.io/client-go/plugin/pkg/client/auth/openstack"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
|
@ -28,8 +28,15 @@ import (
|
|||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
// Uncomment the following line to load the gcp plugin (only required to authenticate against GKE clusters).
|
||||
//
|
||||
// Uncomment to load all auth plugins
|
||||
// _ "k8s.io/client-go/plugin/pkg/client/auth
|
||||
//
|
||||
// Or uncomment to load specific auth plugins
|
||||
// _ "k8s.io/client-go/plugin/pkg/client/auth/azure"
|
||||
// _ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
|
||||
// _ "k8s.io/client-go/plugin/pkg/client/auth/oidc"
|
||||
// _ "k8s.io/client-go/plugin/pkg/client/auth/openstack"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
Loading…
Reference in New Issue