Repository navigation
feat(telepresence): refresh hour-long environment tokens with a credential plugin - #98
Merged
Merged
Conversation
…credential plugin Environment tokens now expire after an hour on current clusters. The kubeconfig telepresence connect writes holds no token; it runs the hidden shipyard telepresence credential command, which fetches a fresh kubeconfig from core and prints its token as an ExecCredential expiring just before the token does.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Environment kubeconfigs are moving from never-expiring service-account tokens to 1-hour TokenRequest tokens (nautilus#854).
exec,logsandport-forwardaren't affected:Telepresence is different. Its daemon keeps making API requests with the token it was given, so a session would lose API access after an hour.
Change
telepresence connect, and the MCPtelepresence_connecttool, now write a~/.shipyard/kubeconfigthat holds no token. Instead its user has aclient.authentication.k8s.io/v1exec credential plugin: this executable's hiddenshipyard telepresence credential --env <id>command.ExecCredential:expirationTimestampis 2 minutes before the JWT'sexp, so client-go asks again in time;exp, so their credential has no expiry, and client-go keeps them until it gets a 401.--configpath;--org=(always set, even when empty);SHIPYARD_API_URL(always set, including the default);SHIPYARD_API_TOKEN, so the config is read again;telepresence quit -sand reconnect. The API token itself is never written to the kubeconfig.Compatibility
exec,logsandport-forward. Their telepresence sessions lose API access after about an hour, and needtelepresence quit -sand a reconnect.Tests
exp, inside the margin, noexp, opaque token);go test ./...passes. golangci-lint reports nothing new; its 9 findings are all in untouched files.shipyard telepresence credentialprinted a v1 ExecCredential with no expiry (legacy token).kubectl get podswith a kubeconfig whose user is this plugin listed the environment's pods.Verify on QA (after nautilus#854 is deployed)
shipyard --config ~/.shipyard/qa.yaml telepresence connect --env <env>, thentelepresence listworks.grep -c 'token:' ~/.shipyard/kubeconfigprints 0, and the file has anexec:block.shipyard telepresence credential --env <env> | jq .status.expirationTimestampshows about now + 58 minutes. Don't print.status.token.telepresence liststill works, and the daemon log (telepresence gather-logs) shows the plugin ran again.