Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add helper for overrides namespace while using helm template #1856

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
{{- default "harbor" .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- 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 -}}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
Expand Down Expand Up @@ -579,3 +586,4 @@ app: "{{ template "harbor.name" . }}"
{{- define "harbor.ingress.kubeVersion" -}}
{{- default .Capabilities.KubeVersion.Version .Values.expose.ingress.kubeVersionOverride -}}
{{- end -}}

2 changes: 1 addition & 1 deletion templates/core/core-cm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion templates/core/core-dpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion templates/core/core-pre-upgrade-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion templates/core/core-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion templates/core/core-svc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion templates/core/core-tls.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion templates/database/database-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion templates/database/database-ss.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion templates/database/database-svc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion templates/exporter/exporter-cm-env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion templates/exporter/exporter-dpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion templates/exporter/exporter-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion templates/exporter/exporter-svc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion templates/ingress/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,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 }}
Expand Down
2 changes: 1 addition & 1 deletion templates/ingress/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions templates/internal/auto-tls.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion templates/jobservice/jobservice-cm-env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion templates/jobservice/jobservice-cm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion templates/jobservice/jobservice-dpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion templates/jobservice/jobservice-pvc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion templates/jobservice/jobservice-secrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion templates/jobservice/jobservice-svc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion templates/jobservice/jobservice-tls.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion templates/metrics/metrics-svcmon.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion templates/nginx/configmap-http.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion templates/nginx/configmap-https.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion templates/nginx/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion templates/nginx/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion templates/nginx/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion templates/portal/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion templates/portal/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion templates/portal/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion templates/portal/tls.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion templates/redis/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion templates/redis/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion templates/registry/registry-cm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion templates/registry/registry-dpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion templates/registry/registry-pvc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
Loading
Loading