Repository navigation
feat(templates): store templates in s3 - #44
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.