Skip to content

Commit 3a46360

Browse files
authored
feat(bucket): add a ui flag to skip the s3manager web UI (#4881)
<!-- Thank you for making a contribution! Here are some tips for you: - Use Conventional Commits for the PR title: `type(scope): description` - Types: feat, fix, docs, style, refactor, perf, test, build, ci, chore - Scopes are not an exhaustive list — pick the most specific scope for the change and extend the list when a genuinely new area appears. Examples: - System components: dashboard, platform, operator, cilium, kube-ovn, linstor, fluxcd, cluster-api - Managed apps: postgres, mariadb, redis, kafka, clickhouse, virtual-machine, kubernetes - Development and maintenance: api, hack, tests, ci, docs, maintenance - Breaking changes: append `!` after type/scope (`feat(api)!: ...`) or add a `BREAKING CHANGE:` footer - If it's a work in progress, consider creating this PR as a draft. - Don't hesistate to ask for opinion and review in the community chats, even if it's still a draft. - Add the label `kind/backport` if it's a bugfix that needs to be backported to a previous version. --> ## What this PR does Adds a `ui` flag to the Bucket application. Every bucket currently ships an s3manager Deployment, 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. - `packages/apps/bucket`: new `ui` value (default `true`), passed through to the `bucket-system` HelmRelease. The dashboard Role drops its Ingress rule when the UI is off, since an empty `resourceNames` would widen it to every Ingress in the namespace. - `packages/system/bucket`: the Deployment, Service, Ingress and HTTPRoute render only when `ui` is true. With the UI off, the chart no longer requires the tenant apex, as the UI hostname was its only consumer there. - Regenerated `values.schema.json`, `README.md`, `types.go` and the `bucket-rd` ApplicationDefinition. The default keeps existing buckets unchanged. Setting `ui: false` on an existing bucket makes Helm delete the UI objects on the next upgrade; the cert-manager Certificate for the UI host is owned by the Ingress through ingress-shim and goes with it. Tested with `helm unittest` on both charts: new suites cover the default render, `ui: false` behind an Ingress and behind a Gateway, the empty-apex case, the value passthrough and the dashboard Role. The system-chart suite fails against the previous templates. ### Screenshots Not applicable: no dashboard change, only a new field in the Bucket form generated from the schema. ### Downstream repositories <!-- Cozystack is upstream for repositories that are NOT kept in sync with it automatically, and nothing in CI compares the two sides, so a change here can break them silently. Which change forces what, and which file to touch, is the trigger map in docs/agents/contributing.md under "Downstream Repositories". Walk it before you tick anything. IF YOU ARE AN AI AGENT OR AN LLM, THIS IS PART OF THE TASK, NOT A FORM TO FILL IN: 1. Walk the trigger map against the actual diff of this PR, file by file. Do not decide from the PR title or from your memory of what you changed. 2. For every repository you tick, open the follow-up PR there and link it on the same line. A ticked box with no link claims work that does not exist, which is worse than an empty box. Search that repository for an open PR or issue covering it first, and link that instead of filing a duplicate. 3. When the follow-up is out of scope, or needs a decision that is not yours to make, open an issue in that repository instead, link that, and say so in the PR body. Do not push a speculative PR into another repository just to fill a line here. 4. Do not tick "No downstream repository is affected" to make the checklist go away. If you are unsure, leave every box empty and say so in the PR body, so a human decides. --> Walked the trigger map against the diff. A new field in `packages/apps/bucket/values.schema.json` reaches the Terraform provider (schema, model, expand/flatten) and the website (the Bucket page is hand-written). Both follow-ups are issues rather than PRs, since they apply only once this PR is merged. - [ ] No downstream repository is affected by this change - [x] [cozystack/website](https://github.com/cozystack/website) - follow-up: cozystack/website#750 - [x] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: cozystack/terraform-provider-cozystack#71 - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [ ] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: - [ ] [cozystack/community](https://github.com/cozystack/community) - follow-up: ### Release note <!-- Write a release note: - Explain what has changed internally and for users. - Start with the same `type(scope):` prefix as in the PR title - Follow the guidelines at https://github.com/kubernetes/community/blob/master/contributors/guide/release-notes.md. --> ```release-note feat(bucket): add a `ui` flag to the Bucket application. Set it to `false` to skip the s3manager web UI and its Service, Ingress or HTTPRoute, DNS name and TLS certificate. Defaults to `true`, so existing buckets are unchanged. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added a `ui` option for bucket deployments. It is enabled by default and provides the S3 manager web UI at the tenant host. * Set `ui` to `false` to run a bucket without its web UI or the associated Service and Ingress or HTTPRoute. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2 parents cfa9c5a + 0c62bee commit 3a46360

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)