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

# Overview — connecting a Kafka cluster

> Register the Kafka cluster record, attach a credential reference, and validate access without storing broker secrets in Sariva.

ⓘINFO

**This page covers the Confluent Cloud path.** On **AWS EKS + Confluent Platform (CFK)**, connection is mostly automatic and there is no Kafka API key — use [Connecting a CFK cluster](https://sariva.mintlify.site/connecting-clusters/cfk.md) instead.

**After the wizard and the platform deploy** (Helm on EKS, `docker compose up -d` on a VM). This page completes the Kafka cluster connection that started in the wizard's cluster step — **Step 7 — Cluster connection** on the EKS path, **Step 4 — Connect existing clusters** on the VM path, where the clusters already exist and you give each one's `file://` reference (see [file:// and env://](https://sariva.mintlify.site/connecting-clusters/file-env.md)). The wizard can declare the Kafka cluster, and GitHub Actions can provision it, but the Kafka API credential is attached only after the Kafka cluster exists and the Sariva platform is running.

## Terms used on this page

Use these terms consistently when reading the remaining pages:

| Term | Meaning |
| - | - |
| **Register a Kafka cluster** | Create or update the Kafka cluster metadata row in Sariva: alias, bootstrap servers, provider/flavor, Confluent environment ID, Confluent cluster ID, and optional credential reference. |
| **Attach a credential** | Add or update `credentials_ref` for an already-registered Kafka cluster. This is usually done with `sariva cluster patch`. |
| **Connect a Kafka cluster** | The full end-to-end flow: register the Kafka cluster, attach the credential reference, pass the credential gate, and validate that Sariva can read metadata/observability data. |

⚠WARNING

**Sariva never stores your Kafka credentials.** The secret value stays in *your* credential store. Sariva stores only a **credential reference URI** and fetches the secret value at runtime when it needs to talk to the Kafka cluster.

## Per-cluster credentials: admin key vs observability key

For Confluent Cloud clusters, keep these two credentials separate. They have different privilege levels and different consumers.

| Credential | Purpose | Who uses it | Where it should live |
| - | - | - | - |
| **Admin Kafka key** | Lets Terraform configure the Kafka cluster, for example topics, ACLs, and cluster-layer resources. | GitHub Actions / Terraform. | Customer-owned credential store such as AWS Secrets Manager or AWS SSM. |
| **Observability Kafka key** | Lets Sariva monitor the Kafka cluster, list topics, and inspect consumer groups. | Sariva platform at runtime (EKS pod or VM container). | Customer-owned credential store such as AWS Secrets Manager, AWS SSM, or Kubernetes Secret; on a VM, a JSON file in `./secrets` (`file://`) or an environment variable (`env://`). |

The Sariva pod does not create Confluent Cloud or AWS resources directly. Resource creation happens through GitOps: Sariva emits Terraform, opens a pull request, and GitHub Actions applies it with the customer-owned CI identity. The pod reads only the final observability credential reference at runtime.

⚠WARNING

Do not grant the Sariva pod access to the admin Kafka key. The admin key is for GitHub Actions / Terraform. The pod needs read access only to the observability credential used for monitoring.

## Preconditions for laptop-based REST commands

The commands below run from your laptop against the Sariva platform REST API.

```bash theme={null}
export SARIVA_PLATFORM_API_KEY="sariva_<generated-admin-bearer>"
export SARIVA_PLATFORM_URL="http://127.0.0.1:8000"
```

On the [Linux VM (Docker) path](https://sariva.mintlify.site/deploy/vm-docker-cc.md) there is no port-forward — the API is already at `http://localhost:8000` and the bearer is the value you set in `.env`:

```bash theme={null}
export SARIVA_PLATFORM_API_KEY=$(grep ^SARIVA_PLATFORM_API_KEY .env | cut -d= -f2)
export SARIVA_PLATFORM_URL="http://localhost:8000"
```

On the Kubernetes paths, if the platform is not exposed through an ingress URL, port-forward the Kubernetes Service from another terminal:

```bash theme={null}
export RELEASE_NS="sariva-platform"
export SARIVA_SERVICE="$(kubectl -n "$RELEASE_NS" get svc \
  -l app.kubernetes.io/instance=sariva-platform,app.kubernetes.io/name=sariva-platform \
  -o jsonpath='{.items[0].metadata.name}')"

kubectl -n "$RELEASE_NS" port-forward "svc/${SARIVA_SERVICE:-sariva-platform}" 8000:8000
```

ⓘINFO

The CLI reads the bearer automatically from `$SARIVA_PLATFORM_API_KEY`. Use `--api-key <bearer>` only if you do not export the environment variable.

## Credential reference formats

`<CRED_REF>` is one of these forms:

| Credential store | Reference format | pod AWS identity required? |
| - | - | - |
| Kubernetes Secret | `k8s://<namespace>/<secret-name>` | No — use Kubernetes RBAC. |
| AWS Secrets Manager | `arn:aws:secretsmanager:<region>:<account>:secret:<stage>/<env>/clusters/<cluster>/observability-reader-<suffix>` | Yes. |
| AWS SSM Parameter Store | `arn:aws:ssm:<region>:<account>:parameter/<path>` | Yes. |
| JSON file on the host ([VM path](https://sariva.mintlify.site/deploy/vm-docker-cc.md)) | `file:///app/secrets/<name>.json` — the **in-container** path; the wizard-emitted compose mounts `./secrets` read-only at `/app/secrets`, so drop the file there | No — see [file:// and env://](https://sariva.mintlify.site/connecting-clusters/file-env.md). |
| Environment variable ([VM path](https://sariva.mintlify.site/deploy/vm-docker-cc.md)) | `env://VAR_NAME` | No — see [file:// and env://](https://sariva.mintlify.site/connecting-clusters/file-env.md). |

⚠WARNING

For AWS Secrets Manager or AWS SSM credential references, Sariva fetches Kafka cluster credentials at runtime using the Sariva platform pod's AWS identity. Wire the pod AWS identity and grant the matching read permission **before** you register or patch the Kafka cluster with an AWS credential reference. See [Wire the pod's AWS identity](https://sariva.mintlify.site/install-setup/irsa.md).

⚠WARNING

The old `k8s_secret://<name>` shorthand is **rejected** by registration. Use explicit `k8s://<namespace>/<name>`. Vault, GCP Secret Manager, and Azure Key Vault are deferred.

## Before you attach a credential, create or obtain it

The commands on this page attach a **credential reference** to a Kafka cluster. They do not create Confluent Cloud Kafka API keys by themselves. Create or obtain the required credential first, store it in your chosen credential store, then attach the reference.

| Kafka provider / auth path | What credential is needed first | Where to continue |
| - | - | - |
| **Confluent Cloud** | An observability Kafka API key/secret for Sariva runtime monitoring. If Terraform will manage topics/ACLs, the cluster layer also needs an admin Kafka key in the CI-accessible credential store. | [Confluent Cloud: per-cluster access](https://sariva.mintlify.site/connecting-clusters/cc-per-cluster-access.md) |
| **MSK with IAM auth** | No Kafka API key/secret. Sariva uses the pod's AWS identity. | [MSK](https://sariva.mintlify.site/connecting-clusters/msk.md) and [pod AWS identity](https://sariva.mintlify.site/install-setup/irsa.md) |
| **MSK or self-hosted with SASL/SCRAM or PLAIN** | A username/password created in the customer's Kafka authentication system. | [Self-hosted Kafka](https://sariva.mintlify.site/connecting-clusters/self-hosted.md) |
| **mTLS** | Client certificate/key and CA material. | [Kubernetes Secret](https://sariva.mintlify.site/connecting-clusters/kubernetes-secret.md) |

For Confluent Cloud, there are two credential tasks:

1. **Admin Kafka key, current manual path.** After the Kafka cluster exists, create a cluster-level admin service account/key for Terraform and store that key in the CI-accessible credential store, such as AWS Secrets Manager or SSM. GitHub Actions reads this key during the cluster-layer apply.
2. **Observability Kafka key, GitOps path.** Ask Sariva through Slack to create an observability credential for the Kafka cluster and store it in your selected credential store. Sariva opens a PR; GitHub Actions applies Terraform to create the read-only service account/key, writes the secret, and emits the credential reference for Sariva runtime monitoring.

⚠WARNING

If the Kafka credential store is **AWS Secrets Manager** or **AWS SSM**, two separate AWS permissions are involved: GitHub Actions needs access to read the admin credential and write the observability credential; the Sariva platform pod needs pod AWS identity read access to fetch the observability credential at runtime. Wire both before you rely on that credential reference.

## How Kafka cluster registration can happen

Sariva supports watcher-driven registration and explicit REST registration. Pick the case that matches how your Kafka cluster was created.

| Purpose | Command | When to use |
| - | - | - |
| **Verify the watcher registered the Kafka cluster** | `sariva cluster list --api-url "$SARIVA_PLATFORM_URL"` | GitHub Actions path with `workflow_watcher.enabled: true`. This is the happy path after Terraform apply. |
| **Register a Confluent Cloud Kafka cluster by reference** | `sariva cluster register --alias <alias> --bootstrap-servers <host:9092> --confluent-cluster-id <lkc-xxxxx> --confluent-env-id <env-xxxxx> --credentials-ref <CRED_REF> --api-url "$SARIVA_PLATFORM_URL"` | Watcher disabled, non-GitHub CI, or explicit manual registration using values from Terraform output or Confluent Cloud. |
| **Register an MSK Kafka cluster with IAM auth** | `sariva cluster register --alias <alias> --bootstrap-servers <host:9098> --flavor msk --auth-type iam --api-url "$SARIVA_PLATFORM_URL"` | MSK with IAM auth. No `--credentials-ref`; the pod uses its AWS identity. |
| **Validate a credential reference before writing** | `sariva cluster register --alias <alias> --credentials-ref <CRED_REF> --api-url "$SARIVA_PLATFORM_URL" --dry-run` | Check that the reference can pass the credential gate before creating or changing a Kafka cluster row. |
| **Attach or update a credential on an existing Kafka cluster** | `sariva cluster patch --alias <alias> --credentials-ref <CRED_REF> --api-url "$SARIVA_PLATFORM_URL"` | A registered Kafka cluster is in `awaiting_credentials` state, commonly after watcher registration. |

!DANGER

Do **not** use `sariva cluster register --from-tf-outputs` from a customer laptop for this REST path. That mode is for local `platform.db` access in controlled runtime contexts, not a REST bulk import from the laptop. For customer laptops, use the watcher or the explicit REST commands above.

## Registering clusters from your own pipeline

If you answered **N** to the wizard's CI/CD applier question (Jenkins / ArgoCD / kubectl-only), there is no workflow watcher — your pipeline applies the Terraform and registers the resulting Kafka clusters itself. Three paths, shortest first:

**Path 1 — bulk, from `terraform output -json` (in-pod).** `--from-tf-outputs` writes the platform's registry database directly, so it runs **inside the platform pod** (see the warning above — not from a laptop):

```bash theme={null}
kubectl -n sariva-platform cp outputs.json <pod>:/tmp/outputs.json
kubectl -n sariva-platform exec <pod> -- \
  sariva cluster register --from-tf-outputs /tmp/outputs.json --env-name <env_name>
```

The parser reads the env-layer shape — one entry per Kafka cluster under a top-level `kafka_clusters` output. If your pipeline doesn't keep the emitted `outputs.tf`, synthesize the minimal equivalent:

```json theme={null}
{
  "kafka_clusters": {
    "value": {
      "payments-cluster": {
        "id": "lkc-xxxxx",
        "env_id": "env-xxxxx",
        "bootstrap_endpoint": "SASL_SSL://pkc-xxxxx.us-east-1.aws.confluent.cloud:9092",
        "rest_endpoint": "https://pkc-xxxxx.us-east-1.aws.confluent.cloud:443"
      }
    }
  },
  "environment_label": { "value": "dev" }
}
```

`id`, `env_id`, and `bootstrap_endpoint` are required per cluster; `rest_endpoint` and `environment_label` are optional. Re-running on the same file is a no-op (`already-known`).

**Path 2 — per cluster, with explicit flags (from anywhere).** The REST-client commands from the table above — `sariva cluster register --api-url … --alias … --bootstrap-servers … --credentials-ref <CRED_REF>` — work from any machine that can reach the platform API. Omit `--credentials-ref` only with `--auth-type iam` (MSK pod identity).

**Path 3 — raw REST (pipelines that can't run the sariva CLI).** `POST /api/v1/clusters/register` with the admin bearer:

```bash theme={null}
curl -sS -X POST "$SARIVA_PLATFORM_URL/api/v1/clusters/register" \
  -H "Authorization: Bearer $SARIVA_PLATFORM_API_KEY" \
  -H "Content-Type: application/json" \
  -d @payload.json
```

```json theme={null}
{
  "alias": "payments-prod",
  "display_name": "payments-prod",
  "flavor": "confluent_cloud",
  "environment_label": "prod",
  "sdlc_tier": "prod",
  "bootstrap_servers": "pkc-xxxxx.us-east-1.aws.confluent.cloud:9092",
  "auth_type": "sasl_ssl_plain",
  "credentials_ref": "k8s://sariva-platform/payments-prod-kafka-creds",
  "monitoring_enabled": true,
  "confluent_cluster_id": "lkc-xxxxx",
  "confluent_env_id": "env-xxxxx",
  "rest_proxy_url": "https://pkc-xxxxx.us-east-1.aws.confluent.cloud:443"
}
```

Required: `alias` (your own spelling of the cluster's name — letters, digits, `.`, `_` and `-`, starting with a letter or digit, 1–64 characters; `cluster_nc01` is fine), `display_name`, `flavor`, `environment_label` (any one word of yours — `dev`, `nonprod`, `production`, `dr`, `dmz`, …), `bootstrap_servers`, `auth_type`; `sdlc_tier` (`non_prod|prod`) when the label is not a known word (`dmz`, `live`) — a known word sets it (`production`, `prod`, `dr` → `prod`; `dev`, `qa`, `uat`, `staging`, `test`, `nonprod`, `sandbox` → `non_prod`); `credentials_ref` for every `auth_type` except `iam`. Unknown fields are rejected. Responses: `201` registered; `409` already registered (use `sariva cluster patch` / `PATCH /api/v1/clusters/{alias}`); `400` credential-gate failure; `422` unreachable.

## Common path after GitHub Actions first apply

If the watcher registered the Kafka cluster, `sariva cluster list` should show something like this:

```text theme={null}
┏━━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ ALIAS       ┃ STATE   ┃ CRED_LIFECYCLE       ┃ NEXT_ACTION                                                                               ┃
┡━━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ dev_cluster │ unknown │ awaiting_credentials │ DM Sariva: 'create observability credential for cluster dev_cluster, store in <provider>' │
└─────────────┴─────────┴──────────────────────┴───────────────────────────────────────────────────────────────────────────────────────────┘
```

This means the Kafka cluster metadata is registered, but Sariva does not yet have a runtime observability credential. For Confluent Cloud, start with [Confluent Cloud: per-cluster access](https://sariva.mintlify.site/connecting-clusters/cc-per-cluster-access.md) to understand the admin key and observability key sequence. Then store the observability credential in your chosen credential store, grant Sariva read access, and attach the reference:

```bash theme={null}
sariva cluster patch \
  --alias <alias> \
  --credentials-ref <CRED_REF> \
  --api-url "$SARIVA_PLATFORM_URL"
```

After the patch succeeds, the credential lifecycle should move from `awaiting_credentials` to `resolved`.

## Universal credential ordering

⚠WARNING

**Do these in this exact order or the credential gate fails:**

1. **Create the Kafka credential** in your chosen store.
2. **Grant Sariva read access** to that credential. For Kubernetes, bind `secrets:get` to the Sariva platform ServiceAccount. For AWS, attach the required IAM statement to the pod AWS identity role. For `file://` on the VM path, put the file in `./secrets/` (`chmod 600`) — the compose mount makes it readable in-container at `/app/secrets/`.
3. **Register or patch the Kafka cluster with the credential reference** from your laptop.
4. Sariva resolves the reference under the platform's own identity, **inside the container/pod**, and validates the payload shape. If the Secret, keys, path, or RBAC/IAM access are wrong, the command returns an actionable error.

## Payload shape per `auth_type`

The Secret, parameter, file, or variable must carry these keys:

| `auth_type` | K8s Secret keys | AWS SM / SSM JSON | `file://` / `env://` JSON (VM path) |
| - | - | - | - |
| `api_key` (Confluent Cloud) | `api_key`, `api_secret` | `{"api_key":"…","api_secret":"…"}` | `{"api_key":"…","api_secret":"…"}` |
| `sasl_ssl_plain`, `sasl_ssl_scram` | `username`, `password` | `{"username":"…","password":"…"}` | `{"username":"…","password":"…"}` |
| `mtls` (PEM) | `client.cert.pem`, `client.key.pem`, `ca.cert.pem`, optional `client.key.password` | K8s Secret only | K8s Secret only |
| `mtls` (JKS) | `keystore.jks`, `truststore.jks`, `keystore.password`, `truststore.password` | K8s Secret only | K8s Secret only |
| `iam` (MSK) | none — auth via the pod AWS identity | none | none |

ⓘINFO

For Confluent Cloud use `auth_type: api_key` and store `api_key` / `api_secret`. `sasl_ssl_plain` also works if you remap via `keys: { username: api_key, password: api_secret }` — same credential, different declared shape.

ⓘINFO

After the gate resolves, the admin-client probe may report `reachable:false` for Confluent Cloud. Consumer-lag uses the Confluent Cloud Metrics API, keyed on `monitoring_ok`, not on `reachable`. Do not read `reachable:false` alone as broken.

## How to connect each Kafka cluster

Pick the page that matches where that Kafka cluster's credentials live, or its provider/flavor:

> [card] [Kubernetes Secret](https://sariva.mintlify.site/connecting-clusters/kubernetes-secret.md)
>
> Verified path; also the only mTLS option.

> [card] [AWS Secrets Manager](https://sariva.mintlify.site/connecting-clusters/aws-secrets-manager.md)
>
> JSON secret + pod AWS identity read policy.

> [card] [AWS SSM](https://sariva.mintlify.site/connecting-clusters/aws-ssm.md)
>
> SecureString parameter + KMS decrypt.

> [card] [file:// and env://](https://sariva.mintlify.site/connecting-clusters/file-env.md)
>
> VM-native: a JSON file on the host, or a named env var.

> [card] [Self-hosted](https://sariva.mintlify.site/connecting-clusters/self-hosted.md)
>
> SASL/SCRAM, PLAIN, mTLS — customer-managed.

> [card] [MSK](https://sariva.mintlify.site/connecting-clusters/msk.md)
>
> IAM auth via the pod AWS identity — no stored credential.

> [card] [Migration & rotation](https://sariva.mintlify.site/connecting-clusters/rotation.md)
>
> Rotate keys; migrate from an older flow.

## Continue the deployment path

> [card] [Next: per-cluster credentials](https://sariva.mintlify.site/connecting-clusters/cc-per-cluster-access.md)
>
> Create the admin Kafka key and attach the observability credential for each Confluent Cloud cluster.

> [card] [Back to the AWS EKS path](https://sariva.mintlify.site/deploy/aws-eks-cc.md)
>
> Return to the EKS path map to confirm where this step fits.

> [card] [Back to the VM path](https://sariva.mintlify.site/deploy/vm-docker-cc.md)
>
> Running on a Linux VM? Return to the VM checklist.


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