Skip to content

feat(templates): store templates in s3 - #44

Merged
TheMeinerLP merged 4 commits into
mainfrom
feat/v2-s3-templates
Nov 25, 2026
Merged

TheMeinerLP merged 4 commits into
mainfrom
feat/v2-s3-templates

Conversation

@TheMeinerLP

Copy link
Copy Markdown
Contributor

Until now the controller kept every template in a directory on its data volume. That works for one controller, but the templates cannot be shared with other tooling and they live and die with the volume. Operators asked for the templates to sit in the object storage the cluster already provides.

With this change the controller can keep its templates in an S3 bucket. The bucket gets the same content-addressed layout the directory store used, so a template version still has the same digest and the same contents, whichever backend holds it. Uploads skip blobs the bucket already has, so a template shared by two versions is stored once. The directory store stays the default, and existing installs see no change.

In the chart, switching to S3 is one value. The credentials and the bucket name come from the bucket claim that the cluster creates for the controller, so no secret is typed into values. Seed templates still come from the ConfigMap and go into the bucket on start.

Tested with a unit suite that runs the same behaviour cases against both backends, using an in-memory stand-in for the bucket, so no network is needed. Config validation and the chart renders were checked as well. Not tested yet against a real bucket in the cluster; that is the next step once the bucket claim exists.

The fs store now implements the template layout on a small objectClient
interface. Blob, manifest and tag handling moves into layout.go without
a change in behaviour, so another backend can reuse it.

Imported files are spooled to a temp file while hashed, then uploaded
only when the blob is not stored yet.
Templates can live in an S3 bucket with the same layout as the file
store, optionally under a key prefix. One behaviour suite runs against
both backends; the S3 tests use an in-memory object store and make no
network calls.

An endpoint is host:port or an http(s) URL. Blobs that already exist in
the bucket are not uploaded again.
GRUS_TEMPLATES_BACKEND chooses fs (default) or s3. The S3 settings are
GRUS_S3_ENDPOINT, GRUS_S3_BUCKET, GRUS_S3_PREFIX and GRUS_S3_INSECURE;
the credentials come from AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
and are never logged or echoed in errors.
templates.backend selects fs (default, rendered unchanged) or s3. For
s3 the controller reads the credentials from an existing Secret and
the bucket name and host from an existing ConfigMap, as created by a
Rook ObjectBucketClaim. Endpoint, bucket and prefix can be set
explicitly instead.
@TheMeinerLP
TheMeinerLP merged commit 320c05a into main Nov 25, 2026
5 checks passed
@TheMeinerLP
TheMeinerLP deleted the feat/v2-s3-templates branch November 25, 2026 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant