Skip to content

Commit

Permalink
Add gcloud auth in user kubeconfig secret
Browse files Browse the repository at this point in the history
Signed-off-by: Shaad7 <abdullah.alshaad@appscode.com>
  • Loading branch information
AbdullahAlShaad committed Jun 19, 2023
1 parent 3cdae96 commit f541000
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 f541000

Please sign in to comment.