Skip to content

Latest commit

 

History

History
376 lines (335 loc) · 24.8 KB

07-eks.md

File metadata and controls

376 lines (335 loc) · 24.8 KB

07. EKS Onboarding — v2 Reference

Runtime cross-account registration

The web EKS pages support read-only queries for enabled accounts already registered in /accounts. The Terraform onboarding sections below describe the original host-account provisioning path; its host-only limitation does not apply to manual runtime registration through the web API.

Account registration and Kubernetes authorization are separate. EKS management API reads (ListClusters, DescribeCluster, and DescribeAccessEntry) use the selected account's registered read-only role. For member clusters, the default Kubernetes bearer also uses that registered member role's temporary credentials. Its STANDARD Access Entry and required read policy must exist on the member cluster. Host clusters retain the web task role as their default identity. Host task-role bearers are not sent to member endpoints: EKS tokens bind the cluster name, which does not by itself distinguish same-named clusters in different accounts. An explicitly saved AssumeRole override for a member must belong to that same member account; historical out-of-account overrides fail closed. Registering an account or a cluster in AWSops does not create IAM roles, Access Entries, access policy associations, or network connectivity.

Existing member configurations that registered only the host web task-role principal need an Access Entry/read policy for the registered member role before default member queries can succeed. The generated guide names the required role; the owner applies it. The app does not add or remove AWS access entries.

Member least-privilege permissions

The member cluster owner runs exactly two commands generated by the /eks guide: aws eks create-access-entry --type STANDARD for the registered member read role, then aws eks associate-access-policy with AmazonEKSViewPolicy at cluster scope. No Kubernetes group, kubeconfig, kubectl or RBAC manifest is required. The managed View policy supplies the supported built-in reads, including namespaces, but excludes Kubernetes Secrets. Do not associate AmazonEKSAdminViewPolicy with the shared member role: it reads Secrets, and other consumers able to assume that role would inherit that access. Access policies are additive, so associating View does not revoke an existing AdminView association; the owner must disassociate it. Host Terraform onboarding retains its existing single-consumer web task-role AdminView configuration.

View has no cluster-scoped nodes read. When the Kubernetes nodes API returns 403 for a member cluster, the BFF builds an EC2/node-group view instead (web/lib/eks-aws-nodes.ts) with the same registered member role: eks:ListNodegroups, eks:DescribeNodegroup, ec2:DescribeInstances filtered by the eks:cluster-name tag or the kubernetes.io/cluster/<name> tag key, and ec2:DescribeInstanceTypes. These are read-only actions already covered by the target-account role's ReadOnlyAccess. Rows use the EC2 private DNS name (the default node name, so pods' spec.nodeName still joins per-node requests), report EC2 state rather than kubelet Ready, carry no labels/taints/conditions, show instance-type capacity as allocatable (an upper bound), and exclude Fargate nodes. The UI labels these rows as an EC2/node-group view. GET /api/eks/fleet marks such a cluster nodesSource: "aws-api" with counts.nodesReady: null and counts.ec2Running; the home tile, /eks stats and the fleet nodes page show "EC2 running N · Ready unknown" rather than 0 Ready, and the fleet reserved-% and per-node Reserved captions exclude these rows. The cluster diagnosis node table shows Ready as "EC2 running · Ready unknown" and Pressure as unknown (never flagged as a problem), and the Kubernetes map draws these nodes as neutral. The node drilldown labels its CPU/Memory cards "EC2/노드그룹 기준", shows instance-type Capacity with Allocatable and Reserved as "—", and the fleet nodes page passes the row it already holds instead of re-listing nodes; a node-read 403 in the drilldown reads as "kubelet details unavailable (View policy)". If both reads fail, the fleet and summary views degrade only the node fields; pods, deployments and services still show. Existing entries created from the earlier guide (awsops:eks-readonly group plus a nodes ClusterRoleBinding) keep working and return Kubernetes node rows; the group and binding are no longer required.

One-click member registration

Member clusters are never registered automatically. GET /api/eks never writes. For an administrator, each discovered member cluster that is not yet registered is checked with DescribeAccessEntry for its registered member read role; a verified entry (true) stays entry-only and is flagged accessEntryVerified: true. Non-administrator reads, missing or unverifiable entries, host clusters and Terraform-managed ids are never flagged.

