-
-
Notifications
You must be signed in to change notification settings - Fork 122
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
Better support for aws-iam-authenticator #376
Conversation
Run |
please add links to your research in the PR description |
f5999c0
to
8a564ee
Compare
5e78a20
to
c575b46
Compare
@@ -0,0 +1,38 @@ | |||
#!/bin/bash |
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.
Something about this should tie it to being necessary for usage with aws-iam-authenticator
(like a comment) =)
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 thought was that this would be the way to generate kubecfg for all usage (where folks don't want to kops export kubecfg
) not necessarily just for the aws-iam-authenticator
use case
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.
See comments
0462d63
to
23a90a6
Compare
a9f41c4
to
da001f1
Compare
This commit adds a command to build a kubecfg that optionally can use aws-iam-authenticator, given we have the `KOPS_AWS_IAM_AUTHENTICATOR_ENABLED` set to true We want to enable RBAC using aws-iam-authenticator to auth users against the Kops cluster via IAM roles. Note that we have to fetch the CA data using `openssl s_client` as we don’t have a kubecfg to pull it from yet and we don't want to have to access the Kops state store S3 bucket where this information is stored. The build-kubecfg command has a check_env_vars function so that we don't have to have already declared the cluster_ca function, which keeps things a little cleaner. `kopsctl cluster kubecfg build` should be run after assuming an AWS role within Geodesic.
Rather than default the assumed role to AWS_DEFAULT_PROFILE use fzf to create a menu for all profiles to do with an AWS organisation (read: namespace) based off AWS_CONFIG_FILE entries. Example: Given the below ~/.aws/config file: ``` [profile cpco-testing-admin] region = us-west-2 role_arn = arn:aws:iam::126450723953:role/OrganizationAccountAccessRole mfa_serial = arn:aws:iam::323330167063:mfa/josh source_profile = cpco [profile cpco-testing-admin-kubernetes] region = us-west-2 role_arn = arn:aws:iam::126450723953:role/KubernetesAdmin mfa_serial = arn:aws:iam::323330167063:mfa/josh source_profile = cpco [profile cpco-testing-readonly-kubernetes] region = us-west-2 role_arn = arn:aws:iam::126450723953:role/KubernetesReadOnly mfa_serial = arn:aws:iam::323330167063:mfa/josh source_profile = cpco [profile cpco] ``` We will end up creating an fzf choice menu of: ``` cpco-testing-admin cpco-testing-admin-kubernetes cpco-testing-readonly-kubernetes ``` This makes switching between roles significantly less cumbersome. Note that we still disallow nested assuming roles, so we need to ‘exit’ in between switching roles.
No point letting the user select a role if already assumed.
Instead of `kopsctl cluster kubecfg build` because typing!
da001f1
to
a620739
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.
🥇
what
This commit adds a command
kopsctl login
to build a kubecfg that optionally can useaws-iam-authenticator, given we have the
KOPS_AWS_IAM_AUTHENTICATOR_ENABLED
set to truewhy
We want to enable RBAC using aws-iam-authenticator to auth users against the Kops cluster via IAM roles.
Note that we have to fetch the CA data using
openssl s_client
as we don’t have a kubecfg to pull it from yet and we don't want to have to access the Kops state store S3 bucket where this information is stored.Note this is a non breaking change and while we can use the templated
kubecfg
, as admin operators, we can still runkops export kubectl
.kopsctl login
should be run after assuming an AWS role within Geodesic.There will be further PRs to create specific IAM roles for
KubernetesAdmin
andKubernetesRead
See: cloudposse/terraform-aws-components#111Testing
Given an aws-iam-authenticator configMap of:
and
~/.aws/config
containing:login to
testing.cloudposse.co
geodesicTry and
kubectl get nodes
:Build our kubecfg:
Check our kubecfg:
Try and get nodes without having assumed our IAM role:
Assume IAM role so we can successfully run some kubectl commands: