-
Notifications
You must be signed in to change notification settings - Fork 51
Updated authentication for Kubernetes #186
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
Updated authentication for Kubernetes #186
Conversation
I have changed how the login works by using the When a user logs out the default config file is loaded again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, just a few questions and nits to start
Tested this out and works as expected. LGTM! |
cb3d49a
to
dc4acc7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quick issue I noticed when testing. This is the current behavior when namespace cannot be found:
get_current_namespace()
returns: "Unable to find current namespace please specify with namespace=<your_current_namespace>"ClusterConfiguration()
(without setting namespace) works and generates yaml when passed into cluster withnamespace=Unable to find current namespace please specify with namespace=<your_current_namespace>
What we want is probably something more along the lines of:
get_current_namespace()
returnsNone
in that case and prints a message like "Unable to find current namespace"Cluster(ClusterConfiguration()
fails if the namespace in the configuration is set toNone
, and tells the user "Unable to find current namespace, please specify in your ClusterConfiguration with namespace=<your_current_namespace>"
So like after line 71 in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks very good 👍
One thing though that is something of a simple change but, will impact a lot of the implementation. 😬
Can we make api_config_handler()
and config_check()
generic auth functions instead of class methods? It looks odd to invoke both authentication type classes on every call, especially when a users should only ever be using one anyways.
Is there any reason we can't separate these from the classes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes! :)
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything seemed to work great, except one critical edge case:
- When doing a token login, I can just pass in no token at all (or no server), and it leads to all sorts of broken behavior (those should not have defaults)
- Also, when I pass in an incorrect token, it will still tell me I've "logged in", only to fail later down the line
Also, how are you obtaining/generating the ca cert that you are passing in when testing the Token approach? I'd like to test that as well, have just been testing with tls-skip for now.
EDIT: Realized if you're on RHEL the default path is probably where your ca cert bundle is, not sure how to do it on mac os though...
That was a great catch about default values for the token. I'll update the PR. |
Looking into how we can pass an incorrect token and catch that and there doesn't seem to be any errors for when you set up the configuration even with bad credentials. Only when the api instance is used will an error be thrown e.g. I found this, we can call |
@Bobbins228 the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This reverts commit 2ced60d.
Update authentication for Kubernetes
references #185
#146
A user can now authenticate using their own k8s config file.
A user can authenticate with their token and server address.
All methods that used
config.load_kube_config()
have been updated to check if a user has already specified their own config file so it isn't overridden.How to test the new authentication methods
git pull https://github.com/Bobbins228/codeflare-sdk.git
git checkout update-authentication
Run
poetry build
within the codeflare-sdk folder to build your own wheel.Install the sdk with
pip install codeflare_sdk-0.0.0.dev0-py3-none-any.whl
Import the necessary classes.
Loading a user's own config file
Authenticating with token + server
Authenticating with certificate
Authenticating by skipping tls verification
Logging out
auth.logout()