-
Notifications
You must be signed in to change notification settings - Fork 84
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
aws-iam-authenticator support added (2) #111
base: master
Are you sure you want to change the base?
Conversation
Thanks for adding this @slyoldfox! @slyoldfox -- I made a release build (
|
@philipbjorge I had the same issues running with the aws-iam-authenticator binary, but since awscli now generates it with Try updating to the latest awscli which supports the get-token construct and use them like this in your .kube/config:
And of course make sure you your profile name matches with the one from your aws-adfs login, check with Drop me your .kube/config files if it doesn't work and I'll try debugging it. |
I pulled this down today because I wanted to give click a try with AWS EKS and that wasn't working with the current release. Had to merge databricks/master into it since rust threw a few errors compiling dependencies (rustyline). But, once that was cleared up this worked immediately for me with my existing kubeconfig. My build error was the same one that caused Travis to mark this as failed, so pulling master into this resolves that failing check. |
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.
Cool! Thanks for sticking with this though the delays. I'm okay with having this as a separate thing from AuthProvider for now, although I would at some point like to merge them more.
I've left a few small things I'd like changed, but then I think it can be merged.
src/config/kubefile.rs
Outdated
@@ -104,6 +107,91 @@ pub struct ContextConf { | |||
pub user: String, | |||
} | |||
|
|||
#[derive(Debug, Deserialize, Clone)] | |||
#[allow(non_snake_case)] |
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.
are you using this so that the deserialize finds the fields? if so, rather do something like this:
#[derive(Debug, Deserialize, Clone)]
pub struct Exec {
#[serde(rename = "apiVersion")]
api_version: String,
pub args: Option<Vec<String>>,
pub command: Option<String>,
pub env: Option<Vec<Env>>,
pub token: RefCell<Option<String>>,
pub expiry: RefCell<Option<DateTime<Utc>>>,
}
src/config/kubefile.rs
Outdated
} | ||
|
||
#[derive(Serialize, Deserialize)] | ||
#[allow(non_snake_case)] |
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.
ditto to above about snake case thing
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.
Done
apiVersion: String, | ||
pub args: Option<Vec<String>>, | ||
pub command: Option<String>, | ||
pub env: Option<Vec<Env>>, |
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.
Can you not just make this an Option<HashMap<String, String>>
directly? I think serde should just "do the right thing" in that case.
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.
I tried this and the suggestions below. It compiles fine, but when I start click it gives the following error which I don't understand:
$ cargo build && ./target/debug/click
Compiling click v0.4.2 (/Users/user/Code/click/click)
Finished dev [unoptimized + debuginfo] target(s) in 8.77s
Could not load kubernetes config. Cannot continue. Error was: Couldn't read yaml in '/Users/user/.kube/config': invalid type: sequence, expected a map
I'm not understanding why, as the generate_token function is not even called when starting, just after the first request to the API.
Any ways I can debug this faster?
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.
@nicklan
Apparently serde doesn't like parsing the following when it's a
Option<HashMap<String, String>>
users:
- name: eks-acceptance
user:
exec:
apiVersion: client.authentication.k8s.io/v1alpha1
args:
- --region
- eu-west-1
- eks
- get-token
- --cluster-name
- eks-acceptance
command: aws
env:
- name: AWS_PROFILE
value: default
I suppose it's something you could test too, it happens just after starting the application. For some reason it doesn't like the env
. Not sure why.
} | ||
|
||
fn generate_token(&self) -> String { | ||
let mut filtered_env: HashMap<String, String> = HashMap::new(); |
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.
If we make the above change to have self.env
be a HashMap, this shouldn't be needed. Below you can just do:
let output = Command::new(self.command.clone().unwrap())
.args(self.args.clone().unwrap())
.envs(&self.env)
.output()
.expect("failed to execute process");
Without testing myself I'm not sure you won't have to clone it, since envs
want's an IntoIter
, so you may need to do that.
I took another look at #111 (comment) The crash is on this line and occurs because
When setting the value to |
I believe this is provided now by what I merged in #129. If anyone who is interested in EKS auth could try that out, that would be great. I tested by adding the cluster to my config via |
Synced the PR from #78 with the latest master branch and added some caching for the token.
At the moment haven't reused much from
AuthProvider
since it does seem a bit different to me.If you have any remarks (my rust experience is 0), please let me know @nicklan