From b0c90f792e34a11d1f363f0491ab0946a52b925c Mon Sep 17 00:00:00 2001 From: yminer Date: Mon, 11 Nov 2024 07:51:56 +0000 Subject: [PATCH] add helper for overrides namespace while using helm template Signed-off-by: yminer --- templates/_helpers.tpl | 7 +++++++ templates/core/core-cm.yaml | 2 +- templates/core/core-dpl.yaml | 2 +- templates/core/core-pre-upgrade-job.yaml | 2 +- templates/core/core-secret.yaml | 2 +- templates/core/core-svc.yaml | 2 +- templates/core/core-tls.yaml | 2 +- templates/database/database-secret.yaml | 2 +- templates/database/database-ss.yaml | 2 +- templates/database/database-svc.yaml | 2 +- templates/exporter/exporter-cm-env.yaml | 2 +- templates/exporter/exporter-dpl.yaml | 2 +- templates/exporter/exporter-secret.yaml | 2 +- templates/exporter/exporter-svc.yaml | 2 +- templates/ingress/ingress.yaml | 2 +- templates/ingress/secret.yaml | 2 +- templates/internal/auto-tls.yaml | 10 +++++----- templates/jobservice/jobservice-cm-env.yaml | 2 +- templates/jobservice/jobservice-cm.yaml | 2 +- templates/jobservice/jobservice-dpl.yaml | 2 +- templates/jobservice/jobservice-pvc.yaml | 2 +- templates/jobservice/jobservice-secrets.yaml | 2 +- templates/jobservice/jobservice-svc.yaml | 2 +- templates/jobservice/jobservice-tls.yaml | 2 +- templates/metrics/metrics-svcmon.yaml | 2 +- templates/nginx/configmap-http.yaml | 2 +- templates/nginx/configmap-https.yaml | 2 +- templates/nginx/deployment.yaml | 2 +- templates/nginx/secret.yaml | 2 +- templates/nginx/service.yaml | 2 +- templates/portal/configmap.yaml | 2 +- templates/portal/deployment.yaml | 2 +- templates/portal/service.yaml | 2 +- templates/portal/tls.yaml | 2 +- templates/redis/service.yaml | 2 +- templates/redis/statefulset.yaml | 2 +- templates/registry/registry-cm.yaml | 2 +- templates/registry/registry-dpl.yaml | 2 +- templates/registry/registry-pvc.yaml | 2 +- templates/registry/registry-secret.yaml | 4 ++-- templates/registry/registry-svc.yaml | 2 +- templates/registry/registry-tls.yaml | 2 +- templates/registry/registryctl-cm.yaml | 2 +- templates/registry/registryctl-secret.yaml | 2 +- templates/trivy/trivy-secret.yaml | 2 +- templates/trivy/trivy-sts.yaml | 2 +- templates/trivy/trivy-svc.yaml | 2 +- templates/trivy/trivy-tls.yaml | 2 +- values.yaml | 6 ++++++ 49 files changed, 65 insertions(+), 52 deletions(-) diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl index f6249b399..d8a7f0587 100644 --- a/templates/_helpers.tpl +++ b/templates/_helpers.tpl @@ -579,3 +579,10 @@ app: "{{ template "harbor.name" . }}" {{- define "harbor.ingress.kubeVersion" -}} {{- default .Capabilities.KubeVersion.Version .Values.expose.ingress.kubeVersionOverride -}} {{- end -}} + +{{/* +Allow the release namespace to be overridden for multi-namespace resources in combined charts. +*/}} +{{- define "harbor.namespace" -}} +{{- default .Release.Namespace .Values.namespaceOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/templates/core/core-cm.yaml b/templates/core/core-cm.yaml index f27bdaaaf..b3d09f750 100644 --- a/templates/core/core-cm.yaml +++ b/templates/core/core-cm.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: ConfigMap metadata: name: {{ template "harbor.core" . }} - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} labels: {{ include "harbor.labels" . | indent 4 }} data: diff --git a/templates/core/core-dpl.yaml b/templates/core/core-dpl.yaml index 4705c5f6e..f2ad39ce3 100644 --- a/templates/core/core-dpl.yaml +++ b/templates/core/core-dpl.yaml @@ -2,7 +2,7 @@ apiVersion: apps/v1 kind: Deployment metadata: name: {{ template "harbor.core" . }} - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} labels: {{ include "harbor.labels" . | indent 4 }} component: core diff --git a/templates/core/core-pre-upgrade-job.yaml b/templates/core/core-pre-upgrade-job.yaml index 872715694..cda15f2e1 100644 --- a/templates/core/core-pre-upgrade-job.yaml +++ b/templates/core/core-pre-upgrade-job.yaml @@ -3,7 +3,7 @@ apiVersion: batch/v1 kind: Job metadata: name: migration-job - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} labels: {{ include "harbor.labels" . | indent 4 }} component: migrator diff --git a/templates/core/core-secret.yaml b/templates/core/core-secret.yaml index ea9d4cfab..4546021de 100644 --- a/templates/core/core-secret.yaml +++ b/templates/core/core-secret.yaml @@ -3,7 +3,7 @@ apiVersion: v1 kind: Secret metadata: name: {{ template "harbor.core" . }} - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} labels: {{ include "harbor.labels" . | indent 4 }} type: Opaque diff --git a/templates/core/core-svc.yaml b/templates/core/core-svc.yaml index f918eb388..0399ee1b4 100644 --- a/templates/core/core-svc.yaml +++ b/templates/core/core-svc.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: Service metadata: name: {{ template "harbor.core" . }} - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} labels: {{ include "harbor.labels" . | indent 4 }} {{- with .Values.core.serviceAnnotations }} diff --git a/templates/core/core-tls.yaml b/templates/core/core-tls.yaml index d90d30c8f..b11ed3803 100644 --- a/templates/core/core-tls.yaml +++ b/templates/core/core-tls.yaml @@ -4,7 +4,7 @@ apiVersion: v1 kind: Secret metadata: name: "{{ template "harbor.internalTLS.core.secretName" . }}" - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} labels: {{ include "harbor.labels" . | indent 4 }} type: kubernetes.io/tls diff --git a/templates/database/database-secret.yaml b/templates/database/database-secret.yaml index 0d07ec26f..d9eba5da7 100644 --- a/templates/database/database-secret.yaml +++ b/templates/database/database-secret.yaml @@ -3,7 +3,7 @@ apiVersion: v1 kind: Secret metadata: name: "{{ template "harbor.database" . }}" - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} labels: {{ include "harbor.labels" . | indent 4 }} type: Opaque diff --git a/templates/database/database-ss.yaml b/templates/database/database-ss.yaml index 9bd5c096c..9916f5664 100644 --- a/templates/database/database-ss.yaml +++ b/templates/database/database-ss.yaml @@ -4,7 +4,7 @@ apiVersion: apps/v1 kind: StatefulSet metadata: name: "{{ template "harbor.database" . }}" - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} labels: {{ include "harbor.labels" . | indent 4 }} component: database diff --git a/templates/database/database-svc.yaml b/templates/database/database-svc.yaml index e2085a058..9fea0ab85 100644 --- a/templates/database/database-svc.yaml +++ b/templates/database/database-svc.yaml @@ -3,7 +3,7 @@ apiVersion: v1 kind: Service metadata: name: "{{ template "harbor.database" . }}" - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} labels: {{ include "harbor.labels" . | indent 4 }} spec: diff --git a/templates/exporter/exporter-cm-env.yaml b/templates/exporter/exporter-cm-env.yaml index 3f911032b..23ebdd6ae 100644 --- a/templates/exporter/exporter-cm-env.yaml +++ b/templates/exporter/exporter-cm-env.yaml @@ -3,7 +3,7 @@ apiVersion: v1 kind: ConfigMap metadata: name: "{{ template "harbor.exporter" . }}-env" - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} labels: {{ include "harbor.labels" . | indent 4 }} data: diff --git a/templates/exporter/exporter-dpl.yaml b/templates/exporter/exporter-dpl.yaml index 32fac20ac..736ebc9a3 100644 --- a/templates/exporter/exporter-dpl.yaml +++ b/templates/exporter/exporter-dpl.yaml @@ -3,7 +3,7 @@ apiVersion: apps/v1 kind: Deployment metadata: name: {{ template "harbor.exporter" . }} - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} labels: {{ include "harbor.labels" . | indent 4 }} component: exporter diff --git a/templates/exporter/exporter-secret.yaml b/templates/exporter/exporter-secret.yaml index 02c74d03c..035cada38 100644 --- a/templates/exporter/exporter-secret.yaml +++ b/templates/exporter/exporter-secret.yaml @@ -3,7 +3,7 @@ apiVersion: v1 kind: Secret metadata: name: {{ template "harbor.exporter" . }} - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} labels: {{ include "harbor.labels" . | indent 4 }} type: Opaque diff --git a/templates/exporter/exporter-svc.yaml b/templates/exporter/exporter-svc.yaml index 6d0d83193..ffbcda13a 100644 --- a/templates/exporter/exporter-svc.yaml +++ b/templates/exporter/exporter-svc.yaml @@ -3,7 +3,7 @@ apiVersion: v1 kind: Service metadata: name: "{{ template "harbor.exporter" . }}" - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} labels: {{ include "harbor.labels" . | indent 4 }} spec: diff --git a/templates/ingress/ingress.yaml b/templates/ingress/ingress.yaml index 06096b86f..cd33f3c83 100644 --- a/templates/ingress/ingress.yaml +++ b/templates/ingress/ingress.yaml @@ -35,7 +35,7 @@ apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: "{{ template "harbor.ingress" . }}" - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} labels: {{ include "harbor.labels" . | indent 4 }} {{- if $ingress.labels }} diff --git a/templates/ingress/secret.yaml b/templates/ingress/secret.yaml index 90ba27511..fa473e1d8 100644 --- a/templates/ingress/secret.yaml +++ b/templates/ingress/secret.yaml @@ -5,7 +5,7 @@ apiVersion: v1 kind: Secret metadata: name: "{{ template "harbor.ingress" . }}" - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} labels: {{ include "harbor.labels" . | indent 4 }} type: kubernetes.io/tls diff --git a/templates/internal/auto-tls.yaml b/templates/internal/auto-tls.yaml index 32807cfd1..b45fb8a0a 100644 --- a/templates/internal/auto-tls.yaml +++ b/templates/internal/auto-tls.yaml @@ -14,7 +14,7 @@ apiVersion: v1 kind: Secret metadata: name: "{{ template "harbor.internalTLS.core.secretName" . }}" - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} labels: {{ include "harbor.labels" . | indent 4 }} type: kubernetes.io/tls @@ -28,7 +28,7 @@ apiVersion: v1 kind: Secret metadata: name: "{{ template "harbor.internalTLS.jobservice.secretName" . }}" - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} labels: {{ include "harbor.labels" . | indent 4 }} type: kubernetes.io/tls @@ -42,7 +42,7 @@ apiVersion: v1 kind: Secret metadata: name: "{{ template "harbor.internalTLS.registry.secretName" . }}" - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} labels: {{ include "harbor.labels" . | indent 4 }} type: kubernetes.io/tls @@ -56,7 +56,7 @@ apiVersion: v1 kind: Secret metadata: name: "{{ template "harbor.internalTLS.portal.secretName" . }}" - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} labels: {{ include "harbor.labels" . | indent 4 }} type: kubernetes.io/tls @@ -73,7 +73,7 @@ apiVersion: v1 kind: Secret metadata: name: "{{ template "harbor.internalTLS.trivy.secretName" . }}" - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} labels: {{ include "harbor.labels" . | indent 4 }} type: kubernetes.io/tls diff --git a/templates/jobservice/jobservice-cm-env.yaml b/templates/jobservice/jobservice-cm-env.yaml index 2b9307455..bc6669f4d 100644 --- a/templates/jobservice/jobservice-cm-env.yaml +++ b/templates/jobservice/jobservice-cm-env.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: ConfigMap metadata: name: "{{ template "harbor.jobservice" . }}-env" - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} labels: {{ include "harbor.labels" . | indent 4 }} data: diff --git a/templates/jobservice/jobservice-cm.yaml b/templates/jobservice/jobservice-cm.yaml index c950e6787..30d2847d7 100644 --- a/templates/jobservice/jobservice-cm.yaml +++ b/templates/jobservice/jobservice-cm.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: ConfigMap metadata: name: "{{ template "harbor.jobservice" . }}" - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} labels: {{ include "harbor.labels" . | indent 4 }} data: diff --git a/templates/jobservice/jobservice-dpl.yaml b/templates/jobservice/jobservice-dpl.yaml index 3e426694b..7a42277f2 100644 --- a/templates/jobservice/jobservice-dpl.yaml +++ b/templates/jobservice/jobservice-dpl.yaml @@ -2,7 +2,7 @@ apiVersion: apps/v1 kind: Deployment metadata: name: "{{ template "harbor.jobservice" . }}" - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} labels: {{ include "harbor.labels" . | indent 4 }} component: jobservice diff --git a/templates/jobservice/jobservice-pvc.yaml b/templates/jobservice/jobservice-pvc.yaml index eb781eed1..8f102ee7b 100644 --- a/templates/jobservice/jobservice-pvc.yaml +++ b/templates/jobservice/jobservice-pvc.yaml @@ -4,7 +4,7 @@ kind: PersistentVolumeClaim apiVersion: v1 metadata: name: {{ template "harbor.jobservice" . }} - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} annotations: {{- range $key, $value := $jobLog.annotations }} {{ $key }}: {{ $value | quote }} diff --git a/templates/jobservice/jobservice-secrets.yaml b/templates/jobservice/jobservice-secrets.yaml index 7706c3513..eacf7eb91 100644 --- a/templates/jobservice/jobservice-secrets.yaml +++ b/templates/jobservice/jobservice-secrets.yaml @@ -3,7 +3,7 @@ apiVersion: v1 kind: Secret metadata: name: "{{ template "harbor.jobservice" . }}" - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} labels: {{ include "harbor.labels" . | indent 4 }} type: Opaque diff --git a/templates/jobservice/jobservice-svc.yaml b/templates/jobservice/jobservice-svc.yaml index 483b40ed5..fab5b4908 100644 --- a/templates/jobservice/jobservice-svc.yaml +++ b/templates/jobservice/jobservice-svc.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: Service metadata: name: "{{ template "harbor.jobservice" . }}" - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} labels: {{ include "harbor.labels" . | indent 4 }} spec: diff --git a/templates/jobservice/jobservice-tls.yaml b/templates/jobservice/jobservice-tls.yaml index 58809ec46..b2c61d212 100644 --- a/templates/jobservice/jobservice-tls.yaml +++ b/templates/jobservice/jobservice-tls.yaml @@ -4,7 +4,7 @@ apiVersion: v1 kind: Secret metadata: name: "{{ template "harbor.internalTLS.jobservice.secretName" . }}" - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} labels: {{ include "harbor.labels" . | indent 4 }} type: kubernetes.io/tls diff --git a/templates/metrics/metrics-svcmon.yaml b/templates/metrics/metrics-svcmon.yaml index d566285ed..f3a6f7c99 100644 --- a/templates/metrics/metrics-svcmon.yaml +++ b/templates/metrics/metrics-svcmon.yaml @@ -3,7 +3,7 @@ apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: name: {{ template "harbor.fullname" . }} - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} labels: {{ include "harbor.labels" . | nindent 4 }} {{- if .Values.metrics.serviceMonitor.additionalLabels }} {{ toYaml .Values.metrics.serviceMonitor.additionalLabels | indent 4 }} diff --git a/templates/nginx/configmap-http.yaml b/templates/nginx/configmap-http.yaml index 93ef76e8b..61aae5ea1 100644 --- a/templates/nginx/configmap-http.yaml +++ b/templates/nginx/configmap-http.yaml @@ -4,7 +4,7 @@ apiVersion: v1 kind: ConfigMap metadata: name: {{ template "harbor.nginx" . }} - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} labels: {{ include "harbor.labels" . | indent 4 }} data: diff --git a/templates/nginx/configmap-https.yaml b/templates/nginx/configmap-https.yaml index 390caf216..ca163cbb6 100644 --- a/templates/nginx/configmap-https.yaml +++ b/templates/nginx/configmap-https.yaml @@ -4,7 +4,7 @@ apiVersion: v1 kind: ConfigMap metadata: name: {{ template "harbor.nginx" . }} - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} labels: {{ include "harbor.labels" . | indent 4 }} data: diff --git a/templates/nginx/deployment.yaml b/templates/nginx/deployment.yaml index 04faa3735..90f38df81 100644 --- a/templates/nginx/deployment.yaml +++ b/templates/nginx/deployment.yaml @@ -3,7 +3,7 @@ apiVersion: apps/v1 kind: Deployment metadata: name: {{ template "harbor.nginx" . }} - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} labels: {{ include "harbor.labels" . | indent 4 }} component: nginx diff --git a/templates/nginx/secret.yaml b/templates/nginx/secret.yaml index 369bd65d6..e5dd2ed3a 100644 --- a/templates/nginx/secret.yaml +++ b/templates/nginx/secret.yaml @@ -5,7 +5,7 @@ apiVersion: v1 kind: Secret metadata: name: {{ template "harbor.nginx" . }} - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} labels: {{ include "harbor.labels" . | indent 4 }} type: Opaque diff --git a/templates/nginx/service.yaml b/templates/nginx/service.yaml index 7eac84ee1..ae9205f21 100644 --- a/templates/nginx/service.yaml +++ b/templates/nginx/service.yaml @@ -5,7 +5,7 @@ metadata: {{- if eq .Values.expose.type "clusterIP" }} {{- $clusterIP := .Values.expose.clusterIP }} name: {{ $clusterIP.name }} - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} labels: {{ include "harbor.labels" . | indent 4 }} {{- if .Values.expose.clusterIP.labels }} diff --git a/templates/portal/configmap.yaml b/templates/portal/configmap.yaml index af56783a8..963aa735c 100644 --- a/templates/portal/configmap.yaml +++ b/templates/portal/configmap.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: ConfigMap metadata: name: "{{ template "harbor.portal" . }}" - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} labels: {{ include "harbor.labels" . | indent 4 }} data: diff --git a/templates/portal/deployment.yaml b/templates/portal/deployment.yaml index 88bcd4979..ddfbc8530 100644 --- a/templates/portal/deployment.yaml +++ b/templates/portal/deployment.yaml @@ -2,7 +2,7 @@ apiVersion: apps/v1 kind: Deployment metadata: name: "{{ template "harbor.portal" . }}" - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} labels: {{ include "harbor.labels" . | indent 4 }} component: portal diff --git a/templates/portal/service.yaml b/templates/portal/service.yaml index c1273f072..a9c094bb4 100644 --- a/templates/portal/service.yaml +++ b/templates/portal/service.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: Service metadata: name: "{{ template "harbor.portal" . }}" - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} labels: {{ include "harbor.labels" . | indent 4 }} {{- with .Values.portal.serviceAnnotations }} diff --git a/templates/portal/tls.yaml b/templates/portal/tls.yaml index e61a7d3a4..5b7d3e020 100644 --- a/templates/portal/tls.yaml +++ b/templates/portal/tls.yaml @@ -4,7 +4,7 @@ apiVersion: v1 kind: Secret metadata: name: "{{ template "harbor.internalTLS.portal.secretName" . }}" - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} labels: {{ include "harbor.labels" . | indent 4 }} type: kubernetes.io/tls diff --git a/templates/redis/service.yaml b/templates/redis/service.yaml index 61c21d13e..81794e53c 100644 --- a/templates/redis/service.yaml +++ b/templates/redis/service.yaml @@ -3,7 +3,7 @@ apiVersion: v1 kind: Service metadata: name: {{ template "harbor.redis" . }} - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} labels: {{ include "harbor.labels" . | indent 4 }} spec: diff --git a/templates/redis/statefulset.yaml b/templates/redis/statefulset.yaml index fa5dd22d2..9149f0af1 100644 --- a/templates/redis/statefulset.yaml +++ b/templates/redis/statefulset.yaml @@ -4,7 +4,7 @@ apiVersion: apps/v1 kind: StatefulSet metadata: name: {{ template "harbor.redis" . }} - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} labels: {{ include "harbor.labels" . | indent 4 }} component: redis diff --git a/templates/registry/registry-cm.yaml b/templates/registry/registry-cm.yaml index 26e3fc915..0bbfa4451 100644 --- a/templates/registry/registry-cm.yaml +++ b/templates/registry/registry-cm.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: ConfigMap metadata: name: "{{ template "harbor.registry" . }}" - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} labels: {{ include "harbor.labels" . | indent 4 }} data: diff --git a/templates/registry/registry-dpl.yaml b/templates/registry/registry-dpl.yaml index a86e2eee0..203cddf2c 100644 --- a/templates/registry/registry-dpl.yaml +++ b/templates/registry/registry-dpl.yaml @@ -4,7 +4,7 @@ apiVersion: apps/v1 kind: Deployment metadata: name: "{{ template "harbor.registry" . }}" - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} labels: {{ include "harbor.labels" . | indent 4 }} component: registry diff --git a/templates/registry/registry-pvc.yaml b/templates/registry/registry-pvc.yaml index 712c21175..f66015786 100644 --- a/templates/registry/registry-pvc.yaml +++ b/templates/registry/registry-pvc.yaml @@ -5,7 +5,7 @@ kind: PersistentVolumeClaim apiVersion: v1 metadata: name: {{ template "harbor.registry" . }} - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} annotations: {{- range $key, $value := $registry.annotations }} {{ $key }}: {{ $value | quote }} diff --git a/templates/registry/registry-secret.yaml b/templates/registry/registry-secret.yaml index 11ada3b70..82e468354 100644 --- a/templates/registry/registry-secret.yaml +++ b/templates/registry/registry-secret.yaml @@ -3,7 +3,7 @@ apiVersion: v1 kind: Secret metadata: name: "{{ template "harbor.registry" . }}" - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} labels: {{ include "harbor.labels" . | indent 4 }} type: Opaque @@ -44,7 +44,7 @@ apiVersion: v1 kind: Secret metadata: name: "{{ template "harbor.registry" . }}-htpasswd" - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} labels: {{ include "harbor.labels" . | indent 4 }} type: Opaque diff --git a/templates/registry/registry-svc.yaml b/templates/registry/registry-svc.yaml index d89ae7dca..8b198d90e 100644 --- a/templates/registry/registry-svc.yaml +++ b/templates/registry/registry-svc.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: Service metadata: name: "{{ template "harbor.registry" . }}" - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} labels: {{ include "harbor.labels" . | indent 4 }} spec: diff --git a/templates/registry/registry-tls.yaml b/templates/registry/registry-tls.yaml index ec4540c2e..28c140563 100644 --- a/templates/registry/registry-tls.yaml +++ b/templates/registry/registry-tls.yaml @@ -4,7 +4,7 @@ apiVersion: v1 kind: Secret metadata: name: "{{ template "harbor.internalTLS.registry.secretName" . }}" - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} labels: {{ include "harbor.labels" . | indent 4 }} type: kubernetes.io/tls diff --git a/templates/registry/registryctl-cm.yaml b/templates/registry/registryctl-cm.yaml index 61b2c5e13..1928fe994 100644 --- a/templates/registry/registryctl-cm.yaml +++ b/templates/registry/registryctl-cm.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: ConfigMap metadata: name: "{{ template "harbor.registryCtl" . }}" - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} labels: {{ include "harbor.labels" . | indent 4 }} data: diff --git a/templates/registry/registryctl-secret.yaml b/templates/registry/registryctl-secret.yaml index 324a2e03b..8bffe843b 100644 --- a/templates/registry/registryctl-secret.yaml +++ b/templates/registry/registryctl-secret.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: Secret metadata: name: "{{ template "harbor.registryCtl" . }}" - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} labels: {{ include "harbor.labels" . | indent 4 }} type: Opaque diff --git a/templates/trivy/trivy-secret.yaml b/templates/trivy/trivy-secret.yaml index b13f88000..9fa11bf03 100644 --- a/templates/trivy/trivy-secret.yaml +++ b/templates/trivy/trivy-secret.yaml @@ -3,7 +3,7 @@ apiVersion: v1 kind: Secret metadata: name: {{ template "harbor.trivy" . }} - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} labels: {{ include "harbor.labels" . | indent 4 }} type: Opaque diff --git a/templates/trivy/trivy-sts.yaml b/templates/trivy/trivy-sts.yaml index 7e34ee9c7..532ff8192 100644 --- a/templates/trivy/trivy-sts.yaml +++ b/templates/trivy/trivy-sts.yaml @@ -4,7 +4,7 @@ apiVersion: apps/v1 kind: StatefulSet metadata: name: {{ template "harbor.trivy" . }} - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} labels: {{ include "harbor.labels" . | indent 4 }} component: trivy diff --git a/templates/trivy/trivy-svc.yaml b/templates/trivy/trivy-svc.yaml index e0ae32070..07ba0d02a 100644 --- a/templates/trivy/trivy-svc.yaml +++ b/templates/trivy/trivy-svc.yaml @@ -3,7 +3,7 @@ apiVersion: v1 kind: Service metadata: name: "{{ template "harbor.trivy" . }}" - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} labels: {{ include "harbor.labels" . | indent 4 }} spec: diff --git a/templates/trivy/trivy-tls.yaml b/templates/trivy/trivy-tls.yaml index 58bce4ec5..5f9a16ee8 100644 --- a/templates/trivy/trivy-tls.yaml +++ b/templates/trivy/trivy-tls.yaml @@ -4,7 +4,7 @@ apiVersion: v1 kind: Secret metadata: name: "{{ template "harbor.internalTLS.trivy.secretName" . }}" - namespace: {{ .Release.Namespace | quote }} + namespace: {{ include "harbor.namespace" . | quote }} labels: {{ include "harbor.labels" . | indent 4 }} type: kubernetes.io/tls diff --git a/values.yaml b/values.yaml index c862337d0..8679a56d2 100644 --- a/values.yaml +++ b/values.yaml @@ -111,6 +111,12 @@ expose: # If Harbor is deployed behind the proxy, set it as the URL of proxy externalURL: https://core.harbor.domain +# Overrides namespace for helm templates explicitly +# Optional, if you don't specified, will use "default" when running "helm templates" +# Also No need to specifiy this while you install directly and changing the namespace like "helm install ... -n " +# helm known issue: https://github.com/helm/helm/issues/3553 +namespaceOverride: "mynamespaces" + # The persistence is enabled by default and a default StorageClass # is needed in the k8s cluster to provision volumes dynamically. # Specify another StorageClass in the "storageClass" or set "existingClaim"