# AlmaForge Storage Guide

AlmaForge starts with SQLite cluster state and local audit and recording storage for a single-host evaluation. No external storage service is needed for the [Standalone guide](https://almaforge.com/deployment/standalone.md). See [SQLite](https://almaforge.com/storage/sqlite.md) and [Filesystem](https://almaforge.com/storage/local.md) to customize these defaults.

For production, choose shared backends before adding Auth replicas. The [`StorageConfig` resource](https://almaforge.com/reference/configuration.md#storageconfig) configures three kinds of data. Its name selects the purpose, and the driver field under `spec` selects the backend.

1. **Cluster state.** Every resource the cluster knows about. Users, roles, connectors, tokens, registered nodes and databases, certificate authorities, locks, access requests, session metadata. One backend. Required. Configured as `StorageConfig` with `metadata.name: state`.
2. **Audit events.** Structured JSON records of what happened. Logins, role changes, session starts and stops, lock events, command executions. Configured as `StorageConfig` with `metadata.name: audit` (the default, a filesystem sink materialized automatically when nothing else is set) or any name starting with `audit-` (named sinks for fan-out, where every emitted event goes to every audit-\* instance).
3. **Session recordings.** Raw terminal and Kubernetes session streams. One destination. Configured as `StorageConfig` with `metadata.name: recordings`.

A `StorageConfig` resource looks like this:

[`state.yaml`](https://almaforge.com/examples/storage/overview/state.yaml):

examples/storage/overview/state.yaml

```yaml
# Minimal shared state backend using DynamoDB.

apiVersion: almaforge.com/v1

kind: StorageConfig

metadata:

  name: state

spec:

  dynamo:

    region: us-east-1

    tableName: cluster-state
```

Set exactly one driver field under `spec` in each resource. In this example, `dynamo` selects DynamoDB for cluster state.

## Default configuration[​](#default-configuration "Direct link to Default configuration")

Out of the box AlmaForge runs on **[SQLite](https://almaforge.com/storage/sqlite.md)** for cluster state and the **[`dir`](https://almaforge.com/storage/local.md)** driver for both audit events and session recordings, all under the data directory. **No storage configuration is needed to start a cluster.** The defaults are equivalent to these three resources:

[`defaults.yaml`](https://almaforge.com/examples/storage/overview/defaults.yaml):

examples/storage/overview/defaults.yaml

```yaml
# What AlmaForge runs with when no StorageConfig is authored. Writing

# these files changes nothing; they are here to be edited from.

apiVersion: almaforge.com/v1

kind: StorageConfig

metadata:

  name: state

spec:

  sqlite:

    path: /var/lib/almaforge/backend

---

apiVersion: almaforge.com/v1

kind: StorageConfig

metadata:

  name: audit

spec:

  dir:

    path: /var/lib/almaforge/audit

---

apiVersion: almaforge.com/v1

kind: StorageConfig

metadata:

  name: recordings

spec:

  dir:

    path: /var/lib/almaforge/audit
```

AlmaForge materializes these at startup, so `alma get storageconfig` lists them on a cluster that configured nothing. Author your own resource with the same `metadata.name` to replace one of them.

On disk that leaves one data directory holding all three:

text

```text
/var/lib/almaforge/

├── backend/

│   └── sqlite.db                                  cluster state

└── audit/

    ├── events/

    │   └── 2026/11/16/

    │       └── 2026-11-16-<host-id>.jsonl         audit events

    ├── records/

    │   └── <session-id>.pb                         session recordings

    └── records-index/

        └── 2026/11/16/09/

            └── <unix-nanos>-<session-id>.jsonl.gz  the recordings listing
```

`records/` and `records-index/` fill in as sessions are recorded. See [Filesystem](https://almaforge.com/storage/local.md) for how the `dir` layout behaves as it grows.

## Bootstrap-only[​](#bootstrap-only "Direct link to Bootstrap-only")

`StorageConfig` is bootstrap-only. Place its manifests in `/etc/almaforge/almad.d` on each Auth host before startup. To change storage configuration, update those files on every Auth host and restart the Auth Service pool. See [Infrastructure as Code](https://almaforge.com/infrastructure-as-code.md) for file ownership and configuration loading.

The Auth Service must know its storage endpoints before connecting to cluster state. Audit and recording destinations follow the same startup configuration model. Changing a destination does not migrate data already stored in the previous backend. Plan [backups and recovery](https://almaforge.com/backups.md) before a storage cutover.

You can read the active configuration any time:

******Terminal

```bash
alma get storageconfig -o yaml
alma get storageconfig/state -o yaml
alma get storageconfig/audit-primary -o yaml
alma get storageconfig/recordings -o yaml
```

`alma get` reports the active configuration with sensitive credentials redacted.

The CLI can read `StorageConfig`, but cannot apply, edit, or delete it.

## Cluster state[​](#cluster-state "Direct link to Cluster state")

The state backend is the cluster's source of truth. Every Auth Service instance reads and writes through it. There is exactly one `StorageConfig` with `metadata.name: state`, and every Auth instance must point at the same backend with the same parameters.

| Driver field     | Use when                                             | HA story                   | Page                                                      |
| ---------------- | ---------------------------------------------------- | -------------------------- | --------------------------------------------------------- |
| `spec.sqlite`    | dev, evaluation, single-node                         | none                       | [SQLite](https://almaforge.com/storage/sqlite.md)         |
| `spec.postgres`  | self-hosted HA, Azure, bare metal                    | replica + failover you run | [PostgreSQL](https://almaforge.com/storage/postgresql.md) |
| `spec.dynamo`    | AWS deployments                                      | AWS-managed                | [DynamoDB](https://almaforge.com/storage/dynamodb.md)     |
| `spec.etcd`      | VM HA with local quorum, or shops with existing etcd | self-hosted quorum         | [etcd](https://almaforge.com/storage/etcd.md)             |
| `spec.firestore` | GCP deployments                                      | GCP-managed                | [Firestore](https://almaforge.com/storage/firestore.md)   |

SQLite supports one Auth instance with local state. For multiple Auth instances, use a shared backend and point every instance at the same store. Separate SQLite files do not form one HA cluster, and sharing a SQLite directory between Auth processes is unsupported.

### VM HA state topology[​](#vm-ha-state-topology "Direct link to VM HA state topology")

VM deployments usually start with three control-plane VMs running Auth and Proxy. Choose where cluster state lives before you write the VM runbook or build firewall rules. The [Linux deployment guide](https://almaforge.com/deployment/linux.md#external-storage) uses an external etcd backend by default. You can run those etcd members on separate hosts or colocate them with the control plane, provided you budget disk performance and failure domains for both services.

| Storage backend | Use when                                                        | Topology effect                                                                                           |
| --------------- | --------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- |
| etcd            | You operate an etcd quorum for cluster state.                   | Run three members on separate hosts, or colocate one member on each cluster VM with sufficient resources. |
| PostgreSQL      | You already run a managed or self-hosted HA PostgreSQL service. | Remove colocated etcd and depend on PostgreSQL availability.                                              |
| DynamoDB        | The cluster runs in AWS and you want managed state storage.     | Remove colocated etcd and depend on DynamoDB IAM, region, and table capacity.                             |
| Firestore       | The cluster runs in GCP and you want managed state storage.     | Remove colocated etcd and depend on Firestore IAM and project availability.                               |

The Auth and Proxy VM shape remains the same unless you intentionally choose a different architecture. PostgreSQL, DynamoDB, and Firestore replace only the state-backend part of the default topology.

## Audit events[​](#audit-events "Direct link to Audit events")

Audit events are sent to every `StorageConfig` instance named `audit` or matching `audit-*`. AlmaForge materializes a default `audit` instance with the `dir` driver when the operator configures nothing, so an audit destination is configured out of the box and visible in `alma get storageconfig`. Override that default by authoring your own `audit` instance, or add `audit-<suffix>` instances for fan-out to multiple destinations. Typical fan-out is one primary external store, one `dir` copy on local disk, and a `file` instance for a collector to follow. [Monitor audit delivery failures](https://almaforge.com/monitoring.md#alerts-that-earn-their-keep) on every deployment.

| Driver field     | Target                                                               | Page                                                                                              |
| ---------------- | -------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| `spec.dynamo`    | DynamoDB (use a different `tableName` than the state instance)       | [DynamoDB](https://almaforge.com/storage/dynamodb.md#step-3-write-any-audit-events-resources)     |
| `spec.postgres`  | PostgreSQL (use a different database than the state instance)        | [PostgreSQL](https://almaforge.com/storage/postgresql.md#step-3-write-any-audit-events-resources) |
| `spec.firestore` | Firestore (use a different `collectionName` than the state instance) | [Firestore](https://almaforge.com/storage/firestore.md#step-3-write-any-audit-events-resources)   |
| `spec.s3`        | Amazon S3 or any S3-compatible object store                          | [S3](https://almaforge.com/storage/s3.md#step-3-write-any-audit-events-resources)                 |
| `spec.dir`       | A directory on each Auth host, or one they share                     | [Filesystem](https://almaforge.com/storage/local.md)                                              |
| `spec.file`      | One file for a log collector to follow                               | [Filesystem](https://almaforge.com/storage/local.md)                                              |
| `spec.stdout`    | The Auth Service's own standard output                               | [Standard output](#standard-output)                                                               |
| `spec.athena`    | AWS Athena over S3 + SNS + SQS + Glue                                | not currently documented                                                                          |

An `audit-*` instance is not exclusive. A typical fan-out keeps the searchable store external and writes a second copy to local disk, which is what to read when the external store is unreachable.

[`audit-fanout.yaml`](https://almaforge.com/examples/storage/overview/audit-fanout.yaml):

examples/storage/overview/audit-fanout.yaml

```yaml
# DynamoDB as the searchable audit store, plus a copy on each Auth

# host's filesystem to read when DynamoDB is unreachable.

apiVersion: almaforge.com/v1

kind: StorageConfig

metadata:

  name: audit-primary

spec:

  dynamo:

    region: us-east-1

    tableName: cluster-audit

---

apiVersion: almaforge.com/v1

kind: StorageConfig

metadata:

  name: audit-local

spec:

  dir:

    path: /var/lib/almaforge/audit
```

Each Auth host writes the events it handled to the local instance on its own disk. Events missed during an outage are not imported back into the primary afterwards.

Audit searches use the first configured destination that supports the search operation. Search results are not merged across destinations, and an error from that destination does not trigger a search of the next one. Put the destination you want to search first in the bootstrap configuration.

Retention lives on the driver block as `auditRetentionPeriod`. Only the drivers whose backend implements retention in code honor it: `dynamo` (per-item TTL), `postgres` (background sweeper), and `firestore` (background purge). `athena` and `s3` delegate retention to S3 lifecycle rules, and neither `dir` nor `file` deletes anything, so the field is rejected on those drivers and on non-`audit-*` instances.

An object store answers a search by listing and reading objects rather than by querying an index, so `s3` asks for a narrow time window and refuses a search that would read more than its scan limits allow. A deployment that searches long windows routinely belongs on a database driver.

### Standard output[​](#standard-output "Direct link to Standard output")

`stdout` writes each audit event to the Auth Service's own standard output and takes no settings at all. Select it with `stdout: {}` on an `audit` or `audit-<suffix>` instance.

Use it for development and smoke tests, where watching events scroll past beats wiring a real sink, and on a host whose log collector already ships the process output. It stores nothing itself, so pair it with a durable sink for anything you have to be able to search later.

## Session recordings[​](#session-recordings "Direct link to Session recordings")

Session recordings land in one destination, configured as `StorageConfig` with `metadata.name: recordings`. If you need a second copy, configure replication or a backup process in the storage service. Lifecycle rules control retention or storage class, not a second independent recording destination.

| Driver field | Target                                           | Page                                                      |
| ------------ | ------------------------------------------------ | --------------------------------------------------------- |
| `spec.s3`    | Amazon S3 or any S3-compatible object store      | [S3](https://almaforge.com/storage/s3.md)                 |
| `spec.gcs`   | Google Cloud Storage                             | [GCS](https://almaforge.com/storage/gcs.md)               |
| `spec.azure` | Azure Blob Storage                               | [Azure Blob](https://almaforge.com/storage/azure-blob.md) |
| `spec.dir`   | A directory on each Auth host, or one they share | [Filesystem](https://almaforge.com/storage/local.md)      |

Recording **storage** (where the files land) is independent of recording **mode** (where and how the stream is captured). Mode lives in the [`RecordingConfig` resource](https://almaforge.com/reference/audit.md#modes) and takes values `node`, `proxy`, `node-sync`, `proxy-sync`, or `off`.

## Pick a set[​](#pick-a-set "Direct link to Pick a set")

Most operators run matched sets so they do not cross cloud boundaries.

| Environment | State                                                                               | Audit primary                                                                                                       | Recordings                                                |
| ----------- | ----------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------- |
| AWS         | [DynamoDB](https://almaforge.com/storage/dynamodb.md)                               | [DynamoDB (second table)](https://almaforge.com/storage/dynamodb.md#step-3-write-any-audit-events-resources)        | [S3](https://almaforge.com/storage/s3.md)                 |
| GCP         | [Firestore](https://almaforge.com/storage/firestore.md)                             | [Firestore (second collection)](https://almaforge.com/storage/firestore.md#step-3-write-any-audit-events-resources) | [GCS](https://almaforge.com/storage/gcs.md)               |
| Azure       | [PostgreSQL (Azure AD)](https://almaforge.com/storage/postgresql.md#authentication) | [PostgreSQL (second database)](https://almaforge.com/storage/postgresql.md#step-3-write-any-audit-events-resources) | [Azure Blob](https://almaforge.com/storage/azure-blob.md) |
| Linux hosts | [SQLite](https://almaforge.com/storage/sqlite.md)                                   | [Filesystem](https://almaforge.com/storage/local.md)                                                                | [Filesystem](https://almaforge.com/storage/local.md)      |
| Kubernetes  | [etcd](https://almaforge.com/storage/etcd.md)                                       | [S3-compatible](https://almaforge.com/storage/s3.md#step-3-write-any-audit-events-resources)                        | [S3-compatible](https://almaforge.com/storage/s3.md)      |

The driver pool is shared across instance names. A `dynamo` driver block looks the same whether it is configuring `name: state` or `name: audit-primary`. The `dir` driver works for both audit and recordings. There is no per-instance schema duplication.

## A complete bootstrap example[​](#a-complete-bootstrap-example "Direct link to A complete bootstrap example")

A small AWS deployment using DynamoDB for state, two `audit-*` sinks (DynamoDB primary plus local file backup), and S3 for recordings:

[`production.yaml`](https://almaforge.com/examples/storage/overview/production.yaml):

examples/storage/overview/production.yaml

```yaml
# Shared state, audit fan-out, and S3 recordings for a production cluster.

apiVersion: almaforge.com/v1

kind: StorageConfig

metadata:

  name: state

spec:

  dynamo:

    region: us-east-1

    tableName: cluster-state

    billingMode: PAY_PER_REQUEST

    continuousBackups: true

---

apiVersion: almaforge.com/v1

kind: StorageConfig

metadata:

  name: audit-primary

spec:

  dynamo:

    region: us-east-1

    tableName: cluster-audit

---

apiVersion: almaforge.com/v1

kind: StorageConfig

metadata:

  name: audit-local

spec:

  file:

    path: /var/log/almaforge/audit.jsonl

---

apiVersion: almaforge.com/v1

kind: StorageConfig

metadata:

  name: recordings

spec:

  s3:

    bucket: almaforge-recordings

    region: us-east-1

    path: records
```

Place this in the Auth Service bootstrap file on every Auth host (the file must be byte-identical across hosts), then start the Auth Service. After startup, verify with `alma get storageconfig`.

## URI format[​](#uri-format "Direct link to URI format")

Every driver documented below can also be expressed as a single URI string. The same URI grammar drives every env-var and CLI-flag bootstrap. The URI scheme picks the driver, and the host and path carry the primary value, such as a table name, bucket, file path, or `database.table` for Athena. Per-driver knobs travel either in the URI query string or, for PostgreSQL retention knobs and Azure container names, in the URI fragment after `#`. Each backend page below shows where its knobs live.

Canonical query keys use snake\_case. The camelCase form used in [`StorageConfig`](https://almaforge.com/reference/configuration.md#storageconfig) resources is accepted as an alias. Durations use values such as `500ms`, `10s`, or `72h`. An invalid query value stops configuration loading and reports the field instead of using a default.

A few representative examples:

text

```text
sqlite:///var/lib/almaforge/backend

postgres://alma:secret@db.example.com/almaforge?sslmode=verify-full#retention_period=72h

dynamodb://cluster-events?region=us-east-1&audit_retention_period=720h

dir:///var/lib/almaforge/audit

s3://almaforge-recordings/sessions?region=us-east-1&sse_kms_key=arn:aws:kms:::key/abc
```

The full grammar for each scheme, including every query knob, every alias, and the host/path/fragment shape, lives on the corresponding backend page below. Two schemes have no page of their own: `athena://<database>.<table>` is parsed but not yet documented, and `stdout://` takes nothing after the scheme and selects the sink described under [Standard output](#standard-output).

## Next steps[​](#next-steps "Direct link to Next steps")

* [High availability](https://almaforge.com/high-availability.md). How the storage backends fit into a production topology.
* [Break-glass access](https://almaforge.com/break-glass.md). What to do when the state backend is down.
