upd namespace labels

This commit is contained in:
Andrei Kvapil
2024-02-02 10:21:10 +01:00
parent 867bd11af0
commit 65e1daf1db
10 changed files with 52 additions and 32 deletions

View File

@@ -1,4 +1,4 @@
{{- if .Values.ownEtcd }}
{{- if .Values.etcd }}
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:

View File

@@ -1,4 +1,4 @@
{{- if .Values.ownIngress }}
{{- if .Values.ingress }}
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:

View File

@@ -1,4 +1,4 @@
{{- if .Values.ownMonitoring }}
{{- if .Values.monitoring }}
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:

View File

@@ -0,0 +1,29 @@
{{- if ne (include "tenant.name" .) "tenant-root" }}
---
apiVersion: v1
kind: Namespace
metadata:
name: {{ include "tenant.name" . }}
{{- if hasPrefix "tenant-" .Release.Namespace }}
{{- $existingNS := lookup "v1" "Namespace" "" .Release.Namespace }}
{{- if $existingNS }}
labels:
{{- 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) }}"
{{- end }}
{{- end }}
ownerReferences:
- apiVersion: v1
blockOwnerDeletion: true
controller: true
kind: Namespace
name: {{ .Release.Namespace }}
uid: {{ $existingNS.metadata.uid }}
{{- else }}
{{- fail (printf "error lookup exiting namespace: %s" .Release.Namespace) }}
{{- end }}
{{- end }}
{{- end }}

View File

@@ -1,22 +1,3 @@
{{- if ne (include "tenant.name" .) "tenant-root" }}
---
apiVersion: v1
kind: Namespace
metadata:
name: {{ include "tenant.name" . }}
{{- if hasPrefix "tenant-" .Release.Namespace }}
{{- $existingNS := lookup "v1" "Namespace" "" .Release.Namespace }}
{{- if $existingNS }}
ownerReferences:
- apiVersion: v1
blockOwnerDeletion: true
controller: true
kind: Namespace
name: {{ .Release.Namespace }}
uid: {{ $existingNS.metadata.uid }}
{{- end }}
{{- end }}
{{- end }}
---
apiVersion: v1
kind: ServiceAccount

View File

@@ -2,17 +2,17 @@
"$schema": "http://json-schema.org/schema#",
"type": "object",
"properties": {
"ownEtcd": {
"etcd": {
"type": "boolean",
"title": "Deploy own Etcd cluster",
"form": true
},
"ownMonitoring": {
"monitoring": {
"type": "boolean",
"title": "Deploy own Monitoring Stack",
"form": true
},
"ownIngress": {
"ingress": {
"type": "boolean",
"title": "Deploy own Ingress Controller",
"form": true

View File

@@ -1,3 +1,3 @@
ownEtcd: false
ownMonitoring: false
ownIngress: false
etcd: false
monitoring: false
ingress: false

View File

@@ -1,14 +1,14 @@
{
"containerimage.config.digest": "sha256:b95413eef3300e5b5d71499df490b708388ef4629bc0f627fa7ccfb868742b8b",
"containerimage.config.digest": "sha256:d7884d6ecb6194f1bd76f60317cc4c74b606c1db542b92559058af4ea6a4ac6a",
"containerimage.descriptor": {
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"digest": "sha256:db7bb15121fc3bad03f4dc6be4ec8ebcefb869f26abcd9b0e3c89f1e3b54a618",
"digest": "sha256:454b0acf089e63f508d27fed62a96a237f6df73a593f14ef9c3db8954281ee66",
"size": 2074,
"platform": {
"architecture": "amd64",
"os": "linux"
}
},
"containerimage.digest": "sha256:db7bb15121fc3bad03f4dc6be4ec8ebcefb869f26abcd9b0e3c89f1e3b54a618",
"containerimage.digest": "sha256:454b0acf089e63f508d27fed62a96a237f6df73a593f14ef9c3db8954281ee66",
"image.name": "ghcr.io/aenix-io/cozystack/installer:latest"
}

View File

@@ -1,4 +1,15 @@
---
apiVersion: v1
kind: Namespace
metadata:
annotations:
helm.sh/resource-policy: keep
labels:
namespace.cozystack.io/etcd: tenant-root
namespace.cozystack.io/monitoring: tenant-root
namespace.cozystack.io/ingress: tenant-root
name: tenant-root
---
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:

View File

@@ -29,4 +29,3 @@ namespaces:
- name: cozy-redis-operator
- name: cozy-telepresence
- name: cozy-victoria-metrics-operator
- name: tenant-root