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

Add stacked KUBECONFIG support #411

Merged
merged 3 commits into from
Feb 10, 2021
Merged

Conversation

kazk
Copy link
Member

@kazk kazk commented Feb 10, 2021

  • Cleaned up config::util
  • current_context in KubeConfig is now Option<String>
  • File paths in Kubeconfig are now remapped to absolute path after reading to support relative paths in stacked config. Assumes paths are unicode (should be fine because Go doesn't have OsString concept).
  • Kubeconfigs are fully merged according to https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/#merging-kubeconfig-files even if kube only needs current_context, contexts, clusters, and auth_infos. If we don't need them, we should remove other fields from Kubeconfig as well because it'll be misleading. I think it's fine to keep.
    • For Option<Preferences> and Option<Vec<NamedExtension>>, we're just taking the first Some because it's unclear what should be done.
  • Returns error when apiVersion/kind is set and mismatches. Not sure if this is correct behavior.

Closes #132

Copy link
Member

@clux clux left a comment

Choose a reason for hiding this comment

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

delimit comment + option nits

looking great. you are really cleaning up the place.

}
match self.extensions.as_mut() {
Some(mut base_exts) => {
if let Some(next_exts) = next.extensions.take() {
Copy link
Member

Choose a reason for hiding this comment

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

This feels like the type of thing where extensions should be Vec<String> with [serde(default, skip_serialize_if = "Option::is_none")] rather than Option<Vec<String>> since we treat missing as empty anyway.

Though it seems we have a convention for Option<Vec<.>> atm so it's a bit of a breaking change 🤔

@kazk
Copy link
Member Author

kazk commented Feb 10, 2021

I think it's good enough now. I'll merge after cleaning up the commits.

@kazk kazk force-pushed the stacked-kubeconfig branch from f466c52 to 8dce23d Compare February 10, 2021 21:08
Copy link
Member

@clux clux left a comment

Choose a reason for hiding this comment

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

looking great. got tests, super readable now.
there's enough to make a new release with this, are you at a good point for 0.50.0?

@kazk
Copy link
Member Author

kazk commented Feb 10, 2021

Yeah 👍 I don't think there's anything else I'd like to include in the next release and want to unblock users with this fix.

@kazk kazk merged commit 8c42f78 into kube-rs:master Feb 10, 2021
@kazk kazk deleted the stacked-kubeconfig branch February 10, 2021 21:24
@kazk
Copy link
Member Author

kazk commented Feb 10, 2021

you are really cleaning up the place.

@clux Thank you for being receptive and quick to respond. It's been a pleasure to work on kube.

I know I went a little crazy the past week :) hyper + tower got me excited, and I wanted to do some clean up while I was off from work.
I'm back to work now, but will start implementing a project using kube (client and controller). Maybe I'll explore unit testing approaches for clients. Now with tower, it should be possible to create a fake like in client-go by creating a mock from resources and using that to create a client. Maybe kube-test crate can provide some convenience builder for it.

@clux
Copy link
Member

clux commented Feb 10, 2021

It's been amazing. The huge hyper/tower hotswap, connection upgrading, tls rewrites, config rewrites, plus all the other hard stuff you've tackled like websockets subresources and schemas.

Really appreciate all the work you've done here. It's made the library a lot more usable and the rust kubernetes story a lot more attractive (even the crd reception was huge). Looking forward to hearing what issues you uncover on the controller side. I am back at work now as well, but reviewing your prs has been the easiest thing to do on the side, always happy to look at more :-)

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

Successfully merging this pull request may close these issues.

Stacked kubeconfigs don't work
3 participants