Skip to content
AggregaAggrega
Select language: English

Memcached — one Aggregate, two targets, and a password that is refused

This lean example compiles a single Memcached in-memory cache from one Developer-authored Aggregate to two realizations:

  • Docker Compose for local development, and
  • the synthesized helm Recipe running the official upstream memcached image directly on Kubernetes (no external chart).

The synthesized helm Recipe is the preferred Kubernetes path: it depends only on an official image tag rather than a third-party chart, and its rendered resource set is exactly what the workload declares.

The same aggregate.yaml drives both. Only the Recipe layer selected by the Manifest changes per realization. Two further Aggregates attach a password to the cache, and their Releases are negative examples: the build halts, because no realization can enforce a Memcached password.

Files

FileRole
aggregate.yamlDeveloper intent: one cache component of type core/datastore/memcached, no credential — the cache runs without authentication.
aggregate-auth.yamlThe same cache with an inject-value password credential attached to the component’s optional password slot (Compose path). Its build halts.
aggregate-helm-synth-auth.yamlThe same cache with a referenceable password credential attached for the synthesized helm path. Its build halts.
manifest-compose.yamlMaps the Memcached type to the Compose Recipe (compose/memcached) and the credential to dotenv-secret.
manifest-helm-synth.yamlMaps the Memcached type to the synthesized helm Recipe (helm/memcached) and the credential to k8s-secret-from-parameter.
release-compose.yaml / release-helm-synth.yamlOperator records for the two realizations.
release-negative-compose-auth.yaml / release-negative-helm-synth-auth.yamlOperator records over the two password Aggregates. Each build is expected to fail.

What it demonstrates

  • One authoring surface, many targets. A single Aggregate is the source of truth for what the stack is. Each Manifest says how to realize it.
  • A stateless datastore. Memcached holds entries in memory and stores nothing durably, so the component is typed as a plain server rather than a stateful-server. On Kubernetes the Recipe renders a Deployment, not a StatefulSet, and requests no persistent volume; on Compose the service declares no data volume.
  • Workload synthesis (Kubernetes). The synthesized helm Recipe declares a Workload — a Deployment plus a ClusterIP Service running the official memcached image — that the helm provider translates into Kubernetes manifests with no external chart. The rendered resource set is exactly what the Workload declares. Because both a Compose and a synthesized helm Recipe carry the name memcached, the Manifests reference them provider-scoped as compose/memcached and helm/memcached.
  • A protection a realization cannot give is refused, not dropped. The component declares an optional password slot. The memcached image enforces no password: its two authentication modes are SASL, spoken over the binary protocol only, and an ASCII authentication file, and the catalog’s Memcached clients use neither. A Recipe that accepted the attachment would render a cache that answers every client while the Aggregate says it is protected, so each Recipe halts the build instead, naming the slot.

Scaffold the example

You can build this example with the commands below, or have your AI assistant build it for you.

Write the example into a new folder named after it:

Terminal window
aggrega scaffold --example memcached-cache

It then prints the commands to run next. The first changes into the new folder:

Terminal window
cd memcached-cache

Build

This workspace carries no .aggrega-config.yaml, so the standard-library entities resolve from the hub registry, hub.aggrega.ai, and no catalog flag is needed; --auto-pull writes the lockfile a fresh clone lacks during the build:

Terminal window
# Local development (Docker Compose)
aggrega build --release release-compose.yaml --auto-pull
# Kubernetes (synthesized helm Recipe, official image)
aggrega build --release release-helm-synth.yaml --auto-pull

Rendered artifacts land under dist/.

With an AI assistant

An AI assistant set up with Aggrega’s tools can do the same: paste this prompt into it.

Use the Aggrega tools only, and create no folder yourself. If the Workspace folder holds no `memcached-cache` folder yet, call the `scaffold` tool once with `example` set to `memcached-cache` and no `dir`: it writes the example into a new `memcached-cache` folder. Then call the `build` tool once for each Release, in this order — `release-compose.yaml` and `release-helm-synth.yaml` — each time with `workspace_root` set to `memcached-cache`, `release` set to that file, `auto_pull` set to true and `write` set to true. Tell me which files each build wrote; they are under `memcached-cache/dist/`.

The control: a password the cache cannot enforce

The two negative Releases build the password Aggregates, and each build is expected to fail:

Terminal window
aggrega build --release release-negative-compose-auth.yaml --auto-pull
aggrega build --release release-negative-helm-synth-auth.yaml --auto-pull

Each halts in the Memcached Recipe, before anything is written, and the halt ends with the Recipe’s own message:

a password is attached to the password slot of "cache", but the memcached
image this Recipe runs cannot enforce a password: it authenticates only through
SASL over the binary protocol or an ASCII authentication file, which the
catalog's Memcached clients do not use, so the cache would accept every client
anyway; remove the attachment, and restrict who can reach the cache through its
network

The refusal is keyed on the attachment itself, not on how the credential is delivered, so every Feature that can fill the slot halts the same way. The managed realizations behave alike: Amazon ElastiCache offers no Memcached authentication, and its Recipes halt on the attachment too. A Memcached cache is therefore protected by who can reach it — the network it is placed on — and the base aggregate.yaml is the form to build.