mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-21 12:13:55 +09:00
feat(observability-proxy): grant tenant viewers the metrics root
The proxy authorizes the namespace metrics root with a SubjectAccessReview for list on cozystack.io metrics, which no role grants yet. Aggregating it into the tenant view role reaches every tenant group and ancestor subject without a tenant chart change. The Deployment passes the metrics store names and short-term retention from values, so a platform that renames or resizes its metricsStorages can keep the proxy's store choice in step. Assisted-by: LLM Signed-off-by: ZverGuy <maximbel2003@gmail.com>
This commit is contained in:
1 parent
cd3d889ee8
commit
5630de4ab1
5 files changed
+46
-7
No files matched your search
@@ -38,6 +38,9 @@ spec:
|
||||
- --cluster-domain={{ $clusterDomain }}
|
||||
- --root-tenant={{ .Values.observabilityProxy.rootTenant }}
|
||||
- --auth-cache-ttl={{ .Values.observabilityProxy.authCacheTTL }}
|
||||
- --metrics-shortterm-store={{ .Values.observabilityProxy.metrics.shorttermStore }}
|
||||
- --metrics-longterm-store={{ .Values.observabilityProxy.metrics.longtermStore }}
|
||||
- --metrics-shortterm-retention={{ .Values.observabilityProxy.metrics.shorttermRetention }}
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: 8080
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Aggregated into cozy-tenant-view (and consequently use, admin, super-admin).
|
||||
# No API server serves cozystack.io logs: the rule exists only for the
|
||||
# SubjectAccessReview the observability proxy asks before it answers a read
|
||||
# under /apis/cozystack.io/v1alpha1/namespaces/<ns>/logs/.
|
||||
# No API server serves cozystack.io logs or metrics: the rule exists only for
|
||||
# the SubjectAccessReview the observability proxy asks before it answers a
|
||||
# read under /apis/cozystack.io/v1alpha1/namespaces/<ns>/{logs,metrics}/.
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
@@ -10,5 +10,5 @@ metadata:
|
||||
rbac.cozystack.io/aggregate-to-tenant-view: "true"
|
||||
rules:
|
||||
- apiGroups: ["cozystack.io"]
|
||||
resources: ["logs"]
|
||||
resources: ["logs", "metrics"]
|
||||
verbs: ["list"]
|
||||
@@ -40,6 +40,35 @@ tests:
|
||||
path: spec.template.spec.containers[0].args
|
||||
content: --auth-cache-ttl=10s
|
||||
|
||||
- it: passes the metrics store names and short-term retention
|
||||
asserts:
|
||||
- contains:
|
||||
path: spec.template.spec.containers[0].args
|
||||
content: --metrics-shortterm-store=shortterm
|
||||
- contains:
|
||||
path: spec.template.spec.containers[0].args
|
||||
content: --metrics-longterm-store=longterm
|
||||
- contains:
|
||||
path: spec.template.spec.containers[0].args
|
||||
content: --metrics-shortterm-retention=72h
|
||||
|
||||
- it: follows renamed metrics stores
|
||||
set:
|
||||
observabilityProxy.metrics:
|
||||
shorttermStore: fast
|
||||
longtermStore: slow
|
||||
shorttermRetention: 24h
|
||||
asserts:
|
||||
- contains:
|
||||
path: spec.template.spec.containers[0].args
|
||||
content: --metrics-shortterm-store=fast
|
||||
- contains:
|
||||
path: spec.template.spec.containers[0].args
|
||||
content: --metrics-longterm-store=slow
|
||||
- contains:
|
||||
path: spec.template.spec.containers[0].args
|
||||
content: --metrics-shortterm-retention=24h
|
||||
|
||||
- it: falls back to cozy.local when the platform passes no cluster domain
|
||||
asserts:
|
||||
- contains:
|
||||
|
||||
@@ -2,7 +2,7 @@ suite: observability-proxy RBAC
|
||||
# The proxy authenticates and authorizes every request through the API server,
|
||||
# so a dropped verb here turns every request into an error at runtime rather
|
||||
# than a render failure. The tenant role is what lets a namespace viewer pass
|
||||
# the SubjectAccessReview the proxy asks for the namespace logs root.
|
||||
# the SubjectAccessReview the proxy asks for the namespace logs and metrics roots.
|
||||
templates:
|
||||
- templates/rbac.yaml
|
||||
- templates/tenant-clusterroles.yaml
|
||||
@@ -50,7 +50,7 @@ tests:
|
||||
name: observability-proxy
|
||||
namespace: cozy-observability-proxy
|
||||
|
||||
- it: aggregates list on cozystack.io logs into the tenant view role
|
||||
- it: aggregates list on cozystack.io logs and metrics into the tenant view role
|
||||
template: templates/tenant-clusterroles.yaml
|
||||
asserts:
|
||||
- isKind:
|
||||
@@ -63,5 +63,5 @@ tests:
|
||||
path: rules
|
||||
value:
|
||||
- apiGroups: ["cozystack.io"]
|
||||
resources: ["logs"]
|
||||
resources: ["logs", "metrics"]
|
||||
verbs: ["list"]
|
||||
@@ -7,6 +7,13 @@ observabilityProxy:
|
||||
replicas: 2
|
||||
rootTenant: tenant-root
|
||||
authCacheTTL: 10s
|
||||
# Names and retention of the root tenant's metricsStorages
|
||||
# (packages/system/monitoring/values.yaml). The retention is a Go
|
||||
# duration: 3d is written 72h.
|
||||
metrics:
|
||||
shorttermStore: shortterm
|
||||
longtermStore: longterm
|
||||
shorttermRetention: 72h
|
||||
resources:
|
||||
requests:
|
||||
cpu: 10m
|
||||
|
||||
Reference in new issue
Block a user