|
| 1 | +--- |
| 2 | +name: eks-usage |
| 3 | +description: >- |
| 4 | + Agent-only operating guide for safe Amazon EKS context verification, kubeconfig setup, authentication diagnosis, and connectivity retries. |
| 5 | + Use before running kubectl or EKS commands, when an EKS IAM, authenticator, Unauthorized, Forbidden, TLS, i/o, or connectivity error appears, or when the active cluster or context is uncertain. |
| 6 | +user-invocable: false |
| 7 | +metadata: |
| 8 | + internal: true |
| 9 | +--- |
| 10 | + |
| 11 | +# EKS usage |
| 12 | + |
| 13 | +This skill owns generic EKS client access and diagnosis, not permission to change a cluster or deploy an application. |
| 14 | +Project runbooks and deployment skills remain authoritative for the intended cluster, lane, namespace, and allowed mutations. |
| 15 | + |
| 16 | +## During deployments |
| 17 | + |
| 18 | +Before contacting the cluster control plane during a deploy, read the project's deployment map or runbook and confirm that direct cluster access belongs to the documented lane. |
| 19 | +Most managed production deploys use CI, declarative synchronization, or a platform release lane and do not contact the raw cluster API. |
| 20 | +If transient TLS, i/o, DNS, or network failures repeat after kubeconfig refresh during a deploy, treat them as a likely wrong-path signal, stop direct cluster retries, and switch to the documented deploy lane. |
| 21 | +Reserve the bounded retry procedure below for a confirmed correct direct-access path, because a wrong deploy path is resolved by switching lanes rather than by retrying or escalating it as a connectivity blocker. |
| 22 | + |
| 23 | +## Establish identity and context |
| 24 | + |
| 25 | +1. Run `aws sts get-caller-identity` and confirm the expected AWS account and principal without exposing credentials. |
| 26 | +2. Run `kubectl config current-context` and `kubectl config view --minify` to inspect the active cluster, user, and namespace or its default. |
| 27 | +3. Before any mutating command, state the intended cluster, context, and namespace and stop if they do not match or cannot be proved. |
| 28 | +4. Treat a context change as safety-significant, because `aws eks update-kubeconfig` sets the written file's current context to the selected cluster. |
| 29 | +5. Bind mutations to the verified context and namespace instead of relying on ambient defaults. |
| 30 | + |
| 31 | +## Understand `update-kubeconfig` |
| 32 | + |
| 33 | +`aws eks update-kubeconfig --name <cluster> --region <region>` retrieves the cluster endpoint and certificate authority from the EKS control plane and creates or merges kubeconfig entries for the cluster, context, and AWS-backed user. |
| 34 | +The AWS identity used for that metadata lookup must be allowed to describe the cluster, while any configured authentication role governs later `kubectl` token generation. |
| 35 | +It writes the explicitly selected kubeconfig path, otherwise the first path in `KUBECONFIG`, otherwise the default kubeconfig file. |
| 36 | +It replaces an existing entry for the same EKS cluster in that file and makes the generated context current. |
| 37 | +The user entry invokes AWS to obtain short-lived authentication when `kubectl` runs; the file does not contain a reusable static Kubernetes bearer token. |
| 38 | +Use dry-run when the destination or merge effect is uncertain, and consult `aws eks update-kubeconfig help` for current flags and precedence. |
| 39 | +Refreshing kubeconfig fixes stale endpoint, certificate, or generated-entry state, but it cannot grant IAM, EKS access-entry, Kubernetes RBAC, or network access. |
| 40 | + |
| 41 | +## Classify the exact failure |
| 42 | + |
| 43 | +| Signal | Layer | Response | |
| 44 | +| --- | --- | --- | |
| 45 | +| `AccessDeniedException` from EKS describe or kubeconfig update | AWS IAM before the Kubernetes API | Confirm the AWS identity and intended role, then escalate an actual missing IAM grant instead of debugging the network. | |
| 46 | +| `ExpiredToken`, `InvalidClientTokenId`, or missing credentials | Local AWS credential chain before the Kubernetes request | Refresh or select the intended profile or role, then re-run the identity check without printing a token. | |
| 47 | +| A generic exec-plugin failure | Local exec invocation or a wrapped nested failure | Classify the nested error first; check for a missing AWS executable, malformed exec stanza, or unsupported exec `apiVersion`, and refresh credentials only when the nested error identifies a credential failure. | |
| 48 | +| `Unauthorized` or a server request for credentials from `kubectl` | Kubernetes API authentication after reaching the endpoint | Confirm the generated user role and the cluster's authorized IAM principal or access entry. | |
| 49 | +| `Forbidden` from `kubectl` | Kubernetes authorization after successful authentication | Check the verb, resource, and namespace with `kubectl auth can-i`, then escalate the RBAC change if it is outside authority. | |
| 50 | +| `dial tcp`, `i/o timeout`, `TLS handshake timeout`, `no route`, or `connection refused` | DNS, route, proxy, firewall, or API-endpoint reachability | Follow the bounded connectivity retry path below rather than requesting IAM. | |
| 51 | +| `x509` or certificate validation failure | Kubeconfig CA, clock, or TLS-intercepting proxy | Refresh kubeconfig and inspect clock and proxy state, but never disable certificate verification as a workaround. | |
| 52 | + |
| 53 | +Messages such as `couldn't get current server API group list` are wrappers, so classify the nested final error rather than the wrapper. |
| 54 | +A successful `aws eks describe-cluster` proves AWS control-plane authorization and cluster metadata access, not Kubernetes endpoint reachability or workload authorization. |
| 55 | +A certificate-verified HTTPS response from the cluster endpoint, including HTTP 401, proves DNS, routing, and TLS reached the API server, but it does not prove `kubectl` authentication. |
| 56 | + |
| 57 | +## Troubleshoot in cheapest-first order |
| 58 | + |
| 59 | +1. Capture the exact command and full error, then verify AWS identity, region, `KUBECONFIG`, current context, cluster, and namespace. |
| 60 | +2. For an isolated TLS or transport timeout, retry the same non-mutating probe once after a short pause; a single transient timeout is never a blocker. |
| 61 | +3. Confirm the intended target, refresh kubeconfig, recheck the now-current context, and retry a harmless version or namespace read once more after a short bounded backoff. |
| 62 | +4. Use EKS describe to confirm that the cluster is active and inspect its endpoint-access mode without changing it. |
| 63 | +5. If transport still fails, test DNS and HTTPS reachability to the configured endpoint and inspect VPN, proxy, firewall, private-endpoint routing, and allowed-source requirements. |
| 64 | +6. If the endpoint is reachable, return to the IAM, token, access-entry, and RBAC classification instead of continuing network changes. |
| 65 | +7. Use `aws eks`, `aws sts`, `aws eks get-token`, `kubectl config`, `kubectl auth`, and `kubectl get --help` for current flags rather than copying stale invocations from old incidents. |
| 66 | + |
| 67 | +## Retry and escalation line |
| 68 | + |
| 69 | +Continue when any bounded retry succeeds, and record the transient only when it affects operational evidence or repeats. |
| 70 | +Apply the three-probe budget only to transient connectivity failures such as TLS handshake timeout, i/o timeout, or transient DNS or network errors; escalate when identity and context checks, kubeconfig refresh, and three total non-mutating attempts still fail. |
| 71 | +Correct an expired or misselected local credential or role first, because those caller-controlled authentication failures do not require escalation. |
| 72 | +Escalate immediately when the intended target cannot be proved or classification confirms an owner-controlled AWS IAM, Kubernetes authentication, EKS access-entry, RBAC, or certificate failure, without spending the connectivity retry budget. |
| 73 | +Also escalate persistent evidence of a non-active control plane, private-route or allowlist boundary, or owner-controlled proxy fault. |
| 74 | +Include the redacted exact commands and errors, timestamps and attempt count, current context and namespace, AWS identity and region, cluster status and endpoint-access mode, and DNS or HTTPS observations. |
| 75 | +Never self-grant IAM or RBAC, edit access entries, expose a private endpoint, widen endpoint CIDRs or security groups, disable TLS verification, or mutate an uncertain context merely to get past an access failure. |
0 commit comments