AWS Open Source Blog
Authenticating to EKS Using GitHub Credentials with Teleport
July 15, 2020 update: Gravitational has updated the instructions for using Teleport with EKS to account for the latest changes in both products. Please see the Gravitational documentation for further details.
This post describes how to configure Gravitational’s Teleport as an authentication proxy for Amazon Elastic Kubernetes Service (Amazon EKS), using GitHub as the identity provider for authenticating users. In this example, Teleport is installed onto a stand-alone EC2 instance and configured to use GitHub authentication to authenticate users identities. Once authenticated, the role assigned to the EC2 instance allows the user to impersonate a Kubernetes RBAC role, giving them access to the EKS cluster.
Teleport
Teleport is an open source solution from Gravitational that can be configured as a proxy for administering a Kubernetes cluster. The open source version includes support for GitHub authentication, i.e. you can use GitHub as an identity provider for authenticating users. You can also extended Teleport’s session recording and audit log to Kubernetes. For example, regular kubectl exec
commands are logged into the audit log and the interactive commands are recorded as regular sessions that can be stored and replayed in the future. The commercial version of Teleport adds support for RBAC and SSO using OAuth/OIDC or SAML; see Teleport Enterprise for more information.
EKS authentication
EKS currently supports two types of authentication: bearer/service account tokens and IAM authentication which uses webhook token authentication. When users call the Kubernetes API, a webhook passes an authentication token included in the request to IAM. The token, a base 64 signed URL, is generated by the AWS Command Line Interface (AWS CLI). In earlier versions of EKS, this was accomplished using the aws-iam-authenticator binary.
While IAM authentication is adequate for a majority of use cases, interest in other types of authentication like OIDC has been steadily growing, particularly among organizations where creating new IAM user accounts is politically challenging. With a solution like Teleport, these organizations can use alternate types of authentication, such as GitHub, with EKS.
How does it work?
Teleport leverages user impersonation, where a user can act as another user through impersonation headers. When you integrate Teleport with EKS, you assign to the instance that Teleport runs on an IAM role mapped to a Kubernetes RBAC role which grants it the ability to impersonate other groups. Once users are authenticated by Teleport, the role granted to the instance allows them to assume the permissions of the Kubernetes group specified in the Teleport configuration.
Use cases
An alternative to Route 53 resolver endpoints
When you configure the EKS cluster endpoint to be private, the name of the EKS cluster can only be resolved from within the worker node VPC. As an alternative to creating Route 53 inbound endpoints (which cost approximately $90/month), you can run a Teleport proxy [in each worker node VPC] on a t3.small instance for as little as $14/month.
Dynamic team environments
There are times when creating IAM users is not practical, e.g. when the composition of a development team is changing frequently or when the time to create an IAM user is excessively long. Delegating cluster access to a team lead who can control access through Teleport and GitHub can streamline the onboarding process for new team members.
Prerequisites
You’ll need a functioning EKS cluster. If you’re unfamiliar with creating an EKS cluster, see eksctl.io.
Integrating Teleport with EKS
Create cluster role and role binding
The first step is to create a cluster role and role binding that will allow the EC2 instance to impersonate other users, groups, and service accounts.