Skip to content

Commit

Permalink
Merge pull request #924 from Shaad7/gcloud-auth
Browse files Browse the repository at this point in the history
Add gcloud auth in user kubeconfig secret
  • Loading branch information
k8s-ci-robot authored Aug 15, 2023
2 parents db41de4 + f541000 commit 9ef6222
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions cloud/services/container/clusters/kubeconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,15 @@ func (s *Service) createUserKubeconfigSecret(ctx context.Context, cluster *conta
return fmt.Errorf("creating base kubeconfig: %w", err)
}

authProviderConfig := &api.AuthProviderConfig{
Name: "gcp",
Config: map[string]string{
"cmd-args": "config config-helper --format=json",
"cmd-path": "gcloud",
"expiry-key": "'{.credential.token_expiry}'",
"token-key": "'{.credential.access_token}'",
},
execConfig := &api.ExecConfig{
APIVersion: "client.authentication.k8s.io/v1beta1",
Command: "gke-gcloud-auth-plugin",
InstallHint: "Install gke-gcloud-auth-plugin for use with kubectl by following\n https://cloud.google.com/blog/products/containers-kubernetes/kubectl-auth-changes-in-gke",
ProvideClusterInfo: true,
}
cfg.AuthInfos = map[string]*api.AuthInfo{
contextName: {
AuthProvider: authProviderConfig,
Exec: execConfig,
},
}

Expand Down

0 comments on commit 9ef6222

Please sign in to comment.