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

Feature | leverage support kubectl #126

Closed
marianod92 opened this issue Oct 18, 2022 · 5 comments
Closed

Feature | leverage support kubectl #126

marianod92 opened this issue Oct 18, 2022 · 5 comments
Assignees

Comments

@marianod92
Copy link

marianod92 commented Oct 18, 2022

What?

Add the ability to manage / configure kubectl with the necessary AWS configuration from leverage-cli

Leverage cli generates subfolders within ~/.aws/ based on the project name for the creation/update of AWS Configs and Credentials files

~/.aws/[PROJECT]/config
~/.aws/[PROJECT]/credentials

When you need to perform actions on a cluster (EKS), besides setting the corresponding context/cluster, it is necessary to export the AWS configuration files, the AWS profile and the location of the .kubeconfig file.

  • For example:

    export AWS_CONFIG_FILE=~/.aws/[PROJECT]/config
    export AWS_SHARED_CREDENTIALS_FILE=~/.aws/[PROJECT]/credentials
    export KUBECONFIG=~/.kube/[PROJECT]/apps-devstg
    export AWS_PROFILE=[PROJECT]-apps-devstg-devops
    

Perhaps being able to support a leverage setting of some of these variables would improve the experience and agility of using leverage to generate the required kubeconfig files/contexts.

Alternative

  • leverage kubectl configure
  • leverage kubectl switch / set

Extra Info

@exequielrafaela
Copy link
Member

@marianod92 @juanmatias @diego-ojeda-binbash @angelofenoglio I'll add some related comments based on our slack thread:

Related issue

Currently to generate the AWS SSO credentials to work with kubectl AWS SSO integration, which is the standard leverage cli workflow auth method, it will always imply to go to the corresponding layer and run leverage aws configure sso || leverage aws sso login to generate / renew credentials and be able to continue working.

Possible solution

@diego-ojeda-binbash proposed an alternative more automated approach which could look something similar to:

"perhaps something like leverage k8s token --cluster [NAME] that we add to the kubeconfig file in order to get the k8s token automatically

@angelofenoglio
Copy link
Contributor

A tool that may help managing multiple kubectl versions in a single workstation is asdf with the kubectl plugin, as explained in this guide.

@Franr
Copy link
Contributor

Franr commented Feb 10, 2023

While working on this, we brought up the question of how to test and develop new commands without installing (as editable) the CLI locally.
It is expected to document the answer as part of the ticket.

@exequielrafaela
Copy link
Member

Thanks for your comment addressing this matter @Franr! 📚 🚀

@Franr Franr mentioned this issue Feb 17, 2023
3 tasks
@Franr
Copy link
Contributor

Franr commented Mar 3, 2023

Also we should add/check the following:

- leverage kubectl configure (initialize at the layer level)
- mount .kube/project_short/config_file - check kubeconfig permission at host level after the execution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants