From 732165eebde83eec63602fcc12f7c4302ac28bc3 Mon Sep 17 00:00:00 2001 From: Ray Low Date: Mon, 23 Nov 2026 14:20:11 +0800 Subject: [PATCH] fix(harbor): meter the registry bucket under the registry WorkloadMonitor The WorkloadMonitor controller finds BucketClaims by the monitor's label selector. The registry BucketClaim carried no labels, so it never got a Workload and Harbor's object storage was invisible to billing. Before the registry moved to S3 its PVC carried the vendored chart's release and component labels and was reported under the registry monitor; labelling the BucketClaim the same way restores that. Assisted-by: LLM Signed-off-by: Ray Low --- packages/apps/harbor/templates/bucket.yaml | 3 ++ .../tests/registry_bucket_monitor_test.yaml | 46 +++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 packages/apps/harbor/tests/registry_bucket_monitor_test.yaml diff --git a/packages/apps/harbor/templates/bucket.yaml b/packages/apps/harbor/templates/bucket.yaml index a9e60988d..5394ad229 100644 --- a/packages/apps/harbor/templates/bucket.yaml +++ b/packages/apps/harbor/templates/bucket.yaml @@ -3,6 +3,9 @@ apiVersion: objectstorage.k8s.io/v1alpha1 kind: BucketClaim metadata: name: {{ .Release.Name }}-registry + labels: + release: {{ .Release.Name }}-system + component: registry spec: bucketClassName: {{ $seaweedfs }} protocols: diff --git a/packages/apps/harbor/tests/registry_bucket_monitor_test.yaml b/packages/apps/harbor/tests/registry_bucket_monitor_test.yaml new file mode 100644 index 000000000..6327a8bc9 --- /dev/null +++ b/packages/apps/harbor/tests/registry_bucket_monitor_test.yaml @@ -0,0 +1,46 @@ +suite: registry BucketClaim is selected by the registry WorkloadMonitor + +release: + name: harbor + namespace: tenant-test + +# The WorkloadMonitor controller lists BucketClaims by the monitor's selector, +# so a BucketClaim without matching labels gets no Workload and its storage +# never reaches billing. The registry keeps its images in this bucket, so it is +# reported under the registry monitor, as the registry PVC was before storage +# moved to S3. Both sides are asserted so that renaming either one fails here. +set: + _namespace: + host: example.org + ingress: nginx + gateway: "" + seaweedfs: seaweedfs + _cluster: + solver: http01 + +tests: + - it: labels the registry BucketClaim with the registry monitor's selector + template: templates/bucket.yaml + documentSelector: + path: kind + value: BucketClaim + asserts: + - equal: + path: metadata.labels + value: + release: harbor-system + component: registry + + - it: selects the registry BucketClaim from the registry monitor + template: templates/harbor.yaml + documentSelector: + path: metadata.name + value: harbor-registry + asserts: + - isKind: + of: WorkloadMonitor + - equal: + path: spec.selector + value: + release: harbor-system + component: registry