Connect to EKS pods
Reach the pods on Luna's shared EKS cluster to read logs, open a shell, or forward a port, with kubectl or k9s. Today the only workload on the cluster is Dagster and dbt (see data/), so the examples use the dagster namespace.
Before you start
- Both AWS SSO profiles configured:
luna-non-prod(forpolarisandstaging) andluna-production(forproduction). Complete AWS setup & CLI auth first; its~/.aws/configblock defines both, under one sharedand-digitalSSO session. - Homebrew, to install the tools below.
- Access through the
AdministratorAccessSSO role. The cluster grantskubectlaccess to that role only (infrastructure/eks/parameters/<env>.parameters.json); the read-only Developer role has none.
Install the tools
brew install awscli kubectl k9sCheck that all three are on your path:
aws --version
kubectl version --client
k9s versionaws --version should report aws-cli/2.x. Skip any tool you already have.
Clusters and what you can do
Each cluster is named <environment>-eks-cluster. polaris and staging live in luna-non-prod, production in luna-production.
| Cluster | AWS profile | Access policy | Allowed |
|---|---|---|---|
polaris-eks-cluster | luna-non-prod | AmazonEKSClusterAdminPolicy | Everything, including exec and port-forward |
staging-eks-cluster | luna-non-prod | AmazonEKSViewPolicy | Read-only |
production-eks-cluster | luna-production | AmazonEKSViewPolicy | Read-only |
TIP
polaris is a throwaway cluster, created by a push to env/polaris and deleted afterwards. It usually does not exist — if update-kubeconfig reports it cannot be found, that is why.
The API endpoint is public and IAM-authenticated, so you do not need the VPN to run kubectl. (The Dagster web UI is a separate matter: its ALB only admits the VPN egress IP.)
1. Authenticate and add the cluster to your kubeconfig
Log in once per SSO session. Both profiles share the and-digital session, so this one login covers luna-non-prod and luna-production:
aws sso login --sso-session and-digitalCheck that each profile you need resolves to the right account (851725171061 for luna-non-prod, 666243557741 for luna-production), and list the clusters in its account:
aws sts get-caller-identity --profile luna-non-prod
aws eks list-clusters --region eu-west-1 --profile luna-non-prod
aws sts get-caller-identity --profile luna-production
aws eks list-clusters --region eu-west-1 --profile luna-productionThen add the cluster to your kubeconfig:
aws eks update-kubeconfig \
--name staging-eks-cluster \
--region eu-west-1 \
--profile luna-non-prod \
--alias staging
aws eks update-kubeconfig \
--name production-eks-cluster \
--region eu-west-1 \
--profile luna-production \
--alias productionPass --profile explicitly so it is written into the kubeconfig entry; kubectl then fetches tokens with the right credentials without you exporting AWS_PROFILE. --alias gives the context a short name.
Confirm you are pointed where you think you are before running anything else:
kubectl config current-context
kubectl get pods -n dagsterSwitch clusters with kubectl config use-context <alias>, or add --context <alias> to a single command.
2. Find the pod
kubectl get pods -n dagsterPod names carry a generated suffix, so copy the name from this output rather than typing one from memory. Run pods are created per Dagster run and removed afterwards, so one you saw earlier may be gone.
3. Read logs
kubectl logs <pod> -n dagster # current logs
kubectl logs -f <pod> -n dagster # follow
kubectl logs <pod> -n dagster --previous # the last container, after a crash or restart
kubectl describe pod <pod> -n dagster # events: scheduling, image pulls, OOM killsStep stdout and stderr for a run are also written to the <env>-dagster-compute-logs-and-digital-luna-bucket S3 bucket (30-day expiry), so the Dagster UI can still show them after the run pod is gone. If the pod has been removed, use the UI rather than kubectl logs.
4. Open a shell
kubectl exec -it <pod> -n dagster -- bashThe container runs as the non-root dagster user, so you cannot install packages in it. If the pod has several containers, add -c <container>.
5. Forward a port
kubectl port-forward <pod> 8080:3000 -n dagsterThis maps localhost:8080 to port 3000 in the pod. Use svc/<service> in place of <pod> to target a Service; list them with kubectl get svc -n dagster.
Use k9s instead of kubectl
k9s is a terminal UI over the same kubeconfig and permissions, so it needs no extra cluster setup. Install it as in Install the tools, then complete step 1 so the cluster is in your kubeconfig and your SSO session is live.
k9s --context staging -n dagsterAdd --readonly to disable every action that changes the cluster. It is a sensible default on staging and production.
| Key | Action |
|---|---|
? | Show all key bindings |
:ctx | Switch cluster context |
:ns | Switch namespace |
:pods | List pods (:svc for services) |
/ | Filter the current list |
l | Logs for the selected pod |
d | Describe the selected pod |
s | Open a shell in the selected pod |
Shift-f | Port-forward |
Esc | Go back |
The permissions in Clusters and what you can do still apply. On staging and production, shell (s) and port-forward (Shift-f) are expected to be denied; logs and describe work. If k9s shows authorisation errors on startup, re-run aws sso login --sso-session and-digital.
Read-only on staging and production
On staging and production, exec and port-forward are expected to be denied because those clusters only attach the view policy. Check what your role can do before assuming a failure is a bug:
kubectl auth can-i create pods/exec -n dagsterno means you can still get, describe and read logs, but cannot get a shell. To debug a staging or production problem interactively, reproduce it on polaris (deploy by pushing to env/polaris) or ask the infrastructure owners for access rather than changing the access policy yourself.
WARNING
On polaris your role is cluster admin. Treat it as a shared scratch environment, and do not use it to look at, edit, or copy staging or production data.
Troubleshooting
| Symptom | Likely cause |
|---|---|
Token has expired and refresh failed | The SSO session expired. Re-run aws sso login --sso-session and-digital. |
error: You must be logged in to the server (Unauthorized) | Wrong AWS profile for the cluster (see the table above), or your SSO role is not the AdministratorAccess role the cluster grants. |
Error from server (Forbidden) on exec or port-forward | Expected on staging and production — see above. |
ResourceNotFoundException from update-kubeconfig | Wrong cluster name or profile, or the polaris cluster is not currently deployed. |
kubectl hangs or times out | Check kubectl config current-context; a stale context pointing at a deleted cluster is the usual cause. |
