diff --git a/packages/apps/tenant/templates/namespace.yaml b/packages/apps/tenant/templates/namespace.yaml index 30601f03..5aa6daae 100644 --- a/packages/apps/tenant/templates/namespace.yaml +++ b/packages/apps/tenant/templates/namespace.yaml @@ -7,18 +7,18 @@ metadata: {{- if hasPrefix "tenant-" .Release.Namespace }} {{- $existingNS := lookup "v1" "Namespace" "" .Release.Namespace }} {{- if $existingNS }} - labels: + annotations: {{- if .Values.host }} namespace.cozystack.io/host: "{{ .Values.host }}" {{- else }} - {{ $parentHost := index $existingNS.metadata.labels "namespace.cozystack.io/host" | required (printf "namespace %s has no namespace.cozystack.io/host label" $.Release.Namespace) }} - namespace.cozystack.io/host: "{{ trimPrefix "tenant-" (include "tenant.name" .) }}.{{ $parentHost }}" + {{ $parentHost := index $existingNS.metadata.annotations "namespace.cozystack.io/host" | required (printf "namespace %s has no namespace.cozystack.io/host annotation" $.Release.Namespace) }} + namespace.cozystack.io/host: "{{ splitList "-" (include "tenant.name" .) | last }}.{{ $parentHost }}" {{- end }} {{- range $x := list "etcd" "monitoring" "ingress" }} {{- if (index $.Values $x) }} namespace.cozystack.io/{{ $x }}: "{{ include "tenant.name" $ }}" {{- else }} - namespace.cozystack.io/{{ $x }}: "{{ index $existingNS.metadata.labels (printf "namespace.cozystack.io/%s" $x) | required (printf "namespace %s has no namespace.cozystack.io/%s label" $.Release.Namespace $x) }}" + namespace.cozystack.io/{{ $x }}: "{{ index $existingNS.metadata.annotations (printf "namespace.cozystack.io/%s" $x) | required (printf "namespace %s has no namespace.cozystack.io/%s annotation" $.Release.Namespace $x) }}" {{- end }} {{- end }} ownerReferences: