Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temporary kubeconfig is not being used in privileged shell #49

Closed
jessesomerville opened this issue Apr 13, 2021 · 2 comments
Closed

Temporary kubeconfig is not being used in privileged shell #49

jessesomerville opened this issue Apr 13, 2021 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@jessesomerville
Copy link
Contributor

No description provided.

@jessesomerville jessesomerville added the bug Something isn't working label Apr 13, 2021
@jessesomerville jessesomerville self-assigned this Apr 13, 2021
@jessesomerville
Copy link
Contributor Author

jessesomerville commented Apr 13, 2021

Current implementation uses gcloud container clusters get-credentials to generate the temporary privileged kubeconfig. The implementation of that command (as seen here) just reads the users gcloud config to get the credentials.

The kubectl implementation of the gcloud auth provider just pulls the users tokens from the fields specified here

@jessesomerville
Copy link
Contributor Author

The cmd/eiam/internal/proxy/shell.go:startShell method was generating a temporary kubeconfig for the privileged session using gcloud container clusters get-credentials. This command adds a new context to the kubeconfig with the gcp auth provider plugin that uses GCP credentials to provide tokens for kubectl to authenticate itself to the apiserver. This auth provider plugin simply instructs kubectl to run gcloud config config-helper --format=json and get the access token from the output, resulting in kubectl commands being authenticated as the default user account stored in the active gcloud config, not the service account for the privileged session.

The fix for this is to add the service account token info to the access-token and expiry fields in the generated kubeconfig. These fields are intended to be used as a token cache, and the value in the access-token field will be used by kubectl to authenticate API calls until the time specified in the expiry field.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

1 participant