Skip to content

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 (for polaris and staging) and luna-production (for production). Complete AWS setup & CLI auth first; its ~/.aws/config block defines both, under one shared and-digital SSO session.
  • Homebrew, to install the tools below.
  • Access through the AdministratorAccess SSO role. The cluster grants kubectl access to that role only (infrastructure/eks/parameters/<env>.parameters.json); the read-only Developer role has none.

Install the tools ​

bash
brew install awscli kubectl k9s

Check that all three are on your path:

bash
aws --version
kubectl version --client
k9s version

aws --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.

ClusterAWS profileAccess policyAllowed
polaris-eks-clusterluna-non-prodAmazonEKSClusterAdminPolicyEverything, including exec and port-forward
staging-eks-clusterluna-non-prodAmazonEKSViewPolicyRead-only
production-eks-clusterluna-productionAmazonEKSViewPolicyRead-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:

bash
aws sso login --sso-session and-digital

Check 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:

bash
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-production

Then add the cluster to your kubeconfig:

bash
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 production

Pass --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:

bash
kubectl config current-context
kubectl get pods -n dagster

Switch clusters with kubectl config use-context <alias>, or add --context <alias> to a single command.

2. Find the pod ​

bash
kubectl get pods -n dagster

Pod 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 ​

bash
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 kills

Step 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 ​

bash
kubectl exec -it <pod> -n dagster -- bash

The 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 ​

bash
kubectl port-forward <pod> 8080:3000 -n dagster

This 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.

bash
k9s --context staging -n dagster

Add --readonly to disable every action that changes the cluster. It is a sensible default on staging and production.

KeyAction
?Show all key bindings
:ctxSwitch cluster context
:nsSwitch namespace
:podsList pods (:svc for services)
/Filter the current list
lLogs for the selected pod
dDescribe the selected pod
sOpen a shell in the selected pod
Shift-fPort-forward
EscGo 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:

bash
kubectl auth can-i create pods/exec -n dagster

no 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 ​

SymptomLikely cause
Token has expired and refresh failedThe 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-forwardExpected on staging and production — see above.
ResourceNotFoundException from update-kubeconfigWrong cluster name or profile, or the polaris cluster is not currently deployed.
kubectl hangs or times outCheck kubectl config current-context; a stale context pointing at a deleted cluster is the usual cause.

Made with ❤️ by the Luna team