-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Allow the re-use of a IAM role that is not created by kops. #2440
Allow the re-use of a IAM role that is not created by kops. #2440
Conversation
3192dcd
to
4937329
Compare
pkg/apis/kops/cluster.go
Outdated
// Use an existing custom cloud security policy for the instances. One example is to specify the name | ||
// of an AWS IAM role for the master and another for the nodes. | ||
// Map is keyed by: master, node | ||
CustomPolicies *map[string]string `json:"customPolicies,omitempty"` |
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.
No reason to have a pointer to a map, I believe; just use a map.
And should we just have a strongly typed object? i.e.
iam:
master: override-master
node: override-node
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 a strongly typed object isn't right, we should use the InstanceGroups roles as the keys, either explicitly (map[Role]string
) or just in comments / code.
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 like a typed object
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 was following the custom roles as an example, which probably should be a object as well
AdmissionControl []string `json:"admissionControl,omitempty" flag:"admission-control"` | ||
ServiceClusterIPRange string `json:"serviceClusterIPRange,omitempty" flag:"service-cluster-ip-range"` | ||
|
||
// TODO: Remove unused BasicAuthFile |
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 there a reason to add these comments in this PR?
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.
Snuck in
VSphereResourcePool *string `json:"vSphereResourcePool,omitempty"` | ||
VSphereDatastore *string `json:"vSphereDatastore,omitempty"` |
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.
Any reason to move this?
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.
Will fix
pkg/model/iam.go
Outdated
@@ -64,33 +68,63 @@ func (b *IAMModelBuilder) Build(c *fi.ModelBuilderContext) error { | |||
// Generate IAM objects etc for each role | |||
for _, role := range roles { | |||
name := b.IAMName(role) | |||
roleAsString := reflect.ValueOf(role).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.
Is this string(role)
?
pkg/model/iam.go
Outdated
|
||
arn := "" | ||
|
||
if b.Cluster.Spec.CustomPolicies != nil && featureflag.CustomPoliciesSupport.Enabled() { |
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 the feature flag isn't set, this should be an error, not silently ignored. Probably in validation.
This may not need a feature flag.
pkg/model/iam.go
Outdated
Name: &roleName, | ||
ID: &arn, | ||
|
||
// We set Policy Document to nil as this role will be managed externally |
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 thought this deleted the role?
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.
More context please
@@ -87,6 +82,9 @@ func (s *IAMInstanceProfileRole) CheckChanges(a, e, changes *IAMInstanceProfileR | |||
if e.InstanceProfile == nil { | |||
return fi.RequiredField("InstanceProfile") | |||
} | |||
if a.Role != e.Role { |
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 think you need to check the ID here, not reference equality.
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 catch
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.
Fixed
@@ -60,9 +58,6 @@ func (e *IAMInstanceProfileRole) Find(c *fi.Context) (*IAMInstanceProfileRole, e | |||
|
|||
ip := response.InstanceProfile | |||
for _, role := range ip.Roles { | |||
if aws.StringValue(role.RoleId) != roleID { |
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.
Not sure why we removed this?
- us-test-1a | ||
Cloud: aws | ||
KubernetesVersion: v1.4.8 | ||
MasterIAMRole: foo |
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 MasterIAMRole / NodeIAMRole mapped somewhere?
@@ -38,6 +39,13 @@ func TestCreateClusterMinimal(t *testing.T) { | |||
runCreateClusterIntegrationTest(t, "../../tests/integration/create_cluster/minimal", "v1alpha2") | |||
} | |||
|
|||
// TODO: https://github.com/kubernetes/kops/issues/2438 |
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.
Answered how to set a FF. Though a FF might not even be necessary here, particularly if we have validation.
docs/iam_roles.md
Outdated
|
||
```yaml | ||
customPolicies: | ||
node: "arn:aws:iam::123456789012:role/kops-node" |
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.
FYI - looks like the code is only matching "Node" and "Master" (first letter capitalized)
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 am going to make it an object
@chrislovecnm @justinsb Hey guys - we're trying to use this feature to set up our cluster using pre-made IAM roles. We have very limited access to create roles, so this feature seems to fit our needs. However, although it seems to picking up on the roles that our administrator created for us, the cluster creation is still trying to edit the inline policies that we had set, which is failing due to the fact that we have no control at all over IAM resources. Any ideas? For reference, here's exactly what we're seeing:
|
017a3d0
to
631db08
Compare
631db08
to
f4dfcc7
Compare
cf367a7
to
7f651ed
Compare
7f651ed
to
a471b93
Compare
Hi what is the status for this? It seems there are multiple PR such as this one #2139 Which one to track? Is that already released in its simplest form? |
#2139 was closed, and this will hopefully be merged |
a471b93
to
a4d34cf
Compare
Blocked on #2763 |
#2763 was merged, so this is unblocked, and just needs the merge conflict resolved, right? |
@chrislovecnm PR needs rebase |
a4d34cf
to
116b029
Compare
@chrislovecnm PR needs rebase |
@justinsb thanks for the response. I do not understand how your different use cases would allow a user to reuse an IAM instance profile. The kops user IAM perms would not have the capability to make any modifications to IAM. You mention modifying the role in multiple parts of your use case. Second question 'adding' permissions. IAM roles are very complex with the use of wild cards. How can we tell that we are missing a permission? Parsing the IAM profile information is quite challenging. Maybe we can use the IAM test API, but I am not certain. The need that we have is that we cannot do any CRUD with IAM. If the name is different we cannot delete the profile. If the permissions are different we cannot update the role. We need to reuse an existing profile instance. How does your design satisfy that need? |
So as discussed in office hours today, a plan for getting this merged (not necessarily in order): a) ability to change the names of the IAM resources that kops creates (and kops still creates them here) |
Can we make a) ability to change the names of the IAM resources that kops creates (and kops still creates them here) |
f543698
to
9548cf4
Compare
63a1f48
to
e88c6f5
Compare
e88c6f5
to
bb9182a
Compare
This way Cluster IAM roles can be managed externally, either manually, using cloudformation or any other tool.
bb9182a
to
7d4329a
Compare
@chrislovecnm PR needs rebase |
Just curious what needs to be done to move this forward? My use case is identical to @dcowden's, we need roles and policies managed externally not by Kops and to instead pass the instance profile ARNs to the cluster spec. I can offer to help if its a time/resource issue. |
@rifelpet would welcome the help! I am still working on security groups and file assets. We have decided to modify the api from how it was implemented here. There is another PR open for the new api. Do you want to chat? |
This is the original PR submitted by @sp-borja-juncosa with some tweaks.
AdditionalPolicies
map.Again thanks @sp-borja-juncosa!! Closing this: #2139
TODO
Next Steps
I have various next steps documented here: #2440
When I get past the first two TODOs, this will be ready for merge.
This change is