Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

Manage EKS system:masters members somehow #1031

Closed
tgeoghegan opened this issue Oct 11, 2021 · 4 comments
Closed

Manage EKS system:masters members somehow #1031

tgeoghegan opened this issue Oct 11, 2021 · 4 comments

Comments

@tgeoghegan
Copy link
Contributor

@branlwyd and I learned last week that the AWS IAM user that creates an EKS cluster is automatically and invisibly added to a system:masters Kubernetes group, allowing management of Kubernetes cluster resources. However, other IAM users get no privileges, even if they have administrator privileges at the AWS layer, and must be explicitly added to the kube-system/aws-auth config map in an appropriate mapUsers section1.

We should work out a way to manage this access via Terraform.

@tgeoghegan
Copy link
Contributor Author

The difficulty is that I'd prefer not to enumerate our AWS IAM user ARNs in .tfvars files that get checked into a public repository. Perhaps we could create an IAM role like k8s-cluster-admin and grant it system:master via mapRoles, and then permit IAM users to impersonate that role, at the cost of (1) manually managing membership in the role, and (2) requiring users to use an AWS profile/kubectl configuration that assumes a role instead of performing operations as their IAM user.

@tgeoghegan
Copy link
Contributor Author

@tgeoghegan
Copy link
Contributor Author

I discussed what I want to do about this here, but I've run into snags while trying to implement it. Introducing readonly and admin IAM roles and using them in the aws-auth config map works, but the problem is doing that via Terraform. The aws-auth map gets created automatically by EKS, and the Kubernetes provider for Terraform doesn't provide a way to add values to an existing config map, so the only way to do this in Terraform would be to do something complicated with a local-exec provisioner, which I would really rather not do. AWS have an open issue about this, or rather the general problem of programmatic management of EKS cluster access. Once they provide API for that, and it gets exposed through the aws TF provider, we should adopt it. In the meantime, given how rarely we provision clusters, I think we will just document the need to manually fix up the kube-system/aws-auth config map, though we can still automate the creation of the AWS IAM roles and the k8s ClusterRole and ClusterRoleBinding.

tgeoghegan added a commit that referenced this issue Jan 6, 2022
Introduces a new module in `terraform/cluster_boostrap` which is
responsible for provisioning a managed GKE or EKS Kubernetes cluster
into a GCP project or AWS account provisioned by `isrg-cloud-bootstrap`.

The bulk of the new module consists of the existing `eks` and `gke`
modules, moved to a new location. We do this in a separate TF state to
avoid configuring a TF provider with output from TF managed resources
(see #1046 for details).

The following functionality is new:
 - creation of an AWS ECR or Google Artifact Registry repository for
   container images via Terraform
 - creation of a ClusterRoleBinding for the read-only group in EKS

This commit removes from `terraform/Makefile` management of the GCS
bucket used to store the Terraform remote state. We now expect the
bucket to have been created manually by the operator. This reduces the
risk of bugs in `Makefile` targets accidentally destroying Terraform
state.

Finally, we align documentation in `terraform/README.md` with docs
introduced in isrg-cloud-boostrap [1] and abetterinternet/docs [2].

[1] abetterinternet/isrg-cloud-bootstrap#1
[2] https://github.com/abetterinternet/docs/pull/10

Resolves #1046
Part of #1170
Part of #1031
tgeoghegan added a commit that referenced this issue Jan 11, 2022
Introduces a new module in `terraform/cluster_boostrap` which is
responsible for provisioning a managed GKE or EKS Kubernetes cluster
into a GCP project or AWS account provisioned by `isrg-cloud-bootstrap`.

The bulk of the new module consists of the existing `eks` and `gke`
modules, moved to a new location. We do this in a separate TF state to
avoid configuring a TF provider with output from TF managed resources
(see #1046 for details).

The following functionality is new:
 - creation of an AWS ECR or Google Artifact Registry repository for
   container images via Terraform
 - creation of a ClusterRoleBinding for the read-only group in EKS

This commit removes from `terraform/Makefile` management of the GCS
bucket used to store the Terraform remote state. We now expect the
bucket to have been created manually by the operator. This reduces the
risk of bugs in `Makefile` targets accidentally destroying Terraform
state.

Finally, we align documentation in `terraform/README.md` with docs
introduced in isrg-cloud-boostrap [1] and abetterinternet/docs [2].

[1] abetterinternet/isrg-cloud-bootstrap#1
[2] https://github.com/abetterinternet/docs/pull/10

Resolves #1046
Part of #1170
Part of #1031
@tgeoghegan
Copy link
Contributor Author

The prio-server onboarding docs discuss managing the config map. As I noted, I don't think we can do much better until there is EKS API plumbed up through Terraform for us. In the meantime, I'm taking this out of the current tech debt milestone.

@tgeoghegan tgeoghegan removed this from the Winter 2021-2022 stability milestone Jan 12, 2022
@divergentdave divergentdave closed this as not planned Won't fix, can't repro, duplicate, stale Jul 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants