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

update tsh proxy kube cluster selection ux #30478

Merged
merged 2 commits into from
Aug 15, 2023

Conversation

GavinFrazar
Copy link
Contributor

@GavinFrazar GavinFrazar commented Aug 15, 2023

This PR allows a user to run tsh proxy kube and choose kube cluster(s) by labels, query predicate, name, and/or prefix of name.
Also fixes the --cluster flag not being propagated.

tsh proxy kube already allowed multiple names to be specified, e.g. tsh proxy kube name1 name2 name3 - this PR will allow matching those names by unambiguous prefix individually. If any of them are ambiguous, it's an error, which is consistent with other commands.

Part of the implementation for RFD 129.

Related issue:

Changelog: tsh proxy kube now supports --labels and --query optional arguments.

@github-actions github-actions bot added size/md tsh tsh - Teleport's command line tool for logging into nodes running Teleport. labels Aug 15, 2023
@github-actions github-actions bot requested a review from rudream August 15, 2023 02:07
@smallinsky smallinsky requested a review from greedy52 August 15, 2023 12:37
Copy link
Contributor

@smallinsky smallinsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
@GavinFrazar Can you postpone backporting this PR to v13 after we will complete test plan v14 regression ?

@GavinFrazar
Copy link
Contributor Author

@smallinsky yes, I will hold off and add this to the list of PRs I need to backport once we do the test plan

@GavinFrazar GavinFrazar force-pushed the gavinfrazar/tsh-proxy-kube-ux branch from ab52340 to 0618d61 Compare August 15, 2023 18:17
@GavinFrazar
Copy link
Contributor Author

@zmb3 can we skip the flaky test detector on this one? I can't speedup TestProxyKubeComplexSelectors any further

@zmb3
Copy link
Collaborator

zmb3 commented Aug 15, 2023

/excludeflake TestProxyKubeComplexSelectors

@GavinFrazar GavinFrazar enabled auto-merge August 15, 2023 19:25
* select by labels, query predicate, name, and/or prefix of name.
* fix --cluster flag not being propagated
@GavinFrazar GavinFrazar force-pushed the gavinfrazar/tsh-proxy-kube-ux branch from 0618d61 to a57c613 Compare August 15, 2023 19:26
@GavinFrazar GavinFrazar added this pull request to the merge queue Aug 15, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 15, 2023
@GavinFrazar GavinFrazar added this pull request to the merge queue Aug 15, 2023
Merged via the queue into master with commit 847e239 Aug 15, 2023
@GavinFrazar GavinFrazar deleted the gavinfrazar/tsh-proxy-kube-ux branch August 15, 2023 21:07
@public-teleport-github-review-bot

@GavinFrazar See the table below for backport results.

Branch Result
branch/v13 Failed

GavinFrazar added a commit that referenced this pull request Sep 16, 2023
backports #30478 to branch/v13.

* select by labels, query predicate, name, and/or prefix of name.
* fix --cluster flag not being propagated
GavinFrazar added a commit that referenced this pull request Sep 19, 2023
backports #30478 to branch/v13.

* select by labels, query predicate, name, and/or prefix of name.
* fix --cluster flag not being propagated
GavinFrazar added a commit that referenced this pull request Sep 19, 2023
backports #30478 to branch/v13.

* select by labels, query predicate, name, and/or prefix of name.
* fix --cluster flag not being propagated
github-merge-queue bot pushed a commit that referenced this pull request Sep 19, 2023
* [v13] Fix Kubernetes selected cluster

backports #30167 to branch/v13.

* Fix Kubernetes selected cluster

Kubeconfig context name can be customized using `--set-context-name`
flag. When using it, the selected Kubernetes cluster fails to correctly
identify the cluster name.

* [v13] tsh kube login by prefix, query, labels (#32088)

backports #30252 to branch/v13.

* fetch kube clusters once for login

* [v13] update `tsh proxy kube` cluster selection ux (#32089)

backports #30478 to branch/v13.

* select by labels, query predicate, name, and/or prefix of name.
* fix --cluster flag not being propagated

* [v13] simplify tsh db prefix predicate logic (#32090)

backports #30531 to branch/v13.

* [v13] check for discovered kube cluster name exact match (#32091)

backports #31744 to branch/v13.

* [v13] rework tsh database selection logic (#32092)

backports #31689 to branch/v13.

* disallow prefix matching
* select by exact name match first,
* otherwise look for unambiguous discovered name label match.
* look for an active db to resolve discovered name match ambiguity.
* add more predicate builder helpers
* check for db name in not found error for stale cert hint
* no error status on tsh db logout with no logged in dbs
* remove dead code
* refactor helper funcs to simplify code and make it easier to test
* test complex database selection
* test findActiveDatabase
* test choosing one db by discovered name
* add more resource selectors tests
* test formatDatabaseLoginCommand
* add debug logging for db selection

* [v13] Fix `tsh kube login` when creds are expired or doesn't exist (#32095)

Backports #31418 to branch/v13.

This PR uses `client.RetryWithRelogin` helper to deal with cases where user's
credentials don't exist or are already expired.

Co-authored-by: Tiago Silva <[email protected]>

* remove tsh kube prefix matching (#31852) (#32097)

* fix retry with relogin for ambiguous clusters
* consolidate test setup for login/proxy kube selection tests
* add more test cases for kube selection
* remove prefix testing
* add origin cloud label in tests
* refactor the check for multiple cluster login into a func

* [v13] remove prefix matching in tctl (#32104)

Backports #31916 to branch/v13.

* remove prefix matching in tctl
* replace prefix matching with exact discovered name match as a fallback
  when no resource full name matches the name given by a user
* refactor test helpers
* avoid decoding yaml/json into already initialized var

---------

Co-authored-by: Tiago Silva <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/branch/v13 kubernetes-access size/md tsh tsh - Teleport's command line tool for logging into nodes running Teleport.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants