> ## Documentation Index
> Fetch the complete documentation index at: https://sariva.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Cross-account reader setup

> Let the Sariva platform pod read app logs and pod health in a different AWS account, using a customer-authored reader role you grant it — examples, not a shipped module.

> [!NOTE]
>
> Written for Sariva on EKS. A VM install that observes apps on EKS uses its own AWS identity (for example the EC2 instance role) in place of the pod's — directly, or to assume the same reader role — and needs the same Kubernetes RBAC. That path is not yet walked end to end.

The Sariva platform pod runs in **one** EKS cluster, in **one** AWS account. In most real deployments the apps it observes — and sometimes the Kafka brokers — run in a **different** EKS cluster and a **different** AWS account. To read app CloudWatch logs and check app/Kafka pod health across that boundary, the pod assumes a **read-only reader role** that you create in the **target** account and grant to Sariva.

ⓘINFO

This page continues from [Wire the pod's AWS identity](https://sariva.mintlify.site/install-setup/irsa.md) (the pod's home identity). Do that first — the reader role's trust policy references the pod's home Pod Identity role.

⚠WARNING

**Sariva ships no infrastructure-as-code for this role.** The snippets below are **reference examples** you copy and adapt in whatever tool you use — Terraform, CloudFormation, CDK, Pulumi, or the console. The reader role and its Kubernetes RBAC are **resources inside your account** and stay **customer-authored**. Sariva documents *what access is needed*; it never creates or manages resources in your account.

## When you need this

Match your deployment to one of three topologies.

| Shape | Layout | Reader role needed? |
| - | - | - |
| **A — Single-cluster** | Sariva pod, Kafka, and apps all on the **same** EKS / account. | **No reader role** — the home IRSA already reaches pods, so skip §2–§3 and §5 and leave `cross_account_reader_role_arn` unset. **One exception:** per-container CPU/mem headroom still needs §4a's optional `metrics.k8s.io` rule on the `ClusterRole` your home IRSA's group is bound to (without it, pod health works but headroom reports "unavailable"). |
| **B — Two-cluster** | Sariva pod + Kafka on one EKS/account; **apps on a separate** EKS/account. | **Yes — once**, for the app EKS/account. |
| **C — Three-cluster** | Sariva, Kafka, and apps on **three** separate EKS clusters/accounts (security segmentation — the common enterprise shape). | **Yes — once per target account** (the app account, and the Kafka account if separate). |

Sariva decides per read: if the entity being read carries a `cross_account_reader_role_arn`, the pod calls `sts:AssumeRole` into it before the CloudWatch / EKS API call; if it does not, the pod uses its **home IRSA session** unchanged. So you only author a reader role for the accounts that actually differ from the pod's.

## What "reading" means here

The reader role grants **read-only** access for exactly two things:

1. **CloudWatch Logs Insights** — query the app's `cloudwatch_log_group` (and, for the Kafka account, the cluster's `kafka_log_groups`) to count and sample error-pattern matches.
2. **EKS Kubernetes API** — `eks:DescribeCluster` + a presigned-STS bearer token, then a read-only `GET` on pods in the app's namespace for pod health (phase, restarts, readiness).

Never a write verb. Never the Kafka admin key.

## 1. Set variables

Run these against the **target** account (the account holding the app workloads / log groups), and fill in the Sariva pod's home identity.

```bash theme={null}
# Target account (where the apps / log groups live)
export TARGET_ACCOUNT_ID="<target-account-id>"
export TARGET_REGION="<target-region>"
export TARGET_EKS_CLUSTER_NAME="<target-eks-cluster-name>"
export READER_ROLE_NAME="sariva-observability-crossacct-reader-role"

# Sariva pod's HOME identity — the Pod Identity role from the IRSA page,
# in the account where the Sariva platform pod runs.
export SARIVA_HOME_ACCOUNT_ID="<sariva-home-account-id>"
export SARIVA_HOME_ROLE_ARN="arn:aws:iam::${SARIVA_HOME_ACCOUNT_ID}:role/sariva-observability-reader-role"
```

## 2. Trust policy — let the Sariva pod assume the reader role

The reader role's trust policy allows **only** the Sariva pod's home Pod Identity role to assume it. Author this in the target account.

```json theme={null}
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "AllowSarivaHomeRoleToAssume",
      "Effect": "Allow",
      "Principal": {
        "AWS": "arn:aws:iam::<SARIVA_HOME_ACCOUNT_ID>:role/sariva-observability-reader-role"
      },
      "Action": [
        "sts:AssumeRole",
        "sts:TagSession"
      ]
    }
  ]
}
```

⚠WARNING

**`sts:TagSession` is required, not optional.** The Sariva pod gets its credentials from **EKS Pod Identity**, which stamps *transitive* session tags onto the pod's session. STS only lets those tags propagate into the assumed reader session if `sts:TagSession` is allowed on **both** this trust policy **and** the Sariva home role's identity policy (see [Wire the pod's AWS identity](https://sariva.mintlify.site/install-setup/irsa.md)). With `sts:AssumeRole` alone the assume fails closed with `AccessDenied` and every cross-account read returns empty.

ⓘINFO

**Confused-deputy protection.** The trust policy above already pins the principal to Sariva's specific home role ARN — assuming the reader role is impossible without holding that exact role, which is account-scoped by construction. Do **not** add an `sts:ExternalId` condition: Sariva does not send an external id on `AssumeRole`, so a trust policy that requires one would reject every assume and the reads would fail closed.

## 3. Read-only permissions on the reader role

Attach an inline policy granting only the two read paths. CloudWatch Logs Insights has a quirk: only `logs:StartQuery` can be ARN-scoped (with a trailing `:*`); `GetQueryResults` / `StopQuery` / `DescribeLogGroups` cannot be resource-scoped and must use `*`.

```json theme={null}
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "DescribeTargetEksCluster",
      "Effect": "Allow",
      "Action": "eks:DescribeCluster",
      "Resource": "arn:aws:eks:<TARGET_REGION>:<TARGET_ACCOUNT_ID>:cluster/<TARGET_EKS_CLUSTER_NAME>"
    },
    {
      "Sid": "StartLogInsightsQueryScoped",
      "Effect": "Allow",
      "Action": "logs:StartQuery",
      "Resource": "arn:aws:logs:<TARGET_REGION>:<TARGET_ACCOUNT_ID>:log-group:<app-log-group-prefix>*:*"
    },
    {
      "Sid": "ReadLogInsightsResults",
      "Effect": "Allow",
      "Action": [
        "logs:GetQueryResults",
        "logs:StopQuery",
        "logs:DescribeLogGroups"
      ],
      "Resource": "*"
    }
  ]
}
```

## 4. Read-only Kubernetes RBAC on the target EKS

`eks:DescribeCluster` + the bearer token only gets Sariva to the API server; the Kubernetes RBAC on the **target** cluster decides what it can read. Sariva reads pods in **one namespace** — the app's `k8s_namespace` — so define the permission set once as a read-only `ClusterRole`, then scope it to the app's namespace with a **namespaced** `RoleBinding` — the binding keeps the grant namespace-local even though the role object is cluster-scoped. Map the assumed reader role to a Kubernetes group, then bind that group to the `ClusterRole` via a `RoleBinding` in the app namespace. In the **single-cluster** case (Shape A) there is no assumed reader role — the principal is the pod's **home IRSA**; map that identity instead, and the same `ClusterRole` + `RoleBinding` (including the optional `metrics.k8s.io` rule for headroom) applies.

### 4a. ClusterRole + namespaced RoleBinding (read-only on pods)

```yaml theme={null}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: sariva-pod-reader
rules:
  - apiGroups: [""]
    resources: ["pods", "pods/log", "events"]
    verbs: ["get", "list", "watch"]
  # Optional — per-container CPU/mem headroom. Lets Sariva read live pod usage
  # from the metrics-server API (metrics.k8s.io). Requires metrics-server to be
  # installed on the target cluster. Omit this rule if you don't run metrics-server:
  # pod health still works and headroom is reported as "unavailable".
  - apiGroups: ["metrics.k8s.io"]
    resources: ["pods"]
    verbs: ["get", "list"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: sariva-pod-reader
  namespace: <your-app-namespace>
subjects:
  - kind: Group
    name: sariva-pod-readers
    apiGroup: rbac.authorization.k8s.io
roleRef:
  kind: ClusterRole
  name: sariva-pod-reader
  apiGroup: rbac.authorization.k8s.io
```

That is the core Kubernetes grant: read pods, pod logs, and events — scoped to **one** namespace by the `RoleBinding`, even though the `ClusterRole` object itself is cluster-scoped. Define the `ClusterRole` once, then add a `RoleBinding` per app namespace. The second rule (`metrics.k8s.io` → `pods`) is **optional** and powers per-container **CPU/mem headroom**.

ⓘINFO

**Headroom needs metrics-server.** The `metrics.k8s.io` API is served by [metrics-server](https://github.com/kubernetes-sigs/metrics-server), which is **not** installed on EKS by default — you add it. If metrics-server is absent **or** you omit the `metrics.k8s.io` rule above, pod health (phase / restarts / readiness) still works; only the headroom section degrades to **"live usage unavailable"** with a reason (`metrics-server not installed` vs `reader role lacks metrics.k8s.io access`). Sariva never hard-fails a health check on it. Sariva reads pod metrics only, never node metrics — and the namespaced `RoleBinding` keeps even the cluster-scoped `ClusterRole`'s grant confined to the one app namespace.

### 4b. Map the reader role to the `sariva-pod-readers` group

On a cluster using **EKS access entries** (recommended):

```bash theme={null}
aws eks create-access-entry \
  --cluster-name "$TARGET_EKS_CLUSTER_NAME" \
  --region "$TARGET_REGION" \
  --principal-arn "arn:aws:iam::${TARGET_ACCOUNT_ID}:role/${READER_ROLE_NAME}" \
  --kubernetes-groups sariva-pod-readers \
  --type STANDARD
```

On a cluster still using the legacy `aws-auth` ConfigMap, add an equivalent `mapRoles` entry mapping the reader role ARN to the `sariva-pod-readers` group instead.

!DANGER

Grant read verbs only (`get` / `list` / `watch`), and bind with a **namespaced** `RoleBinding` so the grant stays scoped to the app namespace — a `ClusterRole` referenced by a `RoleBinding` is namespace-local and safe. Sariva never writes to your cluster and never needs cluster-wide access. Never use a **`ClusterRoleBinding`** (that grants cluster-wide), and don't bind the reader group to any role carrying create / update / delete / patch verbs.

## 5. Tell Sariva the reader-role ARN

Record the role ARN on the registration of whatever Sariva reads. Sariva keys the assume-role **per target**:

* **App logs + app pod health** → set it on the **app** registration (`cross_account_reader_role_arn`), the account where the app runs.
* **Kafka-side pod health + Kafka log groups** → set it on the **cluster** registration (`cross_account_reader_role_arn`), the account where the brokers run.

### App teams — on the app registration

App teams set it when registering the app (`POST /api/v1/apps/register`, or `PUT` to add it later). Pair it with the app's `aws_region` and `eks_cluster_name`:

```json theme={null}
{
  "alias": "payments-consumer",
  "team": "payments",
  "app_type": "consumer",
  "language": "java_spring_boot",
  "cluster_alias": "prod-cc",
  "consumer_group_id": "payments-processor",
  "slack_channel": "#payments-alerts",
  "aws_account_id": "444444444444",
  "aws_region": "us-east-1",
  "eks_cluster_name": "apps-eks",
  "k8s_namespace": "payments",
  "k8s_pod_label_selector": "app=payments-consumer",
  "cloudwatch_log_group": "/aws/eks/apps-eks/payments-consumer",
  "cross_account_reader_role_arn": "arn:aws:iam::444444444444:role/sariva-observability-crossacct-reader-role"
}
```

See [Register an application](https://sariva.mintlify.site/app-teams/register.md) for the full field set.

### Platform/SRE — on the cluster registration

For Kafka-side reads (`platform_admin` / `sre_engineer` only), set it on the cluster (`POST /api/v1/clusters/register`, or `PATCH` to add it later), alongside `aws_account_id`, `aws_region`, `eks_cluster_name`, and the `kafka_log_groups` list:

```json theme={null}
{
  "alias": "prod-cfk",
  "display_name": "Prod CFK",
  "flavor": "confluent_platform",
  "environment_label": "production",
  "bootstrap_servers": "kafka.internal:9092",
  "auth_type": "sasl_ssl_plain",
  "credentials_ref": "arn:aws:secretsmanager:us-east-1:333333333333:secret:prod/clusters/prod-cfk/observability-reader-AbCdEf",
  "aws_account_id": "333333333333",
  "aws_region": "us-east-1",
  "eks_cluster_name": "kafka-eks",
  "cross_account_reader_role_arn": "arn:aws:iam::333333333333:role/sariva-observability-crossacct-reader-role",
  "kafka_log_groups": [
    { "name": "/aws/eks/kafka-eks/broker", "kind": "broker" },
    { "name": "/aws/eks/kafka-eks/controller", "kind": "controller" }
  ]
}
```

Omit `cross_account_reader_role_arn` (or leave it null) for a same-account cluster — Sariva uses its home IRSA session.

## 6. Verify

After the role, RBAC, and registration are in place, ask Sariva to investigate the app, or wait for an `alert_on_error_pattern` / `alert_on_pod_restart` to fire. A working cross-account read shows up as:

* pod health returning a real phase + restart counts (not `phase=Unknown`);
* error-pattern investigations returning matched counts + sample log lines.

If a read **fails closed** — pod health stays `phase=Unknown` or logs come back empty with a reason — check, in order:

| Symptom | Likely cause |
| - | - |
| `sts_assume_role_denied` | The reader role's **trust policy** is missing the Sariva home role under `sts:AssumeRole` — **or** it allows `sts:AssumeRole` but not `sts:TagSession`. EKS Pod Identity attaches transitive session tags, so the chained assume needs `sts:TagSession` on **both** this trust policy and the home role's identity policy; with only `sts:AssumeRole` STS returns `AccessDenied`. (Do **not** add an `sts:ExternalId` condition — Sariva does not send one.) |
| `eks_describe_failed` | The reader role lacks `eks:DescribeCluster` on the target cluster, or `eks_cluster_name` is wrong. |
| `k8s_unauthorized` (401/403) | The reader role is assumable but **not mapped** to the `sariva-pod-readers` group, or the group is not bound to the read-only ClusterRole. |
| Logs always empty | The reader role lacks `logs:StartQuery` on the app log-group ARN, or `cloudwatch_log_group` / `kafka_log_groups` is wrong. |
| Headroom "live usage unavailable" | metrics-server isn't installed on the target cluster (`metrics-server not installed`), or the reader Role is missing the `metrics.k8s.io` `pods` rule (`reader role lacks metrics.k8s.io access`, a 403). Pod health is unaffected — only CPU/mem headroom is blind. |

Every failure degrades to an empty signal or `phase=Unknown` **with a reason** — never a 500. Sariva keeps serving other apps while you fix the grant.

## Per-topology recap

* **Shape A** — skip this page entirely.
* **Shape B** — author one reader role in the **app** account; set `cross_account_reader_role_arn` on each app registration there.
* **Shape C** — author one reader role **per target account** (apps account, Kafka account); set it on the app registrations and the cluster registration respectively.

## Continue

> [card] [Back: wire the pod's AWS identity](https://sariva.mintlify.site/install-setup/irsa.md)
>
> The pod's home Pod Identity role — the principal the reader-role trust policy references.

> [card] [App teams: logs & pod health](https://sariva.mintlify.site/app-teams/logs-and-pod-health.md)
>
> How app-side log scanning and pod health reads work once the reader role is in place.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.