Skip to content

feat(k8s): apply store buckets, keys and rules from git #4756

Closed

Description

@dan-petty

Problem or Motivation

The buckets, keys, quotas, anonymous read and lifecycle rules of the store must be in git, or they drift. The SeaweedFS operator has CRs for this: Bucket, BucketLifecyclePolicy, S3Identity, S3Credentials, S3Policy, S3PolicyBinding and ResourceReferenceGrant (api/v1 at operator 1.0.43). Thus the store needs no custom reconcile Job.

Proposed Solution & Architectural Design

CRs in k8s/object-store/. The Argo CD Application object-store applies them with SkipDryRunOnMissingResource=true.

  • 9 Buckets with spec.quota and reclaimPolicy: Retain: reports 20 GiB, reports-private 20 GiB, cache 10 GiB, argo-artifacts 10 GiB, backups-gitea 30 GiB, backups-llm 60 GiB, backups-mattermost 40 GiB, backups-devops 5 GiB, backups-monitoring 10 GiB. local-path does not enforce the claim size, so the quotas are the real limits.
  • anonymousRead (Read, no List) only on reports and reports-private. The backup buckets never get anonymous access.
  • BucketLifecyclePolicy:
  • S3Identity for each writer: devops, argo, backup-gitea, backup-llm, backup-mattermost, backup-devops and backup-monitoring. Also a reserved read-only identity cloud-backup (Read and List on reports, reports-private and backups-*) for the later cloud copy. It gets no key until that item.
  • S3Credentials with secretRef to the Secret in each writer namespace, and a ResourceReferenceGrant there. ClusterSecret rows with SecretGenerator values for each key pair (no fixed key ID form). The keyring stays the source.
  • S3Policy and S3PolicyBinding: each key works only on its own bucket.
  • No reconcile script, PostSync Job, CronJob or Python image.
  • Fallback, only if a CR fails the build test: the upstream chart at the image version and a weed shell Job (s3.bucket.create, s3.bucket.quota, s3.anonymous.set, s3.configure) plus one PutBucketLifecycleConfiguration call, about 60 lines.

Target Subsystem

Kubernetes & Minikube Automation (k8s/object-store/).

Existing Tool Considered

The SeaweedFS operator CRs (Apache-2.0). They replace a custom reconcile script: about 50k tokens and 1 hour of YAML, instead of about 250k tokens and 2 hours for a script.

Acceptance Criteria

  • After the sync, 9 buckets exist with the quotas in git.
  • An anonymous GET of a test object in reports returns 200. An anonymous List of reports returns AccessDenied. An anonymous GET in cache or backups-gitea returns AccessDenied.
  • A key of namespace llm gets AccessDenied on backups-gitea.
  • A second sync makes 0 changes. A quota that a person changes by hand goes back to the git value.
  • Lifecycle expiry check, on a branch revision: a rule with an Expiration date in the past on prefix lifecycle-test/ of cache removes a test object at the next S3 lifecycle pass. An incomplete multipart upload older than 1 day goes away.
  • Unit tests: no backups-* bucket has an Expiration rule, and only reports and reports-private have anonymousRead.
  • A person ran uv run devops k8s push-secrets before the merge.

Dependencies

Source: #4742

Alternatives check of 2026-11-14: in-use.
The item already names this tool.
Tool: seaweedfs/seaweedfs-operator (https://github.com/seaweedfs/seaweedfs-operator), Apache-2.0, last activity 2026-11-10, maintained.

Coordinator decision of 2026-11-22 (least privilege, decide-and-report): the four platform Buckets of this item (reports, reports-private, cache, argo-artifacts) and their lifecycle policies live in namespace object-store, and the operator watches only object-store. Reason: SeaweedFS operator 1.0.45 sees a Bucket only in a namespace it watches, and the chart gives each watched namespace its manager Role, which can write Secrets. Watching devops and argo-workflows would let the operator read and change every Secret there (the GitHub App keys of the roadmap Service among them). This replaces the refined criterion that puts these Buckets in the writer namespaces. The tenant Buckets of service repositories still come from the tenant chart of dan-petty/infra, in the namespace of each tenant.

Proposed design

Problem statement

The store's buckets, quotas, anonymous read and lifecycle rules live outside git and drift. This change declares the four buckets of the devops and argo-workflows workloads (reports, reports-private, cache and argo-artifacts) as SeaweedFS operator custom resources under k8s/object-store/, with their quotas, Retain policy, anonymous read and lifecycle rules, and adds the object-store Argo CD Application and the homelab project destinations. The tenant backup buckets, the writer identities and keys, and the read-only cloud-backup identity come from the tenant chart of dan-petty/infra#14 and are a separate issue.

Acceptance criteria

Requirement: Object-store manifests validate

The manifests under k8s/object-store/ and the object-store Argo CD Application SHALL pass the repository's Kubernetes validator.

Scenario: Kubernetes validator

  • WHEN uv run devops ci --check --only k8s runs on the branch.
  • THEN The command exits 0 and the k8s row reports no error.

Requirement: Store bucket quotas in git

The repository SHALL declare four SeaweedFS Bucket resources for reports, reports-private, cache and argo-artifacts with the quotas in git and reclaimPolicy: Retain on each.

Scenario: Buckets on the cluster

  • WHEN The live check runs kubectl get buckets.seaweed.seaweedfs.com -A -o yaml.
  • THEN The output has a Bucket for reports 20Gi, reports-private 20Gi and cache 10Gi in namespace devops and a Bucket for argo-artifacts 10Gi in namespace argo-workflows, each with reclaimPolicy: Retain and a clusterRef that names the store cluster that feat(k8s): run a three-node SeaweedFS object store #4750 deploys.

Requirement: Anonymous read only on reports

The store MUST allow anonymous GET, without anonymous List, only on reports and reports-private, and MUST refuse anonymous GET on cache.

Scenario: Anonymous GET and List

  • WHEN The live check puts a test object in reports, reports-private and cache, and sends an anonymous GET and an anonymous List to the store endpoint.
  • THEN reports and reports-private return 200 for GET and AccessDenied for List, and cache returns AccessDenied for GET.

Requirement: Lifecycle rules in git

The repository SHALL declare BucketLifecyclePolicy resources with the expiration and abort-incomplete-multipart rules in git.

Scenario: Lifecycle rules on the cluster

  • WHEN The live check runs kubectl get bucketlifecyclepolicies.seaweed.seaweedfs.com -A -o yaml.
  • THEN The output shows reports-private with prefix studies/ and a 90-day expiration, cache and argo-artifacts with a 7-day expiration, and each of the four buckets with an abort-incomplete-multipart rule of 1 day.

Requirement: Lifecycle expiry

A lifecycle rule with an Expiration date in the past MUST remove a test object at the next S3 lifecycle pass, and an incomplete multipart upload older than 1 day MUST go away.

Scenario: Expiry on a branch revision

  • WHEN The live check runs on a branch revision with a test rule with an Expiration date in the past on prefix lifecycle-test/ of cache, puts a test object there, and waits for the next lifecycle pass.
  • THEN The test object is gone, and the incomplete multipart upload older than 1 day is gone.

Requirement: Argo CD Application

The object-store Argo CD Application SHALL set automated sync with prune and self-heal, a retry limit of 5, and SkipDryRunOnMissingResource=true.

Scenario: Application sync policy

  • WHEN The live check runs kubectl get application object-store -n argocd -o jsonpath='{.spec.syncPolicy}'.
  • THEN The output shows automated.enabled, automated.prune and automated.selfHeal true, retry.limit 5, and SkipDryRunOnMissingResource=true in the sync options.

Requirement: Project destinations

The homelab AppProject SHALL list the namespaces of the store CRs, devops and argo-workflows, in spec.destinations.

Scenario: Project destinations

  • WHEN The live check runs kubectl get appproject homelab -n argocd -o jsonpath='{.spec.destinations[*].namespace}'.
  • THEN The output includes devops and argo-workflows.

Requirement: No custom reconcile code

The change SHALL add no reconcile script, PostSync Job, CronJob or Python image to k8s/object-store/.

Scenario: Store namespace workloads

  • WHEN The live check runs kubectl get jobs,cronjobs -n object-store and kubectl get pods -n object-store -o jsonpath='{.items[].spec.containers[].image}'.
  • THEN The first command reports no resources, and the second lists only the SeaweedFS images that feat(k8s): run a three-node SeaweedFS object store #4750 deploys, with no Python reconcile image.

Requirement: No key rows in the ClusterSecret table

The change SHALL add no ClusterSecret row for a store key; the key pair comes from an ESO Password generator.

Scenario: ClusterSecret table

  • WHEN A unit test reads CLUSTER_SECRETS in src/devops_cli/k8s/cluster_secrets.py.
  • THEN No ClusterSecret in the table has a name that starts with object-store-.

Existing Tool Considered

The alternatives check of 2026-11-14 records the verdict in-use for seaweedfs/seaweedfs-operator (https://github.com/seaweedfs/seaweedfs-operator, Apache-2.0, maintained), and the item already names that tool; the block is the check's record. The check's comment states the one lack: it did not confirm that the pinned version exposes every field the issue lists, such as per-bucket anonymous read with Read but not List. The Bucket CRD read on 2026-11-21 shows scope Namespaced, spec.quota.size, spec.reclaimPolicy with the values Retain and Delete, spec.anonymousRead as a boolean, and spec.access as a list of a user and an action set whose enum holds Read, Write, List, Tagging and Admin, so the design's fields exist at the operator revision of that date (https://github.com/seaweedfs/seaweedfs-operator/blob/master/config/crd/bases/seaweed.seaweedfs.com_buckets.yaml, fetched 2026-11-21), and the live S3 checks of the criteria prove them on the pinned 1.0.43 CRDs. The change builds no reconcile code, so it has no cost to build, keep or fix; it adds YAML and no Python.

Key questions

  • Where do the tenant backup buckets, the writer keys and the cloud-backup identity come from?: From the tenant chart in dan-petty/infra#14, for each namespace with backup.quotaGiB in its services entry: one generic CR form that creates a Bucket, an S3Identity, an S3Credentials, an S3Policy, an S3PolicyBinding and a ResourceReferenceGrant. The key pair comes from an ESO Password generator, not from a push-secrets row. The chart is a shared template, which ADR 0032 puts in dan-petty/infra, and the quota, the namespace and the Secret source are environment values, which it puts in dan-petty/homelab. This item defers that part to a new issue, so it declares no backup bucket, writer key or cloud-backup identity. (best practice) [sources: docs/adr/0032-infrastructure-templates-live-in-four-homes.md:39, docs/adr/0032-infrastructure-templates-live-in-four-homes.md:40, docs/adr/0032-infrastructure-templates-live-in-four-homes.md:44]
    • Chosen: The tenant chart of dan-petty/infra#14. The owner decided it: one generic CR form per namespace with backup.quotaGiB, and the shared template lives in infra while its values live in the environment repository.
    • Rejected: Hand-written CRs for each writer in k8s/object-store/. The owner replaced it; the per-tenant form belongs in the chart that the tenant namespaces already read, and a copy here would drift from it.
    • Rejected: A reconcile script with weed shell. The operator CRs replace it, and it adds code that the project must keep.
  • Who runs uv run devops k8s push-secrets before the merge?: No person runs it for a store key. The owner decided that the key pair comes from an ESO Password generator and not from a push-secrets row, so this change adds no ClusterSecret row and no pod reads a store Secret; the push-secrets rule applies only to a Secret that has a row. The deferred tenant-chart issue adds the rows it needs to the cluster-secrets table of the environment that holds the store, dan-petty/homelab k8s/cluster-secrets.toml (dan-petty/homelab#96). (best practice) [sources: k8s/README.md:736]
    • Chosen: ESO Password generator in the tenant chart. The owner decided it: the chart makes the key pair, so no keyring value and no push-secrets step is needed.
    • Rejected: ClusterSecret rows pushed by devops k8s push-secrets. The owner refused it; the key pair would then live in the workstation keyring.
  • Which AppProject holds the store CRs, and which destinations does it need?: The homelab project, as every leaf Application under k8s/argocd/apps/ uses it. Its destinations already list devops, so the change adds argo-workflows for the argo-artifacts Bucket and its lifecycle policy. No AppProject named services-admin exists in this repository; the owner names services-admin for the tenant chart's CRs, which the deferred issue covers in the repository that holds that chart. (best practice) [sources: k8s/argocd/apps/llm.yaml:11, k8s/argocd/apps/projects.yaml:24, k8s/argocd/apps/projects.yaml:34]
    • Chosen: Use homelab and add the argo-workflows destination. It is the project of every leaf Application here, it already lists devops, and Argo CD refuses a resource whose namespace the project does not list.
    • Rejected: Use services-admin for these CRs. No AppProject named services-admin exists in this repository; the owner names it for the tenant chart's CRs, which the deferred issue carries.
    • Rejected: Rely on the Application destination without listing it. The sync fails the project check.
  • What scope and namespace does each store CR get?: The Bucket and BucketLifecyclePolicy CRDs are Namespaced, so the design writes the namespace of each CR. The reports, reports-private and cache Buckets and their lifecycle policies live in devops, the namespace of the workload that writes them; argo-artifacts and its lifecycle policy live in argo-workflows, not in a bare argo namespace. Each CR names the SeaweedFS cluster that feat(k8s): run a three-node SeaweedFS object store #4750 deploys in object-store through clusterRef.namespace, because the CR sits in another namespace. The CR form keeps the namespace as a value, so the tenant chart can place the same form in each tenant namespace. (best practice) [sources: https://github.com/seaweedfs/seaweedfs-operator/blob/master/config/crd/bases/seaweed.seaweedfs.com_buckets.yaml, k8s/namespaces.yaml:79, k8s/namespaces.yaml:103, docs/adr/0008-argo-workflows-run-the-roadmap-jobs-after-a-measured-go.md:17]
    • Chosen: One namespace per writer workload, written in the design. The owner asked for the scope and the namespace of each CR in the design, the CRDs are namespaced, and the admin project must list them.
    • Rejected: All store CRs in one object-store namespace. A writer key then reaches across namespaces, and the per-namespace grant of the tenant chart cannot scope it.
    • Rejected: Cluster-scoped CRs. The operator's Bucket CRD is Namespaced, so a cluster-scoped object is refused.
  • Does the operator's Bucket CR expose the fields that the design sets?: Yes, in the master CRD read on 2026-11-21: Bucket is Namespaced and has spec.quota.size, spec.reclaimPolicy with the values Retain and Delete, spec.anonymousRead as a boolean, spec.access as a list of a user and an action set whose enum holds Read, Write, List, Tagging and Admin, and exactly one of spec.clusterRef or spec.seaweedRef. The live S3 checks of the criteria prove the same fields on the pinned 1.0.43 CRDs. [sources: https://github.com/seaweedfs/seaweedfs-operator/blob/master/config/crd/bases/seaweed.seaweedfs.com_buckets.yaml]
  • How does Argo CD apply the CRs before the operator CRDs exist?: A raw leaf Application k8s/argocd/apps/object-store.yaml sets SkipDryRunOnMissingResource=true and retry.limit: 5, as the other leaf Applications do. A sync that races the CRDs retries instead of failing for good. (best practice) [sources: k8s/argocd/apps/llm.yaml:24, k8s/argocd/apps/llm.yaml:31, k8s/README.md:1055]
    • Chosen: Skip the dry run and retry 5 times. It is the repository pattern for a kind whose CRD may be absent, and the retry covers the race.
    • Rejected: Pre-install the CRDs by hand. It adds a manual step, and feat(k8s): run a three-node SeaweedFS object store #4750 installs the operator and its CRDs.
    • Rejected: A sync wave before the operator. The CRs cannot apply before their CRDs exist.
  • How does the plan correct manual drift?: Automated sync with prune: true and selfHeal: true, as the other leaf Applications use. A manual quota change returns to the git value. (best practice) [sources: k8s/README.md:1274, k8s/argocd/apps/llm.yaml:20]
    • Chosen: Automated sync with self-heal. A manual quota change returns to the git value with no person step.
    • Rejected: Manual sync only. It leaves drift in place until a person syncs.
    • Rejected: A CronJob that patches quotas. It adds custom reconcile code that the operator replaces.
  • Where does the 90-day lifecycle rule for the version-review HTML go?: To a new issue, because feat(roadmap): publish the project review and link it on GitHub #4733 has not yet fixed the bucket and the prefix that hold the HTML. A rule on a guessed prefix expires nothing or expires other objects, so the new issue adds the rule when feat(roadmap): publish the project review and link it on GitHub #4733 names the prefix. (proposed)
    • Chosen: Defer the rule until feat(roadmap): publish the project review and link it on GitHub #4733 names the prefix. A rule on an unknown prefix is untestable and can expire the wrong objects.
    • Rejected: Guess the prefix and add the rule now. A wrong prefix expires other objects, and a rule on a prefix with no object expires nothing.
    • Rejected: Put the rule on the cache bucket. The version-review HTML is not the cache, and the cache already expires at 7 days.
  • Does this change wait on the environment-tree migration feat(argocd): read the environment from the homelab repo #5134?: It merges in k8s/object-store/ here only before plan step 10 of feat(argocd): read the environment from the homelab repo #5134. From step 12 the freeze refuses a change to an environment path that homelab holds, and the part that misses the window lands in dan-petty/homelab, with its Secret rows in k8s/cluster-secrets.toml (dan-petty/homelab#96). (best practice) [sources: docs/HOMELAB_REPO_SWITCH.md:174, docs/HOMELAB_REPO_SWITCH.md:178, docs/adr/0032-infrastructure-templates-live-in-four-homes.md:71]
    • Chosen: Merge here before plan step 10 of feat(argocd): read the environment from the homelab repo #5134. The owner's answer allows it, and the freeze starts only at step 12.
    • Rejected: Wait and land the whole change in homelab. It keeps the store outside git for the length of the migration, and no homelab Application is added before step 12.

Fit

Fits in one pull request.

Suspected block

The environment-tree migration #5134: its step 12 freeze refuses changes to the environment paths that homelab holds, so a part that misses its plan step 10 lands in dan-petty/homelab (dan-petty/homelab#96).

Dependencies

#4750

Activity

  1. added
    source/agent
    on Nov 11, 2026
  2. added
    type/feature
    scope/k8s
    status/new
    value/high
    effort/medium
    on Nov 11, 2026
  3. dan-petty commented on Nov 11, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/feature. The feat prefix of the title gives the type.
    • Scope: scope/k8s. The (k8s) scope of the title gives the scope.
    • Priority: P2-Medium. It is a prerequisite for backups and reports, but it is not a security fix or a broken production path.
    • Value: High. It gives every service a durable, quota-limited, access-controlled store and removes a custom reconcile script.
    • Effort: Medium. The work is well-scoped YAML for 9 buckets, lifecycle policies, identities, credentials, and bindings, estimated at about 1 hour.
    • Related: feat(k8s): Add scheduled off-node backup and restore for Gitea #2144, which asks for a different change. Both target the Gitea backup path, but the candidate creates the backups-gitea bucket and store rules while 2144 builds the scheduled backup and restore job that writes to it.
  4. added
    priority/p2-medium
    on Nov 11, 2026
  5. devops-cli-service commented on Nov 14, 2026

    @devops-cli-service
    Contributor

    Alternatives check: in-use

    Reason: The searches found the SeaweedFS operator, whose CRDs declaratively cover exactly what the issue needs: buckets with quota and reclaimPolicy, lifecycle policies, S3 identities, credentials, policies and policy bindings, so no custom reconcile Job or script is required. The issue itself already names the SeaweedFS operator CRs as the existing tool considered, so it is in use.

    The item already names this tool.

    Tool: seaweedfs/seaweedfs-operator (https://github.com/seaweedfs/seaweedfs-operator)

    • License: Apache-2.0
    • Last activity: 2026-11-10
    • Maintained: yes

    Covers:

    • Bucket CRs with quota and reclaimPolicy (Retain), so bucket creation and quota limits come from git
    • BucketLifecyclePolicy CRD with per-rule prefix, expiration (days), abortIncompleteMultipartUpload.daysAfterInitiation, noncurrentVersionExpiration and Enabled/Disabled status, and its own reclaimPolicy
    • S3Identity, S3Credentials, S3Policy, S3PolicyBinding and ResourceReferenceGrant for per-writer keys, secretRef-based credentials and per-key bucket scoping
    • Declarative, Argo CD-applied CRs in k8s/object-store/ with no custom reconcile script, PostSync Job or CronJob

    Lacks:

    • Not confirmed from the sources read: whether the pinned operator version exposes every field the issue lists (for example per-bucket anonymousRead with Read-but-not-List); the issue itself keeps a fallback if a CR fails the build test

    Tools considered:

    Searches run:

    • SeaweedFS operator kubernetes bucket quota lifecycle policy declarative, results: 5
    • SeaweedFS operator CRD Bucket BucketLifecyclePolicy S3Identity S3Credentials, results: 5
    • seaweedfs-operator S3PolicyBinding ResourceReferenceGrant CRD api/v1, results: 5
    • seaweedfs-operator Bucket CRD quota reclaimPolicy anonymousRead, results: 5

    Sources:

    Checked on 2026-11-14. A person decides what this means for the item. The check changes no label and closes no issue.

  6. devops-cli-service commented on Nov 15, 2026

    @devops-cli-service
    Contributor

    Owner question: Who runs uv run devops k8s push-secrets before the merge? (a person decides)

    Options

    1. Decide the question: The job refines the item with your answer.
    2. Leave it to the job: The job records the best-practice answer and goes on.

    Recommendation: Decide the question: only a person can answer it.

    Evidence

  7. devops-cli-service commented on Nov 20, 2026

    @devops-cli-service
    Contributor

    Owner question: See the first point of Open questions in the section Proposed design of the body.

    Options

    1. Decide the question: The job refines the item with your answer.
    2. Leave it to the job: The job records the best-practice answer and goes on.

    Recommendation: Decide the question: only a person can answer it.

    Evidence

  8. dan-petty commented on Nov 21, 2026

    @dan-petty
    OwnerAuthor

    Answer: I run uv run devops k8s push-secrets for the seven object-store-<identity> rows from the branch of this item, before the merge. The writer namespaces exist, so the push works before the merge. I merge only when --plan shows every key unchanged. #4750 merges first.

  9. devops-cli-service commented on Nov 21, 2026

    @devops-cli-service
    Contributor

    Owner question: See the first point of Open questions in the section Proposed design of the body.

    Options

    1. Decide the question: The job refines the item with your answer.
    2. Leave it to the job: The job records the best-practice answer and goes on.

    Recommendation: Decide the question: only a person can answer it.

    Evidence

  10. 3 remaining items

  11. added
    status/in-progress
    and removed
    status/new
    on Nov 21, 2026
  12. added
    status/in-review
    and removed
    status/in-progress
    on Nov 22, 2026
  13. removed
    status/in-review
    owner/agent
    on Nov 22, 2026
  14. devops-cli-service commented on Nov 22, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-22 05:04 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p2-mediumscope/k8ssource/agenttype/featurevalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions