mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-30 04:06:34 +09:00
feat(cozystack-basics): take the root tenant vGPU flag from the platform
A tenant is entitled to vGPU only when its parent is, and the root tenant's namespace and _namespace values are rendered here rather than by the tenant chart, so the chain has to start here. The value comes from _cluster.gpu-vgpu, which the platform fills from its gpu.vgpu. Like a tenant namespace, the root namespace always carries the label, and _namespace.vgpu appears only when entitled. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <f@lex.la>
This commit is contained in:
3 files changed
+83
No files matched your search
@@ -43,3 +43,6 @@ stringData:
|
||||
{{- end }}
|
||||
monitoring: tenant-root
|
||||
seaweedfs: tenant-root
|
||||
{{- if eq (toString (index .Values._cluster "gpu-vgpu" | default "false")) "true" }}
|
||||
vgpu: true
|
||||
{{- end }}
|
||||
@@ -6,6 +6,7 @@ metadata:
|
||||
labels:
|
||||
platform.cozystack.io/no-delete: "true"
|
||||
namespace.cozystack.io/host: {{ index .Values._cluster "root-host" | quote }}
|
||||
namespace.cozystack.io/vgpu: {{ eq (toString (index .Values._cluster "gpu-vgpu" | default "false")) "true" | quote }}
|
||||
{{- /* Gateway attach label: when platform-level Gateway is on,
|
||||
tenant-root owns the publishing Gateway, and its own
|
||||
namespace must carry the label so the Gateway's
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
suite: root tenant vGPU entitlement from platform values
|
||||
# The root tenant is rendered here, not by the tenant chart, so its vGPU
|
||||
# entitlement comes from the platform's gpu.vgpu through _cluster.gpu-vgpu.
|
||||
# Every child's entitlement requires its parent's, so this is where the chain
|
||||
# starts.
|
||||
templates:
|
||||
- templates/tenant-root.yaml
|
||||
- templates/cozystack-values-secret.yaml
|
||||
release:
|
||||
name: cozystack-basics
|
||||
namespace: cozy-system
|
||||
set:
|
||||
_cluster:
|
||||
root-host: example.org
|
||||
tests:
|
||||
- it: labels the root namespace entitled when the platform turns vGPU on
|
||||
set:
|
||||
_cluster:
|
||||
gpu-vgpu: "true"
|
||||
template: templates/tenant-root.yaml
|
||||
documentSelector:
|
||||
path: kind
|
||||
value: Namespace
|
||||
asserts:
|
||||
- equal:
|
||||
path: metadata.labels["namespace.cozystack.io/vgpu"]
|
||||
value: "true"
|
||||
|
||||
- it: passes the entitlement to the root tenant's children
|
||||
set:
|
||||
_cluster:
|
||||
gpu-vgpu: "true"
|
||||
template: templates/cozystack-values-secret.yaml
|
||||
asserts:
|
||||
- matchRegex:
|
||||
path: stringData["values.yaml"]
|
||||
pattern: "(?m)^_namespace:\\n( .*\\n)* vgpu: true$"
|
||||
|
||||
- it: labels the root namespace not entitled by default
|
||||
template: templates/tenant-root.yaml
|
||||
documentSelector:
|
||||
path: kind
|
||||
value: Namespace
|
||||
asserts:
|
||||
- equal:
|
||||
path: metadata.labels["namespace.cozystack.io/vgpu"]
|
||||
value: "false"
|
||||
|
||||
- it: leaves _namespace.vgpu out by default
|
||||
template: templates/cozystack-values-secret.yaml
|
||||
asserts:
|
||||
- notMatchRegex:
|
||||
path: stringData["values.yaml"]
|
||||
pattern: "(?m)^ vgpu:"
|
||||
|
||||
# A bool set on the command line reaches here as a bool, a value from the
|
||||
# platform's Secret as a string; only "true" in either form entitles.
|
||||
- it: accepts a bool true
|
||||
set:
|
||||
_cluster:
|
||||
gpu-vgpu: true
|
||||
template: templates/tenant-root.yaml
|
||||
documentSelector:
|
||||
path: kind
|
||||
value: Namespace
|
||||
asserts:
|
||||
- equal:
|
||||
path: metadata.labels["namespace.cozystack.io/vgpu"]
|
||||
value: "true"
|
||||
|
||||
- it: treats the string "false" as not entitled
|
||||
set:
|
||||
_cluster:
|
||||
gpu-vgpu: "false"
|
||||
template: templates/cozystack-values-secret.yaml
|
||||
asserts:
|
||||
- notMatchRegex:
|
||||
path: stringData["values.yaml"]
|
||||
pattern: "(?m)^ vgpu:"
|
||||
Reference in new issue
Block a user