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 command eksctl utils aws-auth #623

Merged
merged 8 commits into from
Mar 13, 2019
Merged

Add command eksctl utils aws-auth #623

merged 8 commits into from
Mar 13, 2019

Conversation

rndstr
Copy link
Contributor

@rndstr rndstr commented Mar 11, 2019

Adds the command

eksctl utils aws-auth --name=<name> [--add-admin-role=<arn>] [--remove-role=<arn>] [--add-account=<number>] [--remove-account=<number>]

to allow modifying the kube-system/aws-auth object which is a mapping from IAM entities to Kubernetes groups.

@rndstr rndstr changed the title Add support for groups to authconfigmap Extend authconfigmap to allow role groups and accounts Mar 11, 2019
@rndstr rndstr force-pushed the add-admin-role branch 2 times, most recently from f6a000e to 5306e57 Compare March 12, 2019 00:11
@rndstr rndstr changed the title Extend authconfigmap to allow role groups and accounts Add command eksctl utils aws-auth Mar 12, 2019
@rndstr rndstr marked this pull request as ready for review March 12, 2019 00:45
@rndstr rndstr requested a review from errordeveloper March 12, 2019 00:45
Copy link
Contributor

@mumoshu mumoshu left a comment

Choose a reason for hiding this comment

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

Hey! I think this is great even at this point.

The benefit of this improvement and the addition of addAccount() is that (to me) this opens up possibility to manage additional mapRoles and mapAccounts in our ClusterConfig.

Perhaps your original motivation could be either to:

  • implement eksctl utils aws-auth [map|unmap] [account --id AWS_ACCOUNT_ID|role --arn ROLE_ARN --username USERNAME --groups GROUP1,GROUP2] on top of this, or
  • enhance ClusterConfig and add eksctl utils apply-aws-auth -f cluster.yaml to update the aws-auth configmap according to the mappings in ClusterConfig.

If that's the case, I would have thought that I liked the latter, but WDYT?

@rndstr
Copy link
Contributor Author

rndstr commented Mar 12, 2019

@mumoshu thanks for the suggestions. this PR is motivated by the former (sorry for scarce PR description). I briefly went over this with @errordeveloper beforehand and we were talking about a separate command.

What I'm personally looking for is the functions to simplify adding/removing roles/accounts, so the command is secondary to me.

I prefer your suggestion over mine (dislike the verbs in my args), so I'll change this.

@rndstr
Copy link
Contributor Author

rndstr commented Mar 12, 2019

@mumoshu wdyt about omitting the --id and --arn flags and use them as args instead? eksctl utils aws-auth [map|unmap] [account AWS_ACCOUNT_ID|role ROLE_ARN --username USERNAME --groups GROUP1,GROUP2]

I reckon an argument against this would be the convention to use the first arg as cluster name seen in most commands.

Copy link
Contributor

@errordeveloper errordeveloper left a comment

Choose a reason for hiding this comment

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

Looks great overall, just a few nits :)

pkg/authconfigmap/authconfigmap.go Outdated Show resolved Hide resolved
pkg/authconfigmap/authconfigmap.go Outdated Show resolved Hide resolved
@errordeveloper
Copy link
Contributor

errordeveloper commented Mar 12, 2019

@rndstr I don't mind merging it as is, and we can have a separate conversation about the CLI design.

I think it would make sense to consider this:

eksctl auth <add-account|remove-account> AWS_ACCOUNT_ID
eksctl auth <add-role|remove-role> ROLE_ARN --username USERNAME --groups GROUP1,GROUP2

But it also seems plausible to provide full create/get/delete, and perhaps we should think about treating it as a first-class resource, i.e.:

eksctl <create|get|delete> account
eksctl <create|get|delete> role

I'm not sure what's best, also the underlying details may change as EKS may finally move to a CRD instead of this configmap... so whatever we do now may have to change sooner or later. I'd really vote for keeping it as is for now.

@rndstr
Copy link
Contributor Author

rndstr commented Mar 12, 2019

@errordeveloper what about

eksctl <create|get|delete> auth-account
eksctl <create|get|delete> auth-role

which elaborates on what kind of account or role this is.

i first preferred

eksctl auth <add-account|remove-account> AWS_ACCOUNT_ID
eksctl auth <add-role|remove-role> ROLE_ARN --username USERNAME --groups GROUP1,GROUP2

but I think a command to display the current version would be nice too, which would be eksctl auth get which screws over the eksctl <verb> <subject> consistency.

@errordeveloper
Copy link
Contributor

errordeveloper commented Mar 12, 2019 via email

errordeveloper
errordeveloper previously approved these changes Mar 12, 2019
@errordeveloper
Copy link
Contributor

errordeveloper commented Mar 13, 2019 via email

rndstr added 8 commits March 12, 2019 17:53
Some refactoring around the authconfigmap while allowing to specify the
groups when adding new roles.
The command `eksctl util -aws-auth` allows to manipulate the `aws-auth`
configmap in `kube-system`.

It supports the following actions
- `--add-admin-role=<arn>`
- `--remove-role=<arn>`
- `--add-account=<number>`
- `--remove-account=<number>`
Discussion about location and hierarchy deferred into issue.
@rndstr
Copy link
Contributor Author

rndstr commented Mar 13, 2019

@errordeveloper created #625 and removed the command itself for now

@errordeveloper errordeveloper merged commit 46ae350 into master Mar 13, 2019
@errordeveloper errordeveloper deleted the add-admin-role branch March 13, 2019 09:06
@errordeveloper
Copy link
Contributor

hm... integration tests failed for me, seems like it's to do with this change?

2019-03-13T18:48:40Z [▶]  done after 4m22.7808778s of waiting for CloudFormation stack "eksctl-exciting-mushroom-1552501999-nodegroup-ng-0" to reach "CREATE_COMPLETE" status
2019-03-13T18:48:41Z [▶]  processing stack outputs
2019-03-13T18:48:41Z [▶]  task 0 returned without errors
2019-03-13T18:48:41Z [✔]  all EKS cluster resource for "exciting-mushroom-1552501999" had been created
2019-03-13T18:48:41Z [▶]  merging kubeconfig files
2019-03-13T18:48:41Z [▶]  setting current-context to [email protected]
2019-03-13T18:48:41Z [✔]  saved kubeconfig as "/tmp/kubeconfig"
2019-03-13T18:48:42Z [▶]  aws-auth = {
  TypeMeta: {
    Kind: "",
    APIVersion: ""
  },
  ObjectMeta: {
    Name: "",
    GenerateName: "",
    Namespace: "",
    SelfLink: "",
    UID: ,
    ResourceVersion: "",
    Generation: 0,
    CreationTimestamp: {
      Time: 0001-01-01 00:00:00 +0000 UTC
    },
    ClusterName: ""
  }
}
2019-03-13T18:48:42Z [ℹ]  adding role "arn:aws:iam::376248598259:role/eksctl-exciting-mushroom-15525019-NodeInstanceRole-5EUF1ZLNQ3SG" to auth ConfigMap
2019-03-13T18:48:42Z [✖]  saving auth ConfigMap: ConfigMap "" is invalid: metadata.name: Required value: name or generateName is required

@rndstr wdyt?

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.

3 participants