Developer EKS Access
Pre-reqs
- an environment variable
GITHUB_TOKENset to a classic GitHub token withread:orgpermissions. - Latest (as of 02-19-2025)
aws-cliis installed and available on your$PATH. kubectl>= 1.30 is installed and available on your$PATH. (Newer is better, usually)- Cloned copy of ol-infrastructure
- Should run with a standard python install with
hvacinstalled. Alternatively, follow the instructions in ol-infrastructure/README.md.
Overview
This document will guide you through the process of setting up your local environment to access the EKS cluster. This will allow you to interact with applications deployed into EKS, including tailing logs and opening a shell into the running containers.
Extra Reading
For more information about kubeconfig files, refer to the Kubernetes documentation here and here.
Steps
- Within your cloned copy of
ol-infrastructure, navigate to theeksdirectory atsrc/ol_infrastructure/infrastructure/aws/eks(or prefix the script with that path). -
There is a script in this directory called
login_helper.pythat will help you set up your local environment to access the EKS cluster. Run this script with the following command: -
This will return several
export AWS_statements onstdoutthat you can then run in your current shell. You need ALL of them. Additionally, it will include the timestamp of when these credentials will expire. By default they expire in one hour, but you can change that to 8 hours with-d 480argument. 8 hours is the maximum allowed. -
After running the
exportcommands on your shell, run the following command to generate akubeconfigfile: -
This will generate a
kubeconfigfile onstdoutthat will define contexts to all active clusters. Each context is named for the cluster so for exampleoperations-ci,applications-qa, and so on. -
You can save this
kubeconfigfile to your local machine for kubectl to use with the following: -
Additionally, you can specify a default current context with
--set-current-context <context>argument. -
Or you can set it by hand once you've saved your
kubeconfigfile: -
You can now interact with the EKS cluster using
kubectl. For example, to list all pods in thelearn-ainamespace of theapplications-qacluster:
Tip
login_helper sends progress logs to stderr; only relevant output goes to stdout. The aws_creds and kubeconfig steps can easily be combined in a private script (example).
Other Interesting kubectl Commands
-
Get all the pods for the learn-ai namespace:
-
Get all the pods in the learn-ai namespace with more information:
-
Describe a pod, which can tell you interesting things like the pod's IP address, the node it's running on, and the events that have happened to it, as well as the containers that make up the pod:
-
Output the logs of a pod in the learn-ai namespace.
kubectlwill makes its best guess at which container to output logs from: -
Be specific and output the logs from the
nginxcontainer. -
tailor follow the logs of the nginx container in a pod in the learn-ai namespace: -
Open a shell into the nginx container of a pod in the learn-ai namespace: