mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-21 12:13:55 +09:00
fix(platform): leave tenant-root's ingress empty when the root tenant has none (#5226)
## What this PR does Enabling SeaweedFS on the root tenant without ingress no longer hangs. `cozystack-basics` wrote `_namespace.ingress: tenant-root` for the root tenant whatever its `spec.ingress` said, so `seaweedfs-system` depended on an `ingress-nginx-system` release that nothing creates, and the platform backup bucket waited with it. Every other tenant already derives the key in `packages/apps/tenant/templates/namespace.yaml` and leaves it empty without ingress. `cozystack-basics` cannot read the root Tenant, so the platform now carries its ingress state the same way it carries monitoring: the new platform value `ingress.rootEnabled` reaches the `cozystack-values` Secret as `_cluster.ingress-enabled`, and `_namespace.ingress` is written only when it is true. The default is `true`, which keeps the value every existing cluster renders today, and a Secret written before the key existed keeps it as well. An operator running the root tenant without ingress sets `ingress.rootEnabled: false`, kept in sync with `Tenant/root spec.ingress` by hand, as with `monitoring.rootEnabled`. With the key empty, `seaweedfs-system` drops the dependency through the check it already had (`eq $ingress .Release.Namespace`), and nothing reads live cluster state for it. An empty `_namespace.ingress` now reaches tenant-root and every tenant inheriting from it, so the consumers that would break on it are adjusted in the same PR. The API rejects `ingressClassName: ""` (checked with a server-side dry run), and two consumers quote the value: - `kubernetes`: the proxied ingress-nginx addon Ingress is not rendered without an ingress; its Service still is. - `monitoring`: Grafana's `spec.ingress` is left out, since grafana-operator copies it into the Ingress verbatim. - `seaweedfs`: the S3 Ingress is disabled instead of rendering with no controller to serve it. The `KamajiControlPlane` `network.ingress` block is unchanged on purpose: its `hostname` is what the Kamaji provider uses as the control plane endpoint, and Kamaji itself skips an empty class name. Harbor, bucket, bootbox and alerta write the class unquoted, so an empty value renders as an unset class, which the API accepts. Tests: `packages/core/platform/tests/apps_ingress_enabled_wiring_test.yaml` pins the flag reaching `_cluster` both ways and with `ingress` set to null; `packages/system/cozystack-basics/tests/cozystack-values-secret_test.yaml` pins `_namespace.ingress` for a missing, string, bool and `"false"` flag, and that the other keys stay when ingress is off; `packages/extra/seaweedfs/tests/ingress_dependency_test.yaml` pins the dependency and the S3 Ingress for an own, empty and inherited ingress; the kubernetes and monitoring suites pin the gated Ingress. Reverting any of the gates, or flipping the missing-key default, fails the suites. Not covered here: - `_namespace.etcd` has the same hardcoded shape (#4783) and is left for its own change. - Toggling `Tenant/root spec.ingress` without changing `ingress.rootEnabled` leaves the value stale, as `monitoring.rootEnabled` does today. ### Screenshots Not a UI change. ### Downstream repositories The diff adds a key to `packages/core/platform/values.yaml`, which the website documents by hand. - [ ] No downstream repository is affected by this change - [x] [cozystack/website](https://github.com/cozystack/website) - follow-up: cozystack/website#800 documents `ingress.rootEnabled` in the platform Package reference - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: - [ ] [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 ```release-note fix(platform): a root tenant without ingress no longer leaves seaweedfs-system waiting for an ingress-nginx-system release that is never created. Set the new platform value ingress.rootEnabled to false to match Tenant/root spec.ingress: false. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * Added a root-tenant ingress setting, enabled by default, that can be turned off. * **Bug Fixes** * Kubernetes and Grafana ingress resources are now rendered only when ingress is configured. * SeaweedFS S3 ingress is enabled only when ingress is configured. * Ingress-dependent components now respect the root-tenant setting, while other platform services remain available when root ingress is off. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
11 files changed
+266
-10
No files matched your search
@@ -3,7 +3,7 @@
|
||||
on an etcd-less tenant the chart collapses to the awaiting-etcd beacon,
|
||||
so no addon controller exists and the Service would select nothing. */}}
|
||||
{{- if and .Values.addons.ingressNginx.enabled .Values._namespace.etcd (eq .Values.addons.ingressNginx.exposeMethod "Proxied") }}
|
||||
{{- if .Values.addons.ingressNginx.hosts }}
|
||||
{{- if and .Values.addons.ingressNginx.hosts $ingress }}
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
|
||||
@@ -79,3 +79,20 @@ tests:
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 0
|
||||
|
||||
# An empty _namespace.ingress means no ingress-nginx serves this tenant, and
|
||||
# the API rejects the ingressClassName "" the Ingress would carry.
|
||||
- it: renders the Service but no Ingress when the tenant has no ingress
|
||||
set:
|
||||
_namespace:
|
||||
ingress: ""
|
||||
addons:
|
||||
ingressNginx:
|
||||
enabled: true
|
||||
exposeMethod: Proxied
|
||||
hosts: ["app.example.com"]
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 1
|
||||
- isKind:
|
||||
of: Service
|
||||
@@ -261,6 +261,10 @@ stringData:
|
||||
null/omitted in custom values. Missing key -> the true default,
|
||||
matching the chart values.yaml. */}}
|
||||
monitoring-enabled: {{ dig "rootEnabled" true (.Values.monitoring | default dict) | quote }}
|
||||
{{- /* Whether the root tenant runs its own ingress-nginx
|
||||
(Tenant/root spec.ingress). `dig`, as for monitoring-enabled
|
||||
above, so an explicit false survives. */}}
|
||||
ingress-enabled: {{ dig "rootEnabled" true (.Values.ingress | default dict) | quote }}
|
||||
{{- /* The rate each shared-central tracing tenant's collector holds it
|
||||
to. Only written when set: every release in every tenant reads
|
||||
this Secret, and a key appearing would upgrade all of them. */}}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
suite: apps.yaml ingress.rootEnabled → _cluster wiring
|
||||
templates:
|
||||
- templates/apps.yaml
|
||||
|
||||
release:
|
||||
name: cozy-platform
|
||||
namespace: cozy-system
|
||||
|
||||
# ingress.rootEnabled records whether the root tenant runs its own
|
||||
# ingress-nginx (Tenant/root spec.ingress). It reaches cozystack-basics through
|
||||
# _cluster.ingress-enabled in the cozystack-values Secret, where it decides
|
||||
# whether tenant-root's _namespace.ingress names tenant-root or stays empty.
|
||||
|
||||
tests:
|
||||
- it: writes ingress-enabled true by default
|
||||
asserts:
|
||||
- matchRegex:
|
||||
path: stringData["values.yaml"]
|
||||
pattern: '(?m)^\s*ingress-enabled:\s*"true"'
|
||||
|
||||
- it: writes ingress-enabled false when ingress.rootEnabled is disabled
|
||||
set:
|
||||
ingress.rootEnabled: false
|
||||
asserts:
|
||||
- matchRegex:
|
||||
path: stringData["values.yaml"]
|
||||
pattern: '(?m)^\s*ingress-enabled:\s*"false"'
|
||||
|
||||
- it: falls back to true (no panic) when ingress is null
|
||||
set:
|
||||
ingress: null
|
||||
asserts:
|
||||
- matchRegex:
|
||||
path: stringData["values.yaml"]
|
||||
pattern: '(?m)^\s*ingress-enabled:\s*"true"'
|
||||
@@ -669,6 +669,19 @@ gateway:
|
||||
- cozy-monitoring
|
||||
- cozy-linstor-gui
|
||||
- default
|
||||
# Platform ingress configuration.
|
||||
ingress:
|
||||
# Whether the root tenant (tenant-root) runs its own ingress-nginx, i.e.
|
||||
# Tenant/root spec.ingress=true. It decides whether tenant-root's
|
||||
# _namespace.ingress names tenant-root or stays empty, which is what
|
||||
# applications there (SeaweedFS waiting on ingress-nginx-system, the
|
||||
# ingressClassName of their Ingresses) and every tenant inheriting from the
|
||||
# root read. Nothing in the charts sets Tenant/root spec.ingress, so keep
|
||||
# this in sync with it by hand; changing it re-renders cozystack-basics and
|
||||
# the releases reading the cozystack-values Secret. The default is true only
|
||||
# to keep the value existing clusters already render.
|
||||
rootEnabled: true
|
||||
|
||||
# Platform monitoring configuration.
|
||||
monitoring:
|
||||
# Whether the root tenant (tenant-root) hosts the platform
|
||||
|
||||
@@ -338,6 +338,7 @@ spec:
|
||||
s3:
|
||||
replicas: {{ .Values.s3.replicas }}
|
||||
ingress:
|
||||
enabled: {{ not (empty $ingress) }}
|
||||
className: {{ $ingress }}
|
||||
host: {{ .Values.host | default (printf "s3.%s" $host) }}
|
||||
annotations:
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
suite: seaweedfs waits for ingress-nginx only in a namespace that runs it
|
||||
templates:
|
||||
- templates/seaweedfs.yaml
|
||||
|
||||
release:
|
||||
name: seaweedfs
|
||||
namespace: tenant-root
|
||||
|
||||
set:
|
||||
topology: Simple
|
||||
replicationFactor: 2
|
||||
_cluster:
|
||||
issuer-name: letsencrypt-prod
|
||||
|
||||
tests:
|
||||
- it: depends on ingress-nginx-system when the namespace runs its own ingress
|
||||
documentSelector:
|
||||
path: metadata.name
|
||||
value: seaweedfs-system
|
||||
set:
|
||||
_namespace:
|
||||
host: example.org
|
||||
ingress: tenant-root
|
||||
asserts:
|
||||
- contains:
|
||||
path: spec.dependsOn
|
||||
content:
|
||||
name: ingress-nginx-system
|
||||
namespace: tenant-root
|
||||
|
||||
- it: does not depend on ingress-nginx-system when the root tenant has no ingress
|
||||
documentSelector:
|
||||
path: metadata.name
|
||||
value: seaweedfs-system
|
||||
set:
|
||||
_namespace:
|
||||
host: example.org
|
||||
ingress: ""
|
||||
asserts:
|
||||
- notContains:
|
||||
path: spec.dependsOn
|
||||
content:
|
||||
name: ingress-nginx-system
|
||||
namespace: tenant-root
|
||||
|
||||
- it: does not depend on ingress-nginx-system when ingress lives in a parent namespace
|
||||
release:
|
||||
namespace: tenant-acme
|
||||
documentSelector:
|
||||
path: metadata.name
|
||||
value: seaweedfs-system
|
||||
set:
|
||||
_namespace:
|
||||
host: acme.example.org
|
||||
ingress: tenant-root
|
||||
asserts:
|
||||
- notContains:
|
||||
path: spec.dependsOn
|
||||
content:
|
||||
name: ingress-nginx-system
|
||||
namespace: tenant-acme
|
||||
|
||||
- it: disables the S3 Ingress when the namespace has no ingress
|
||||
documentSelector:
|
||||
path: metadata.name
|
||||
value: seaweedfs-system
|
||||
set:
|
||||
_namespace:
|
||||
host: example.org
|
||||
ingress: ""
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.values.seaweedfs.s3.ingress.enabled
|
||||
value: false
|
||||
|
||||
- it: keeps the S3 Ingress when the namespace has an ingress
|
||||
documentSelector:
|
||||
path: metadata.name
|
||||
value: seaweedfs-system
|
||||
set:
|
||||
_namespace:
|
||||
host: example.org
|
||||
ingress: tenant-root
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.values.seaweedfs.s3.ingress.enabled
|
||||
value: true
|
||||
- equal:
|
||||
path: spec.values.seaweedfs.s3.ingress.className
|
||||
value: tenant-root
|
||||
@@ -15,7 +15,13 @@ stringData:
|
||||
_namespace:
|
||||
host: {{ index .Values._cluster "root-host" | quote }}
|
||||
etcd: tenant-root
|
||||
{{- /* Without ingress on the root Tenant there is no
|
||||
ingress-nginx-system in tenant-root, so the key stays empty, as
|
||||
it does for a sub-tenant with no ingress anywhere above it. A
|
||||
missing key keeps tenant-root for Secrets written before it. */ -}}
|
||||
{{- if eq (toString (index .Values._cluster "ingress-enabled" | default "true")) "true" }}
|
||||
ingress: tenant-root
|
||||
{{- end }}
|
||||
{{- /* `gateway` is conditional, the other four `_namespace` keys are
|
||||
unconditional. The `apps/tenant` chart gates tenant-root via
|
||||
`ne (include "tenant.name" .) "tenant-root"`, so the namespace.yaml
|
||||
|
||||
@@ -19,14 +19,16 @@ set:
|
||||
# never reaches tenant-root — this Secret is the only place that
|
||||
# value gets set for the root tenant.
|
||||
#
|
||||
# Four of the five `_namespace.*` keys (`etcd`, `ingress`,
|
||||
# `monitoring`, `seaweedfs`) are always rendered, because their
|
||||
# dependent platform apps are always installable in tenant-root.
|
||||
# `gateway` is conditional on `_cluster.gateway-enabled`: when the
|
||||
# platform-level flag is false (the default), Gateway is not
|
||||
# installed, and writing `gateway: tenant-root` would point apps at a
|
||||
# Gateway that doesn't exist. The fixtures below pin both halves of
|
||||
# that contract.
|
||||
# Three of the five `_namespace.*` keys (`etcd`, `monitoring`,
|
||||
# `seaweedfs`) are always rendered, because their dependent platform
|
||||
# apps are always installable in tenant-root. `gateway` is conditional
|
||||
# on `_cluster.gateway-enabled`: when the platform-level flag is false
|
||||
# (the default), Gateway is not installed, and writing
|
||||
# `gateway: tenant-root` would point apps at a Gateway that doesn't
|
||||
# exist. `ingress` is conditional on `_cluster.ingress-enabled` for the
|
||||
# same reason: with ingress off on the root Tenant there is no
|
||||
# ingress-nginx-system in tenant-root, and seaweedfs would wait on it
|
||||
# forever. The fixtures below pin both halves of each contract.
|
||||
tests:
|
||||
- it: omits _namespace.gateway when _cluster.gateway-enabled is missing (default)
|
||||
asserts:
|
||||
@@ -52,6 +54,54 @@ tests:
|
||||
path: stringData["values.yaml"]
|
||||
pattern: '(?m)^\s+gateway: tenant-root$'
|
||||
|
||||
- it: emits _namespace.ingress=tenant-root when _cluster.ingress-enabled is missing (Secrets written before the key existed)
|
||||
asserts:
|
||||
- matchRegex:
|
||||
path: stringData["values.yaml"]
|
||||
pattern: '(?m)^\s+ingress: tenant-root$'
|
||||
|
||||
- it: emits _namespace.ingress=tenant-root when _cluster.ingress-enabled is "true"
|
||||
set:
|
||||
_cluster:
|
||||
ingress-enabled: "true"
|
||||
asserts:
|
||||
- matchRegex:
|
||||
path: stringData["values.yaml"]
|
||||
pattern: '(?m)^\s+ingress: tenant-root$'
|
||||
|
||||
- it: emits _namespace.ingress=tenant-root when _cluster.ingress-enabled is a bool true
|
||||
set:
|
||||
_cluster:
|
||||
ingress-enabled: true
|
||||
asserts:
|
||||
- matchRegex:
|
||||
path: stringData["values.yaml"]
|
||||
pattern: '(?m)^\s+ingress: tenant-root$'
|
||||
|
||||
- it: omits _namespace.ingress when _cluster.ingress-enabled is "false"
|
||||
set:
|
||||
_cluster:
|
||||
ingress-enabled: "false"
|
||||
asserts:
|
||||
- notMatchRegex:
|
||||
path: stringData["values.yaml"]
|
||||
pattern: '(?m)^\s+ingress:'
|
||||
|
||||
- it: keeps _namespace.{etcd,monitoring,seaweedfs} when ingress is off
|
||||
set:
|
||||
_cluster:
|
||||
ingress-enabled: "false"
|
||||
asserts:
|
||||
- matchRegex:
|
||||
path: stringData["values.yaml"]
|
||||
pattern: '(?m)^\s+etcd: tenant-root$'
|
||||
- matchRegex:
|
||||
path: stringData["values.yaml"]
|
||||
pattern: '(?m)^\s+monitoring: tenant-root$'
|
||||
- matchRegex:
|
||||
path: stringData["values.yaml"]
|
||||
pattern: '(?m)^\s+seaweedfs: tenant-root$'
|
||||
|
||||
- it: keeps _namespace.{etcd,ingress,monitoring,seaweedfs} unconditional when Gateway is off — regression guard for a refactor that accidentally gates them on the same flag
|
||||
asserts:
|
||||
- matchRegex:
|
||||
|
||||
@@ -280,7 +280,7 @@ spec:
|
||||
path: auth.ini
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if ne $gatewayEnabled "true" }}
|
||||
{{- if and (ne $gatewayEnabled "true") $ingress }}
|
||||
ingress:
|
||||
{{- /* Operator wildcard mode: nginx serves the default SSL cert, so skip per-host ACME. */}}
|
||||
{{- if not $wildcardSecret }}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
suite: grafana ingress needs an ingress class to name
|
||||
templates:
|
||||
- templates/grafana/grafana.yaml
|
||||
|
||||
release:
|
||||
name: monitoring
|
||||
namespace: tenant-root
|
||||
|
||||
# An empty _namespace.ingress means no ingress-nginx serves this tenant, and
|
||||
# the API rejects the ingressClassName "" the operator would put on the
|
||||
# Ingress it creates from spec.ingress.
|
||||
|
||||
tests:
|
||||
- it: leaves spec.ingress out when the tenant has no ingress
|
||||
set:
|
||||
_cluster:
|
||||
issuer-name: letsencrypt-prod
|
||||
gateway-enabled: "false"
|
||||
_namespace:
|
||||
host: example.org
|
||||
ingress: ""
|
||||
asserts:
|
||||
- equal:
|
||||
path: kind
|
||||
value: Grafana
|
||||
- notExists:
|
||||
path: spec.ingress
|
||||
|
||||
- it: keeps spec.ingress when the tenant has an ingress
|
||||
set:
|
||||
_cluster:
|
||||
issuer-name: letsencrypt-prod
|
||||
gateway-enabled: "false"
|
||||
_namespace:
|
||||
host: example.org
|
||||
ingress: tenant-root
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.ingress.spec.ingressClassName
|
||||
value: tenant-root
|
||||
Reference in new issue
Block a user