Skip to content
This repository has been archived by the owner on Mar 5, 2024. It is now read-only.

Implement regional STS endpoint support #229

Merged
merged 3 commits into from
Mar 13, 2019
Merged

Conversation

cjbradfield
Copy link
Contributor

fixes #190

Joseph-Irving
Joseph-Irving previously approved these changes Mar 11, 2019
Copy link
Contributor

@Joseph-Irving Joseph-Irving left a comment

Choose a reason for hiding this comment

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

thanks for the pr!, it lgtm, any objections @pingles?

@pingles
Copy link
Contributor

pingles commented Mar 11, 2019

Love it :-)

Only comment would be to maybe add a default/enum to make it easier for operators to understand what value to set in the flag?

@zytek
Copy link
Contributor

zytek commented Mar 11, 2019

Will this support aws china regions? I have problem deploying kiam on kops-provisioned cluster in aws-cn, and this is possibly cause kiam tries to talk to global aws sts endpoint and not china local.

@cjbradfield
Copy link
Contributor Author

Love it :-)

Only comment would be to maybe add a default/enum to make it easier for operators to understand what value to set in the flag?

Sure, I can do that. I'm thinking something like "global-endpoint" as it would be highly unlikely for AWS to use that as a region.

@cjbradfield
Copy link
Contributor Author

Will this support aws china regions? I have problem deploying kiam on kops-provisioned cluster in aws-cn, and this is possibly cause kiam tries to talk to global aws sts endpoint and not china local.

The diff does support regional endpoints in China assuming they exist (I haven't tested there).

@cjbradfield
Copy link
Contributor Author

Love it :-)

Only comment would be to maybe add a default/enum to make it easier for operators to understand what value to set in the flag?

Oh wait did you mean replicate all the region list as an enum? Although I see benefit in that, we'd have to constantly edit the list when AWS adds regions which seems error prone. Perhaps I can just add an example to the flag description?

I'm also not a fan of the previous diff I just posted (i'd prefer to leave it the zero value of the string and explain the behavior in the description). I think I misunderstood your feedback.

Anyway, thanks for the opportunity to contribute!

@pingles
Copy link
Contributor

pingles commented Mar 12, 2019 via email

@zytek
Copy link
Contributor

zytek commented Mar 12, 2019

Could region be auto-discovered from EC2 Metadata / kubernetes labels?

You could also update docs/readme to point out this new feature.

Gonna check this in aws-cn today.

@zytek
Copy link
Contributor

zytek commented Mar 12, 2019

I can confirm that kiam built from this PR works fine in AWS China. Region autodiscovery would be a nice bonus.

… lookup.

Refactor to cache the result so that we don't validate the region on every request.
@cjbradfield
Copy link
Contributor Author

cjbradfield commented Mar 13, 2019

I can confirm that kiam built from this PR works fine in AWS China. Region autodiscovery would be a nice bonus.

Hmm. Well, this would get me what I want as-is. I'll add it if everyone agrees it makes the whole thing a lot better.

The only downside I could see is it binds kiam-server to running in-cluster. That may be the case already. I also don't know how we would support the fips regions as well (technically, they aren't regions but the Go SDK treats them that way).

@zytek
Copy link
Contributor

zytek commented Mar 13, 2019

The only downside I could see is it binds kiam-server to running in-cluster. That may be the case already. I also don't know how we would support the fips regions as well (technically, they aren't regions but the Go SDK treats them that way).

I don't think this is a big issue, as when kiam fails to discover region via EC2 Metadata it can fall back to old behavior. Anyway, this can be a scope of another PR.

Thanks for this submission, it saved my day ;-)

@pingles
Copy link
Contributor

pingles commented Mar 13, 2019

It'd be cool to have it auto-discover but I'm also happy for it to default to current behaviour (and add a second for the auto-discovery later).

Only comment would be if we can add some help docs to the flags to indicate the kinds of values you could set: eu-west1, us-east1 etc. It doesn't have to be exhaustive but useful to give operators an easy way to see the kinds of values they could set.

As I said earlier, other thing I'd like (if possible) would be something that could validate and fail early if someone provides a bad region (typo etc.) as we wouldn't want to start the server, it accept connections and never be able to generate credentials.

@cjbradfield
Copy link
Contributor Author

It'd be cool to have it auto-discover but I'm also happy for it to default to current behaviour (and add a second for the auto-discovery later).

Only comment would be if we can add some help docs to the flags to indicate the kinds of values you could set: eu-west1, us-east1 etc. It doesn't have to be exhaustive but useful to give operators an easy way to see the kinds of values they could set.

As I said earlier, other thing I'd like (if possible) would be something that could validate and fail early if someone provides a bad region (typo etc.) as we wouldn't want to start the server, it accept connections and never be able to generate credentials.

@pingles did you have a chance to look at the updated PR? In it I updated the flag description to include an example and also information about the default behavior.

The regional endpoint is now validated based on the existence of a region as well as DNS resolution of the hostname of the endpoint. In addition, I cache the ResolvedEndpoint so that these checks aren't performed after the initial endpoint resolution.

I have also added a bullet point to the features list in the README.md

Let me know if you want more examples. The tests also will test the resolution of the endpoint. It might be best to make one more change there to make the resolver parametric for testability so that you don't need network connectivity to run the tests.

@pingles
Copy link
Contributor

pingles commented Mar 13, 2019

Fantastic, thanks for the contribution!

@Joseph-Irving be great if you guys could cut a release when you can 😄

@pingles pingles merged commit adf03bb into uswitch:master Mar 13, 2019
charlievieth added a commit to charlievieth/kiam that referenced this pull request Sep 27, 2019
This fixes uswitch#229 while also cleaning up the run logic to catch the error
returned by server.Serve() and log when iptables changes are being
undone.
charlievieth added a commit to charlievieth/kiam that referenced this pull request Sep 27, 2019
This fixes uswitch#229 while also cleaning up the run logic to catch the error
returned by server.Serve() and log when iptables changes are being
undone.
@cjbradfield cjbradfield deleted the regional branch December 20, 2019 01:37
Joseph-Irving pushed a commit that referenced this pull request May 18, 2020
* agent: fix #229: ensure deferred funcs run + cleanup

This fixes #229 while also cleaning up the run logic to catch the error
returned by server.Serve() and log when iptables changes are being
undone.

* agent: handle server shutdown and error

Handle server shutdown directly in the run() command and log any errors.
Previously, the code relied on a deferred call to close to stop the
server and errors were ignored.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Regional STS Endpoint
4 participants