Skip to content

Commit 0c62bee

Browse files
feat(bucket): add a ui flag to skip the s3manager web UI
Every bucket ships an s3manager Deployment with its Service and an Ingress or HTTPRoute on <bucket>.<tenant host>. Tenants that only use the S3 API pay for a pod per bucket and for one DNS name and TLS certificate per bucket, none of which they need. ui defaults to true, so existing buckets keep their UI. With ui set to false the bucket no longer needs the tenant apex either, since the UI hostname was its only consumer in the bucket-system chart. Assisted-by: LLM Signed-off-by: Mattia Eleuteri <[email protected]>
1 parent 7c46fff commit 0c62bee

14 files changed

Lines changed: 149 additions & 8 deletions

File tree

‎api/apps/v1alpha1/bucket/types.go‎

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎packages/apps/bucket/README.md‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44

55
### Parameters
66

7-
| Name | Description | Type | Value |
8-
| ---------------------- | -------------------------------------------------------------------------- | ------------------- | ------- |
9-
| `locking` | Provisions bucket from the `-lock` BucketClass (with object lock enabled). | `bool` | `false` |
10-
| `storagePool` | Selects a specific BucketClass by storage pool name. | `string` | `""` |
11-
| `users` | Users configuration map. | `map[string]object` | `{}` |
12-
| `users[name].readonly` | Whether the user has read-only access. | `bool` | `false` |
7+
| Name | Description | Type | Value |
8+
| ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------- | ------- |
9+
| `locking` | Provisions bucket from the `-lock` BucketClass (with object lock enabled). | `bool` | `false` |
10+
| `storagePool` | Selects a specific BucketClass by storage pool name. | `string` | `""` |
11+
| `ui` | Deploys the web UI (s3manager) with its Service and its Ingress or HTTPRoute at `<bucket>.<tenant host>`. Set to `false` to run the bucket without them. | `bool` | `true` |
12+
| `users` | Users configuration map. | `map[string]object` | `{}` |
13+
| `users[name].readonly` | Whether the user has read-only access. | `bool` | `false` |
1314

‎packages/apps/bucket/templates/dashboard-resourcemap.yaml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ rules:
1212
- {{ $.Release.Name }}-{{ $name }}-credentials
1313
{{- end }}
1414
verbs: ["get", "list", "watch"]
15+
{{- if .Values.ui }}
1516
- apiGroups:
1617
- networking.k8s.io
1718
resources:
1819
- ingresses
1920
resourceNames:
2021
- {{ .Release.Name }}-ui
2122
verbs: ["get", "list", "watch"]
23+
{{- end }}
2224
---
2325
kind: RoleBinding
2426
apiVersion: rbac.authorization.k8s.io/v1

‎packages/apps/bucket/templates/helmrelease.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ spec:
2323
values:
2424
bucketName: {{ .Release.Name }}
2525
users: {{ .Values.users | toJson }}
26+
ui: {{ .Values.ui }}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
suite: bucket ui flag
2+
templates:
3+
- templates/helmrelease.yaml
4+
- templates/dashboard-resourcemap.yaml
5+
6+
release:
7+
name: bucket-my-bucket
8+
namespace: tenant-root
9+
10+
tests:
11+
- it: passes ui through to the bucket-system release, enabled by default
12+
template: templates/helmrelease.yaml
13+
asserts:
14+
- equal:
15+
path: spec.values.ui
16+
value: true
17+
18+
- it: passes ui=false through to the bucket-system release
19+
template: templates/helmrelease.yaml
20+
set:
21+
ui: false
22+
asserts:
23+
- equal:
24+
path: spec.values.ui
25+
value: false
26+
27+
- it: grants dashboard read access to the UI Ingress by default
28+
template: templates/dashboard-resourcemap.yaml
29+
documentIndex: 0
30+
asserts:
31+
- contains:
32+
path: rules
33+
content:
34+
apiGroups: ["networking.k8s.io"]
35+
resources: ["ingresses"]
36+
resourceNames: ["bucket-my-bucket-ui"]
37+
verbs: ["get", "list", "watch"]
38+
39+
- it: drops the Ingress rule when ui is false
40+
template: templates/dashboard-resourcemap.yaml
41+
documentIndex: 0
42+
set:
43+
ui: false
44+
asserts:
45+
- lengthEqual:
46+
path: rules
47+
count: 1
48+
- notContains:
49+
path: rules[0].resources
50+
content: ingresses

‎packages/apps/bucket/values.schema.json‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
"source": "storagepool"
1616
}
1717
},
18+
"ui": {
19+
"description": "Deploys the web UI (s3manager) with its Service and its Ingress or HTTPRoute at `\u003cbucket\u003e.\u003ctenant host\u003e`. Set to `false` to run the bucket without them.",
20+
"type": "boolean",
21+
"default": true
22+
},
1823
"users": {
1924
"description": "Users configuration map.",
2025
"type": "object",

‎packages/apps/bucket/values.yaml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ locking: false
55
## @x-cozystack-options {source: storagepool}
66
storagePool: ""
77

8+
## @param {bool} ui=true - Deploys the web UI (s3manager) with its Service and its Ingress or HTTPRoute at `<bucket>.<tenant host>`. Set to `false` to run the bucket without them.
9+
ui: true
10+
811
## @typedef {struct} User - Bucket user configuration.
912
## @field {bool} [readonly] - Whether the user has read-only access.
1013

‎packages/system/bucket-rd/cozyrds/bucket.yaml‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎packages/system/bucket/templates/deployment.yaml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.ui }}
12
{{- $host := include "cozy-lib.ns-host-required" . }}
23
{{- $endpoint := printf "s3.%s" $host }}
34
{{- range $name, $user := .Values.users }}
@@ -37,3 +38,4 @@ spec:
3738
requests:
3839
cpu: 100m
3940
memory: 128Mi
41+
{{- end }}

‎packages/system/bucket/templates/httproute.yaml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.ui }}
12
{{- $host := include "cozy-lib.ns-host-required" . }}
23
{{- $gateway := .Values._namespace.gateway | default "" }}
34
{{- if $gateway }}
@@ -18,3 +19,4 @@ spec:
1819
- name: {{ .Values.bucketName }}-ui
1920
port: 8080
2021
{{- end }}
22+
{{- end }}

0 commit comments

Comments
 (0)