-
Notifications
You must be signed in to change notification settings - Fork 18
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 AWSIAMRole CRD for flexible role assignment #13
Conversation
Pull Request Test Coverage Report for Build 85
💛 - Coveralls |
a5ba3e6
to
6baf1f4
Compare
4547b31
to
3e935c1
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.
A few things to consider, that I couldn't comment on at the line level since this patch didn't touch the pertinent areas of the code:
- Update Secrets more carefully
When updating a Secret consider constraining the update on matching the resource version, and if it fails due to a version mismatch, reread the Secret and try again (no more than some fixed number of times). - Do we watch pods only to post events to them?
If so, consider removing that capability, so that your controller doesn't need a pod cache (a scaling limitation that presents a headache to cluster operators). - Have you considered integrating kubebuilder?
Though you've already paid the cost of arranging for code generation, integrating kubebuilder could remove some of the boilerplate code here.
Have you been running this controller since posting this patch? How is it working so far?
docs/aws_iam_role_crd.yaml
Outdated
minLength: 3 | ||
roleSessionDuration: | ||
description: | | ||
Specify the tole session duration in seconds. defaults to 3600 |
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.
s/tole/role/
s/defaults/Defaults/
roleSessionDuration: | ||
description: | | ||
Specify the tole session duration in seconds. defaults to 3600 | ||
seconds (1 hour). This value must be less than or equal to 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.
What happens if this value is greater than "MaxSessionDuration?" Does it get clamped to that value, or does something fail?
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 assume the API call to sts assumeRole would throw an error which would propagate as an event on the AWSIAMRole resource
roleARN: | ||
type: string | ||
expiration: | ||
type: string |
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.
What's the format of this value? Presumably it's a time instant formatted as a string.
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.
Yes, RFC3339 formatted string in UTC (I'm not sure if kubectl can somehow show the local time given a timestamp string?)
type: integer | ||
minimum: 900 # 15 minutes | ||
maximum: 43200 # 12 hours | ||
roleDefinition: |
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.
Is this CRD defining a new IAM role, or is this a snapshot of an existing IAM role as read from AWS?
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.
Yes, the idea, which is not yet implemented and won't be in this PR, is to allow users to define an IAM role via the CRD as an alternative to referencing it. This would then take care of provisioning the IAM role with the correct assume role configuration etc.
I will remove this from this PR, was just easier to design the whole thing with this idea in mind.
name: kube-aws-iam-controller | ||
rules: | ||
- apiGroups: | ||
- "amazonaws.com" |
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 we really claim this group name? I think it's best left for software actually published by the trademark holder. Perhaps something involving "kube," "iam," and "aws" would be safer.
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.
Good point, I also thought about this but went with it anyway since kube2iam does the same and no complaints from AWS :) But you are right, let's use a less trademark infringing value.
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.
mikkel.labs/aws-iam
?
- apiGroups: | ||
- "" | ||
resources: | ||
- pods |
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.
Why does the controller watch pods? Is this to help clean up orphaned (no longer referenced) Secrets? Is it to decide whether to keep renewing credentials for Secrets that are no longer referenced?
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.
The old support for generating secrets based on the aws-iam-
prefixed secret mount is still supported here. I would remove it in a later PR to not break existing users without a possibility of an upgrade path.
|
||
SRC="github.com" | ||
GOPKG="$SRC/mikkeloscar/kube-aws-iam-controller" | ||
CUSTOM_RESOURCE_NAME="amazonaws.com" |
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.
Again, I suggest reconsidering use of this name for which we're not the trademark holder.
Thanks a lot for the review, let me answer your questions inline.
This should already be handled by client-go. If we get any error on update then it will be retried in the next iteration, IMO no need to add retries directly to this call unless it becomes a problem.
It's to support the old
I have not really considered it. The code generation as-is is fairly simple IMO and I would avoid adding another build dependency unless it really provides a benefit.
Not really, have only been running it for testing but nothing real so far. This is mostly due to other priorities right now, but I didn't find any issues in my tests, just didn't get around to merging yet :) |
38f2631
to
d5e94eb
Compare
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
d5e94eb
to
80db556
Compare
This implements support for a simple
AWSIAMRole
CRD which makes it possible to reference a role name or full arn and get a corresponding secret with IAM role credentials generated, which can be mounted into a pod.It works like this:
The controller will look for resources of type
AWSIAMRole
which looks like this:And it will create a matching secret
my-app-iam-role
with credentials for the referenced role.This should solve most of the issues raised in #12
Additionally to being able to referencing a role in the
AWSIAMRole
resources, I also think about making it possible to specify a full role definition and have the controller provision the role in AWS. This would make it possible to provision AWS IAM roles completely through Kubernetes and would make it possible to hide the complexity of specifying assumeRole relationships between roles from the user. I.e. users would no longer need to define that thekube-aws-iam-controller
role should be able to assume the user role as this could be injected transparently.The reason I think we need to support both a simple
roleReference
and role provisioning is that it makes it more flexible and potentially easier to migrate from other solutions tokube-aws-iam-controller
.It also allows providing nicer feedback for users, like a status section of the CRD showing the full role arn and expiration date:
/cc @seh