Skip to main content

Bucket claim lifecycle

Lifecycle rules are standing orders that automatically delete data — for example old objects under a prefix, superseded versions, or unfinished uploads. You set them on the bucket claim in a namespace — from the console or with kubectl.

warning

Every rule here deletes data. Deletion is asynchronous, runs on a background schedule, and also applies to objects uploaded later. Claim status does not report what a rule removed.

tip

If you leave lifecycle unset, objects stay until you (or the claim deletion policy) delete them.

Set from the console​

Lifecycle tab in the console

  1. Open your workspace, then open a namespace.
  2. In the namespace nav, under Object Storage, open Bucket claims.
  3. Open the claim.
  4. Select the Lifecycle tab.
  5. Click Add rule and fill in:
    • rule name — unique name for the rule (required)
    • Armed / Disabled — the rule runs only when Armed
    • Expire objects after (days) — delete objects N days after creation
    • Abort unfinished uploads after (days) (optional) — abort incomplete multipart uploads
    • Expire delete markers… or Expire superseded versions if needed (usually on a versioned bucket)
    • Filter (optional) — for example prefix logs/ or a size limit
  6. Click Save lifecycle.

Remove lifecycle​

Delete every rule, then click Save lifecycle again to remove the configuration from the bucket.

Set with kubectl​

Set spec.lifecyclePolicy on the same S3BucketClaim:

zsh
❯ kubectl -n <namespace> apply -f - <<EOF
❯ apiVersion: oss.tapsicloud.com/v1alpha1
❯ kind: S3BucketClaim
❯ metadata:
❯ name: app-data
❯ spec:
❯ lifecyclePolicy:
❯ - name: expire-logs
❯ enabled: true
❯ filter:
❯ prefix: logs/
❯ expireAfterDays: 30
❯ abortIncompleteMultipartUploadAfterDays: 7
❯ EOF

Replace <namespace> with your namespace. Assumes your workspace kubeconfig and context are already configured.

Multiple rules (versions and a disabled rule)​

!manifest.yaml×
tapsicloud › manifest.yaml
1apiVersion: oss.tapsicloud.com/v1alpha1
2kind: S3BucketClaim
3metadata:
4 name: app-data
5spec:
6 lifecyclePolicy:
7 - name: expire-logs
8 enabled: true
9 filter:
10 prefix: logs/
11 tags:
12 - key: class
13 value: transient
14 objectSizeGreaterThan: 1Ki
15 expireAfterDays: 30
16 abortIncompleteMultipartUploadAfterDays: 7
17 - name: trim-versions
18 enabled: true
19 noncurrentVersions:
20 expireAfterDays: 14
21 keepNewest: 3
22 - name: parked
23 enabled: false
24 filter:
25 prefix: tmp/
26 expireAfterDays: 1
✓ dry-runLn 26 · YAML

Rule fields​

FieldIn plain terms
nameUnique rule id
enabledtrue = armed; false = stored but inactive
filter (optional)Scope; omit = every object
filter.prefixKey prefix
filter.tagsTags that must match
filter.objectSizeGreaterThan / objectSizeLessThanSize bounds (for example 1Ki, 128Mi)
expireAfterDaysDelete objects N days after creation
expireDeleteMarkersRemove orphan delete markers (not with expireAfterDays)
noncurrentVersionsExpire old versions on a versioned bucket
abortIncompleteMultipartUploadAfterDaysAbort unfinished multipart uploads
warning

expireAfterDays and expireDeleteMarkers cannot be set on the same rule. Noncurrent or delete-marker rules on an unversioned bucket are accepted but do not run.

tip

On a versioned bucket, expireAfterDays usually expires the current version by adding a delete marker. Use noncurrentVersions to remove older versions.

Clear lifecycle​

zsh
❯ kubectl -n <namespace> patch s3bucketclaim app-data --type=merge -p '{"spec":{"lifecyclePolicy":null}}'