The admin /eks page lists flagged clusters in an "Access Entry 확인됨" callout above the cluster cards, each with its own [조회 등록] button, and sorts their cards first. The page sends no request on load; registration happens only when the administrator clicks [조회 등록] (in the callout or on the card), which sends the ordinary POST /api/eks/[cluster]/register. That request runs the admin, DescribeCluster, Access Entry and ONBOARDED_EKS_CLUSTERS checks and writes the Aurora eks_registrations row attributed to that administrator. The route logs one structured eks_cluster_registered line (mode: "access-entry"); a successful DELETE logs eks_cluster_unregistered. Registration is an app-state write only: AWSops never creates Access Entries, associates policies or applies RBAC.

Admin DELETE ([해제]) removes the registry row, and the cluster stays unregistered: on the next page load it reappears in the callout but is not registered again until an administrator clicks [조회 등록].

Optional APIs need separate narrow bindings bound to a Kubernetes group that the owner adds to the member Access Entry (for example awsops:eks-readonly). K8sGPT Result access is described in the operator runbook. OpenCost's fixed service-proxy path separately needs the following namespace-limited read permission after the opencost namespace/service exist. The cluster owner applies it; AWSops does not. It grants no pod exec, node proxy, Secret or write permissions:

apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: awsops-opencost-proxy-reader
  namespace: opencost
rules:
  - apiGroups: [""]
    resources: ["services/proxy"]
    resourceNames: ["opencost:9003"]
    verbs: ["get"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: awsops-opencost-proxy-reader
  namespace: opencost
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: awsops-opencost-proxy-reader
subjects:
  - apiGroup: rbac.authorization.k8s.io
    kind: Group
    name: awsops:eks-readonly

Kubernetes access alone does not enable the adjacent data panels. CloudWatch diagnostics require cloudwatch:GetMetricData and cloudwatch:ListMetrics on the selected read role, and Container Insights must actually publish its series. Node ENI details require the account/region to be in the enabled inventory scan scope with a completed EC2 inventory collection. A denied query, absent metric series, and inventory not yet collected are distinct operational conditions.

Query scope and cleanup

The cluster list, registration, and subsequent resource reads retain the selected account and region. Member-account and nondefault-region clusters use their EKS ARN as the API and registry identifier; the visible cluster name remains separate. The existing eks_registrations.cluster_name text key stores that qualified identifier, including any authentication override. Existing bare-name registrations and ONBOARDED_EKS_CLUSTERS entries retain their host/deployment-region meaning. This prevents a same-named host cluster from granting access to, overwriting, or unregistering a member cluster. It requires no schema migration.

The registration endpoint accepts either a URL-encoded cluster ARN or a bare name with ?account=<TARGET_ACCOUNT_ID>&region=<REGION>. It describes that exact target before checking its Access Entry, rather than searching the first page of the host account's cluster list. A 404 unknown cluster therefore means the selected target was not found; an absent or unverifiable entry remains a separate registration failure. Invalid or disabled target accounts do not fall back to the host.

Admin DELETE is a local cleanup operation: a syntactically valid canonical registration can be removed, including its saved auth, after its member account is disabled or removed. It does not require AWS discovery or an enabled member scope, and it does not revoke AWS permissions. Bare-name member references require an explicit region or a full ARN. Host Terraform-managed entries remain protected; POST and reads keep their enabled-scope checks.

The account/region selector refreshes EKS lists and fleet aggregates without a registration side effect. Queries wait for the persisted selection and discard responses from an earlier selection. Discovery is bounded to 12 account/region targets and 25 cluster descriptions per target. Wildcard all-region discovery includes configured and already-registered regions and explicitly reports that this is not exhaustive AWS-region discovery; select a specific region to query another region directly. Fleet selection includes all authorized registered regions under wildcard scope, with a separate 100-cluster cap. Registration-store failures return an unavailable result instead of a successful empty fleet. Partial failures and truncation are returned separately from a successful empty result. Kubernetes endpoints must still be reachable from the web task, and downstream collectors can report unsupported scopes separately.

Read failures retain a coarse classification (denied, unreachable, timeout, or upstream-error) and a safe explanation. The same controlled classification is logged without raw provider messages, bodies, stack traces or credentials. A denied K8sGPT Result read or OpenCost detection read does not prove the operator is absent; even a degraded HTTP 200 response must be interpreted with its failure metadata. The generated member guide and optional bindings above address permissions; network and timeout failures require connectivity checks instead.

Terraform host-account provisioning

make configure uses scripts/v2/configure.mjs to discover host clusters and offer an EKS multi-select. Its authentication-mode preflight selects clusters using API or API_AND_CONFIG_MAP; CONFIG_MAP-only clusters require an operator handoff. The selection becomes onboard_eks_clusters in terraform.tfvars.

terraform/foundation/eks.tf iterates that list to create a STANDARD Access Entry for the web task role and associate a cluster-scoped AWS-managed view policy. It supplies the onboarded_eks_clusters endpoint/ARN/CA output. The always-on task-role discovery permissions are defined separately in terraform/foundation/workload.tf. The CA value comes from certificate_authority[0].data. An empty selection creates no onboarding resources. This Terraform path provisions host clusters only; it does not provision member roles, member Access Entries, or cross-account network connectivity.

An operator can separately create an Access Entry and read-policy association. For host/deployment-region events, the optional eks_auto_register_enabled observer (scripts/v2/eks/auto_register.py) can reflect the event into the app registry. Member clusters register through the admin /eks page's one-click [조회 등록] described above, not through this observer; the guide does not promise that the host EventBridge observer will see member or nondefault-region events.

Principal and governance boundaries

The web workflow inherits read-only multi-account discovery from ADR-011. It does not relax ADR-005: AWS-resource mutation and autonomy remain frozen. Generated Access Entry commands and OpenCost installation bundles are operator handoffs; returning a bundle does not execute it or enable an in-app mutation tool.

Host web queries use the web task role; member web queries use the registered member role by default. Network Path Check EKS access describes the separate worker/target-role principal, and Istio agent EKS access describes an agent Lambda principal. An entry for one actor does not grant access to the others. An explicit saved web AssumeRole override also needs authorization for its own role.

Kubernetes service graph

/topology/infra?view=k8s (K8sMapView) draws one selected cluster as a namespace-grouped graph of Ingress gateways, Services and managed datastores (web/lib/k8s-service-graph.ts). Pods and Nodes are never graph nodes; they appear only in the Service detail panel, and Service-to-Pod membership comes only from ready Endpoints addresses. A datastore matched to inventory is one node per resource, identified by type, account, region and resource id (ds:<type>:<account>:<region>:<id>), so the same identifier in another region or account is a separate node; an unmatched host is one node per host (ds:<kind>:<host>). System namespaces (kube-system, kube-public, kube-node-lease) are hidden by default, and namespaces start collapsed when the graph has more than 40 Services.

Edge evidence, strongest first (an edge with several sources shows the strongest):

Line Evidence Source
Solid Observed in traces Published service snapshot (/api/topology?lens=service)
Dashed Inferred from configuration Managed-database hostnames in Pod env and ConfigMaps (db-refs)
Thin Routing Ingress rules, Service selection and exact Route 53 host matches

db-refs extraction and security posture

GET /api/eks/[cluster]/db-refs reads the Pod list (cap 2,000) and the ConfigMaps Pods reference (cap 200, concurrency 8) with the cluster's read credentials, in web/lib/eks-db-refs.ts, the only server code that scans env or ConfigMap values for content (the explorer incluster list returns a ConfigMap key count and incluster/describe redacts ConfigMap values). terraform/foundation/eks.tf registers this read next to the kind allow-list. The cluster connection and bearer are resolved once per request and reused for every read (k8sGetWith), and the run has a 20-second overall budget; a caller-supplied budget is capped at 50 seconds, below the bearer's 60-second lifetime. The Pod cap is always at least 1 (Kubernetes treats limit=0 as unlimited), and referenced ConfigMaps are read in namespace/name order so a cap always keeps the same ones. Env values and referenced ConfigMap data are scanned by web/lib/db-endpoint.ts for RDS/Aurora, ElastiCache, OpenSearch and MSK hostnames. Only the bare lower-cased host is kept: userinfo, port, path and the raw value are dropped, and all values are discarded after scanning. URL userinfo (after ://, up to the authority's last @) is removed before scanning; a token directly followed by @ or assigned to a credential-like key (password, passwd, pwd, secret, token, key) is never returned; scheme prefixes such as tcp: are stripped only at the start of a value or after whitespace; and every label must be a valid DNS label (1–63 characters, 253 in total). Secrets are never requested; only the names of referenced Secrets are returned. Hosts are matched to inventory endpoints (web/lib/db-ref-resolve.ts) for rds, rds_cluster, rds_proxy, opensearch, elasticache (cache-node endpoints) and elasticache_replication_group (primary and reader endpoints) rows of the cluster's account, reading at most 5 pages of 500 rows per type (30 inventory reads in the worst case). Only the types that can carry a wanted host's kind are read, and a type is no longer paged once every host it could resolve is matched. A host is bound to a resource only from a type whose pages all carry consistency=statement-snapshot and one unchanged succeeded sync-ledger version (status, finished_at, last_success_at, row_count), the evidence rule /topology applies to its critical inventory reads. A type whose ledger is missing, running, partial, failed, malformed or changes between pages sets inventoryIncomplete; a type that still returns a full page at the page cap with a wanted host unresolved sets inventoryCapped. Either way that type's matches are withheld, its hosts stay unmatched host names and the page shows a notice. The response is an explicit allow-list: workload, via (env or configmap), host, kind, matched resource (type, id, region, account), secret names, and the truncated/partial and inventoryCapped/inventoryIncomplete flags. A denied Pod list or a ConfigMap that could not be read (denied, failed, timed out or unparsable) sets partial; a referenced ConfigMap that does not exist (404) holds no values and does not; hitting a cap sets truncated; exceeding the budget stops issuing reads, keeps the references found so far and sets both. Only account and region query parameters are accepted, and responses are Cache-Control: private, no-store.

Scope and limits

  • Trace edges (web/lib/k8s-trace-overlay.ts) come from the published service snapshot, which is host-account only. A trace service maps to a workload only through its runs_on relation to exactly one namespace/deployment of the selected cluster, and the cluster name must be unique across the fleet-wide cluster listing (all registered accounts and regions), not just the clusters of the selected scope: a narrowed scope, including the default host-account-only scope, hides same-named clusters of other accounts or regions without any truncation or error flag. When the selected scope is already all accounts and all regions, its listing is reused; otherwise the page reads the fleet listing separately (the cluster selector still follows the selected scope). A truncated scope or fleet listing, one with a per-target read failure, or a failed or unparseable fleet listing cannot prove that uniqueness, so the join is refused (incomplete_listing, no trace edges) without reading the snapshot. The snapshot API returns at most 200 entities per page with relations between same-page entities only; the overlay reads up to 5 pages and draws trace edges only when it can account for every entity and relation, otherwise it draws none and discloses the count of records it did not inspect. A partial publication also yields no trace edges, with a notice (partial_snapshot): any gap other than the two baseline gaps every healthy publication carries (nfm:not_collected, kubernetes:live_ownership_unavailable), or any source that is stale, retained or capped, has no generation, or has a status other than ok/empty; a page without gaps or sources counts as partial. The top-level status is not used, because a healthy publication always reports partial. This mirrors partialInputs in web/lib/service-topology/read-published.ts, since a capped source may have dropped a second runs_on relation. Calls that cannot be mapped to one workload or managed datastore are counted, not guessed, and add no node.
  • Member clusters (full EKS ARN ids) read through the member role show Kubernetes structure and db-refs links but no trace edges. A host cluster outside the deployment region also has an ARN id, and the cluster listing reports a numeric account for every row, so the page resolves the host account from the single isHost row of GET /api/accounts: an ARN whose account equals it is a host cluster for both trace edges and Route 53 records. If that lookup fails or does not return exactly one 12-digit host account, every ARN id is treated as a member: no trace edges, with the member-cluster notice, and Route 53 is read for the ARN's account.
  • Route 53 records are read from the synced inventory of the cluster's account (self for the host) and matched to gateway hosts exactly; the record name is only the DNS node's label, so a wildcard record (\052 decoded to a leading *.) links like any other. The read stops after 5 pages of 500 rows or 2,000 alias/CNAME records. A read that stops at a cap keeps what it read and a failed read yields none; both show a notice. Records use the same inventory evidence gate as datastore resolution (web/lib/inventory-ledger.ts, the checks of fetchType in app/topology/page.tsx): every page must carry consistency: statement-snapshot and one succeeded ledger version (valid finished_at/last_success_at, non-negative integer row_count). A missing, running, partial, failed or malformed ledger, or a ledger that changes between pages, yields no records and an "inventory sync completion could not be confirmed" notice instead of DNS links.
  • ElastiCache hosts resolve to cache-node endpoints (elasticache) or to replication-group primary and reader endpoints (elasticache_replication_group). MSK hosts and ElastiCache configuration endpoints stay unresolved host names, because their inventory rows store no endpoint.
  • Layout (web/lib/k8s-graph-layout.ts) uses dagre (MIT, the dependency behind web/lib/flow-layout.ts) only for the call order inside each namespace box, on plain non-compound graphs, one connected component of intra-namespace calls at a time. dagre time grows quickly with dense meshes, so it is budgeted: a component with more than 150 edges never gets dagre, and all expanded namespaces share a 600-edge budget spent on components in ascending edge count (ties: namespace name, then smallest Service id). A small call graph therefore keeps its call direction whichever other namespaces are expanded. Services without calls inside their namespace, and components left out of the budget, are packed into a near-square grid in their box. Columns, barycenter ordering and box stacking are computed by the module itself. No edge route is precomputed: the canvas draws each edge as a smoothstep path between node handles.

Key files

File Responsibility
terraform/foundation/eks.tf Host Terraform onboarding and endpoint/CA output
terraform/foundation/workload.tf Always-on web task-role EKS discovery permissions
scripts/v2/configure.mjs Host discovery and authentication-mode preflight
web/lib/eks-cluster-id.ts Strict name/ARN parsing and display labels
web/lib/eks-context.ts Canonical account/region identity, selector conflicts, enabled member scope
web/lib/eks-role.ts Registered member-role ARN and same-account authentication checks
web/lib/eks-aws-nodes.ts Member EC2/node-group node view when the Kubernetes nodes read is forbidden
web/lib/eks-registry.ts Legacy host and qualified runtime registrations, cached read quality, saved auth
web/lib/eks-scope.ts Collection selection, wildcard disclosure, discovery and fleet limits
web/lib/eks-access.ts Target metadata and Access Entry checks for the applicable host/member principal
web/lib/eks-incluster.ts Scoped endpoint/CA cache, bearer construction, read-only Kubernetes transport
web/app/api/eks/ Discovery, registration, fleet, summary, and detail routes
web/lib/eks-db-refs.ts, web/lib/db-endpoint.ts, web/lib/db-ref-resolve.ts Server-side Pod env/ConfigMap host extraction and inventory matching for db-refs
web/lib/k8s-service-graph.ts, web/lib/k8s-trace-overlay.ts, web/lib/k8s-graph-layout.ts, web/lib/k8s-dns.ts Service graph model, trace overlay, namespace-boxed column layout and Route 53 matching
web/components/topology/K8sMapView.tsx, ServiceGraphCanvas.tsx, ServiceDetailPanel.tsx Graph page, canvas and Service detail panel
web/app/eks/, web/components/eks/ Scope-aware views, qualified requests, stale-response protection

See the API reference for response status and metadata contracts, including conditional envelope region, partial errors, and truncated. NFM pod-transfer attribution remains host/deployment-region only; member and other region requests return explicit unavailability rather than a host namesake's data.

Verification and historical scope

P1e originally established host Access Entry/view-policy onboarding and exposed connection metadata for later Kubernetes views. Those views and runtime query registration are now implemented; the original P3 deferral is historical.

The 2026-08-11 assessment recorded four host-role Access Entries, including clusters added outside Terraform. That dated snapshot is not a current inventory or an exhaustive statement of Terraform ownership. Compare the actual Access Entries, policy associations, ONBOARDED_EKS_CLUSTERS, and eks_registrations to establish current state. Source support and unit/browser checks do not prove a deployed role's permissions, API-server reachability, or completed rollout.