teleport/lib/kube/utils
Tiago Silva 06c735490b
Bootstrap kubernetes RBACs when running EKS auto discovery (#41693)
* Bootstrap kubernetes RBACs when running EKS auto discovery

This PR extends the ability of `discovery_service` to self-bootstrap the
required permissions for the `kubernetes_service` to dial and forward
requests to the Kubernetes API on behalf of the users.

When EKS auto-discovery was initially developed, it wasn't possible to
bootstrap the required permissions without having prior access to the
cluster itself. Recently, AWS releases a new API to configure access to
IAM identities. By default, there are just a few predifined permissions
that either don't have the required permissions for
`kubernetes_service` to be operational or are the equivalent of
`cluster-admin` RBAC role.

To bypass it, `discovery_service` temporarily escalates itself to
`cluster-admin` by creating an EKS `AccessEntry` and associates the
policy
`arn:aws:eks::aws:cluster-access-policy/AmazonEKSClusterAdminPolicy`.

Once access is granted, it creates a Kubernetes RBAC `ClusterRole` and
`ClusterRoleBinding` with the minimal required permissions for
`kubernetes_service` to be operational. These permissions are binded to
`teleport:kube-service:eks`.

Finally, it deletes the previously created `AccessEntry` and creates
another for the target ARN that Kubernetes Service uses.

Fixes #39021

Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>

* handle review comments

* do not exit on failed GetCallerIdentity call

---------

Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>
2024-05-28 12:13:47 +00:00
..
eks_token_signed.go Bootstrap kubernetes RBACs when running EKS auto discovery (#41693) 2024-05-28 12:13:47 +00:00
utils.go Enable errorlint via golangci-lint (#37669) 2024-02-02 15:59:24 +00:00
utils_test.go Remove assigning by default first alphabetical kube cluster to a user. (#37242) 2024-01-29 22:47:34 +00:00