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

feat(cluster): add getKubeconfig method to generate scoped kubeconfigs #356

Merged
merged 1 commit into from
Mar 30, 2020

Conversation

metral
Copy link
Contributor

@metral metral commented Mar 24, 2020

Proposed changes

  • feat(cluster): add getKubeconfig method to generate scoped kubeconfigs

A scoped kubeconfig is necessary for certain auth scenarios. For example:

  1. Assume a role on the default account caller,
  2. Use an AWS creds profile instead of the default account caller,
  3. Use an AWS creds creds profile instead of the default account caller,
    and then assume a given role on the profile. This scenario is also
    possible by only using a profile, iff the profile includes a role to
    assume in its settings.

Scope options added are based on AWS kubeconfig docs, and include:

  • roleArn: Role ARN to assume instead of the default AWS credential
    provider chain
  • profileName: AWS credential profile name to always use instead of the
    default AWS credential provider chain

Note: The options can be used independently, or additively as they configure different settings of the kubeconfig authentication steps.

PR includes example of:

  • Using role-based kubeconfig: create a Pod as a dev with limited permissions.
  • Asserting profile-based kubeconfig is properly configured, since testing profiles is out of scope.

Related issues (optional)

Closes #348

@metral metral added this to the 0.33 milestone Mar 24, 2020
@metral metral force-pushed the metral/role-kubeconfig branch 4 times, most recently from 6296550 to 6af6057 Compare March 24, 2020 02:48
@metral metral requested a review from lblackstone March 24, 2020 16:02
@metral
Copy link
Contributor Author

metral commented Mar 24, 2020

PR Passed 3 times in CI

nodejs/eks/cluster.ts Outdated Show resolved Hide resolved
@metral metral force-pushed the metral/role-kubeconfig branch 2 times, most recently from defa076 to 106e246 Compare March 24, 2020 18:37
@beetahnator
Copy link
Contributor

It would be nice to be able to target an AWS profile instead of a role as well, maybe replace roleArn with args or add profile?

@metral
Copy link
Contributor Author

metral commented Mar 26, 2020

@mazamats The PR has been re-scoped to include the use of a roleArn and an AWS creds profile name.

@lblackstone Please review once more.

@metral metral changed the title feat(cluster): add helper to generate role-based kubeconfigs feat(cluster): add getKubeconfig method to generate scoped kubeconfigs Mar 26, 2020
@metral metral assigned lukehoban and unassigned lukehoban Mar 26, 2020
@metral metral requested a review from lukehoban March 26, 2020 01:09
@metral metral self-assigned this Mar 26, 2020
@metral metral force-pushed the metral/role-kubeconfig branch 6 times, most recently from bc13e08 to 4d7ec03 Compare March 26, 2020 01:40
@metral metral force-pushed the metral/role-kubeconfig branch 2 times, most recently from 0271183 to 53e83dd Compare March 26, 2020 16:18
A scoped kubeconfig is necessary for certain auth scenarios. For example:
  1. Assume a role on the default account caller,
  2. Use an AWS creds profile instead of the default account caller,
  3. Use an AWS creds creds profile instead of the default account caller,
     and then assume a given role on the profile. This scenario is also
     possible by only using a profile, iff the profile includes a role to
     assume in its settings.

---

Scope options are based on [1], and include:
  - `roleArn`: Role ARN to assume instead of the default AWS credential
  provider chain
  - `profileName`: AWS credential profile name to always use instead of the
  default AWS credential provider chain

Note: The options can be used independently, or additively as they
configure different settings of the kubeconfig authenticaton steps.

PR includes example of:
  - Using role-based kubeconfig: create a Pod as a dev with limited permissions.
  - Asserting profile-based kubeconfig is properly configured, since
  testing profiles is out of scope.

1 - https://docs.aws.amazon.com/eks/latest/userguide/create-kubeconfig.html
@metral metral merged commit 90ce459 into master Mar 30, 2020
@pulumi-bot pulumi-bot deleted the metral/role-kubeconfig branch March 30, 2020 16:21
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.

Provide a helper to generate role-limited kubeconfig files
4 participants