Reference: Command Conventions and Safety Checks

Every runbook and procedure in this handbook uses the same variable names, so commands can be pasted in any order. Set the ones a page lists under Inputs.

Tools: AWS CLI v2, kubectl within one minor version of the cluster, jq, and the Session Manager plugin for aws ssm start-session. Some procedures also use eksctl, helm or velero.

Before you change anything

Run these and read the output. Most incident-making mistakes happen against the wrong cluster.

aws sts get-caller-identity --query '[Account,Arn]' --output text
kubectl config current-context
kubectl cluster-info | head -1
aws eks describe-cluster --name "$CLUSTER" --region "$REGION" \
  --query 'cluster.{arn:arn,version:version,platform:platformVersion,status:status,endpoint:endpoint}'

Check that the account, the cluster ARN and the endpoint in kubectl cluster-info belong to the same cluster. If they don’t, run aws eks update-kubeconfig --name "$CLUSTER" --region "$REGION" --alias "$CLUSTER", then kubectl config use-context "$CLUSTER".

For anything destructive, put the cluster in your prompt, or pass --context "$CLUSTER" explicitly.

Variables

VariableMeaningHow to get it
CLUSTER, REGIONCluster name and regionaws eks list-clusters --region <region>
NS, PODNamespace and Pod namekubectl get pods -A
NODEKubernetes node namekubectl get pod "$POD" -n "$NS" -o jsonpath='{.spec.nodeName}'
INSTANCE_IDEC2 instance behind a nodekubectl get node "$NODE" -o jsonpath='{.spec.providerID}' | awk -F/ '{print $NF}'
NODEGROUPManaged node groupkubectl get node "$NODE" -o jsonpath='{.metadata.labels.eks\.amazonaws\.com/nodegroup}'
NODEPOOL, NODECLAIMKarpenter NodePool and NodeClaimkubectl get node "$NODE" -L karpenter.sh/nodepool; kubectl get nodeclaims -o wide
KARPENTER_NSKarpenter’s namespacekubectl get deploy -A -l app.kubernetes.io/name=karpenter
PVC, PV, VOLClaim, volume object, EBS volume IDkubectl get pvc -n "$NS"; .spec.volumeName; PV .spec.csi.volumeHandle
PRINCIPAL_ARNIAM role ARN (not the sts session ARN)Use the role ARN from trusted IaC/access configuration or aws iam get-role; an STS session ARN is not the access-entry principal and guessing can lose IAM role paths
TARGET_VERSIONKubernetes minor version to move toaws eks describe-cluster-versions --region "$REGION"
TG_ARN, LB_ARNTarget group and load balancerkubectl get targetgroupbindings -A; aws elbv2 describe-load-balancers
AZ_IDAZ ID (e.g. use1-az1), not the nameaws ec2 describe-availability-zones --region "$REGION" --query 'AvailabilityZones[].[ZoneName,ZoneId]'
EVIDENCE_DIRWhere to keep incident outputSee below

Keep evidence

export EVIDENCE_DIR=~/incidents/$(date -u +%Y%m%dT%H%MZ)-$CLUSTER
mkdir -p "$EVIDENCE_DIR" && chmod 700 "$EVIDENCE_DIR"
kubectl get "$KIND" "$NAME" -n "$NS" -o yaml > "$EVIDENCE_DIR/$KIND-$NAME-before.yaml"   # before every change

Save the object before you patch it, and write each mutation and its undo into a running log ($EVIDENCE_DIR/actions.md) with UTC timestamps. Don’t collect Secret contents.

Conventions on these pages

  • <angle brackets> are values you fill in. $VARIABLES come from the table above.
  • ⚠ Destructive marks a step that deletes, detaches, force-terminates or bypasses a control, together with its precondition.
  • Expect / If after a command describe the healthy and unhealthy output.
  • Change EKS-managed add-ons with aws eks update-addon --configuration-values, not by editing their Deployments or DaemonSets. Otherwise the next add-on update overwrites the edit.
  • If GitOps (Argo CD, Flux) owns an object, either change it in Git or pause sync before a live edit; otherwise the edit is reverted within minutes.

Primary references

Across the wiki