From a07569d02c5f9cceb36b57fd8e4d4418865ed197 Mon Sep 17 00:00:00 2001 From: Mihail Radkov Date: Mon, 22 Apr 2024 10:13:26 +0300 Subject: [PATCH] Added `namespaceOverride` for overriding the deployment namespace for all resources in case of multi-namespace deployment --- CHANGELOG.md | 1 + templates/_helpers.tpl | 6 ++++-- templates/_labels.tpl | 7 +++++++ templates/graphdb/configmap-properties.yaml | 1 + templates/graphdb/configmap-settings.yaml | 1 + templates/graphdb/configmap.yaml | 1 + templates/graphdb/pdb.yaml | 1 + templates/graphdb/secret-users.yaml | 1 + templates/graphdb/service-headless.yaml | 1 + templates/graphdb/service.yaml | 1 + templates/graphdb/serviceaccount.yaml | 1 + templates/graphdb/statefulset.yaml | 1 + templates/ingress.yaml | 1 + templates/jobs/configmap-cluster-config.yaml | 1 + templates/jobs/configmap-utils.yaml | 1 + templates/jobs/job-create-cluster.yaml | 1 + templates/jobs/job-patch-cluster.yaml | 1 + templates/jobs/job-provision-repositories.yaml | 1 + templates/jobs/job-scale-down-cluster.yaml | 1 + templates/jobs/job-scale-up-cluster.yaml | 1 + templates/jobs/secret-provision-user.yaml | 1 + templates/proxy/configmap-properties.yaml | 1 + templates/proxy/configmap.yaml | 1 + templates/proxy/service-headless.yaml | 1 + templates/proxy/service.yaml | 1 + templates/proxy/statefulset.yaml | 1 + values.yaml | 5 +++++ 27 files changed, 40 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d6719fc..bcbf3b2c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -77,6 +77,7 @@ TODO: decide how detailed we want this to be - Added new proxy configurations `proxy.command` and `proxy.args` that override the default container entrypoint and command, use for troubleshooting - Added new `global.clusterDomain` for reconfiguring the default Kubernetes cluster domain suffix in case it is different than `cluster.local` - Added `cluster.existingConfigmapKey` to specify a custom configmap key if needed +- Added `namespaceOverride` for overriding the deployment namespace for all resources in case of multi-namespace deployment ### Updates diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl index 750deaef..87d73f39 100644 --- a/templates/_helpers.tpl +++ b/templates/_helpers.tpl @@ -31,11 +31,12 @@ Renders the gRPC address of each GraphDB node that is part of the cluster as a J {{- define "graphdb.cluster.nodes.json" -}} {{- $pod_name := include "graphdb.fullname" . -}} {{- $service_name := include "graphdb.fullname.service.headless" . -}} + {{- $namespace := include "graphdb.namespace" . -}} {{- $cluster_domain := .Values.global.clusterDomain -}} {{- $service_rpc_port := .Values.headlessService.ports.rpc -}} {{- $nodes := list -}} {{- range $i, $node_index := until (int .Values.replicas) -}} - {{- $nodes = append $nodes (printf "%s-%s.%s.%s.svc.%s:%s" $pod_name (toString $node_index) $service_name $.Release.Namespace $cluster_domain (toString $service_rpc_port)) -}} + {{- $nodes = append $nodes (printf "%s-%s.%s.%s.svc.%s:%s" $pod_name (toString $node_index) $service_name $namespace $cluster_domain (toString $service_rpc_port)) -}} {{- end -}} {{- toPrettyJson $nodes -}} {{- end -}} @@ -46,10 +47,11 @@ Renders the HTTP address of each GraphDB node that is part of the cluster, joine {{- define "graphdb-proxy.cluster.nodes" -}} {{- $pod_name := include "graphdb.fullname" . -}} {{- $service_name := include "graphdb.fullname.service.headless" . -}} + {{- $namespace := include "graphdb.namespace" . -}} {{- $cluster_domain := .Values.global.clusterDomain -}} {{- $service_http_port := .Values.headlessService.ports.http -}} {{- range $i, $node_index := until (int .Values.replicas) -}} - http://{{ $pod_name }}-{{ $node_index }}.{{ $service_name }}.{{ $.Release.Namespace }}.svc.{{ $cluster_domain }}:{{ $service_http_port }} + http://{{ $pod_name }}-{{ $node_index }}.{{ $service_name }}.{{ $namespace }}.svc.{{ $cluster_domain }}:{{ $service_http_port }} {{- if gt (sub (int $.Values.replicas) 1 ) $node_index -}} {{- ", " -}} {{- end -}} diff --git a/templates/_labels.tpl b/templates/_labels.tpl index 45a8c7ce..a1ff7268 100644 --- a/templates/_labels.tpl +++ b/templates/_labels.tpl @@ -63,3 +63,10 @@ Create the name of the service account to use {{- default "default" .Values.serviceAccount.name }} {{- end }} {{- end }} + +{{/* +Returns the namespace of the release. +*/}} +{{- define "graphdb.namespace" -}} +{{- default .Release.Namespace .Values.namespaceOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/templates/graphdb/configmap-properties.yaml b/templates/graphdb/configmap-properties.yaml index d780cf7b..c2819604 100644 --- a/templates/graphdb/configmap-properties.yaml +++ b/templates/graphdb/configmap-properties.yaml @@ -2,6 +2,7 @@ apiVersion: v1 kind: ConfigMap metadata: name: {{ include "graphdb.fullname.configmap.properties" . }} + namespace: {{ include "graphdb.namespace" . }} labels: {{- include "graphdb.labels" . | nindent 4 }} {{- with .Values.annotations }} diff --git a/templates/graphdb/configmap-settings.yaml b/templates/graphdb/configmap-settings.yaml index ceb83d85..eae047b0 100644 --- a/templates/graphdb/configmap-settings.yaml +++ b/templates/graphdb/configmap-settings.yaml @@ -3,6 +3,7 @@ apiVersion: v1 kind: ConfigMap metadata: name: {{ include "graphdb.fullname.configmap.settings" . }} + namespace: {{ include "graphdb.namespace" . }} labels: {{- include "graphdb.labels" . | nindent 4 }} {{- with .Values.annotations }} diff --git a/templates/graphdb/configmap.yaml b/templates/graphdb/configmap.yaml index d73d2de9..8232c3b8 100644 --- a/templates/graphdb/configmap.yaml +++ b/templates/graphdb/configmap.yaml @@ -2,6 +2,7 @@ apiVersion: v1 kind: ConfigMap metadata: name: {{ include "graphdb.fullname" . }} + namespace: {{ include "graphdb.namespace" . }} labels: {{- include "graphdb.labels" . | nindent 4 }} {{- with .Values.annotations }} diff --git a/templates/graphdb/pdb.yaml b/templates/graphdb/pdb.yaml index 8690ee06..a0e43e7f 100644 --- a/templates/graphdb/pdb.yaml +++ b/templates/graphdb/pdb.yaml @@ -3,6 +3,7 @@ apiVersion: policy/v1 kind: PodDisruptionBudget metadata: name: {{ include "graphdb.fullname" . }} + namespace: {{ include "graphdb.namespace" . }} labels: {{- include "graphdb.labels" . | nindent 4 }} {{- with .Values.annotations }} diff --git a/templates/graphdb/secret-users.yaml b/templates/graphdb/secret-users.yaml index 78556508..532e0dd8 100644 --- a/templates/graphdb/secret-users.yaml +++ b/templates/graphdb/secret-users.yaml @@ -3,6 +3,7 @@ apiVersion: v1 kind: Secret metadata: name: {{ include "graphdb.fullname.secret.users" . }} + namespace: {{ include "graphdb.namespace" . }} labels: {{- include "graphdb.labels" . | nindent 4 }} {{- with .Values.annotations }} diff --git a/templates/graphdb/service-headless.yaml b/templates/graphdb/service-headless.yaml index 90696d80..389e87be 100644 --- a/templates/graphdb/service-headless.yaml +++ b/templates/graphdb/service-headless.yaml @@ -3,6 +3,7 @@ apiVersion: v1 kind: Service metadata: name: {{ include "graphdb.fullname.service.headless" . }} + namespace: {{ include "graphdb.namespace" . }} labels: {{- include "graphdb.labels" . | nindent 4 }} {{- with .Values.headlessService.labels }} diff --git a/templates/graphdb/service.yaml b/templates/graphdb/service.yaml index 93ce1db1..b0557e26 100644 --- a/templates/graphdb/service.yaml +++ b/templates/graphdb/service.yaml @@ -3,6 +3,7 @@ apiVersion: v1 kind: Service metadata: name: {{ include "graphdb.fullname" . }} + namespace: {{ include "graphdb.namespace" . }} labels: {{- include "graphdb.labels" . | nindent 4 }} {{- with .Values.service.labels }} diff --git a/templates/graphdb/serviceaccount.yaml b/templates/graphdb/serviceaccount.yaml index 6b64dd81..0b5d0ed4 100644 --- a/templates/graphdb/serviceaccount.yaml +++ b/templates/graphdb/serviceaccount.yaml @@ -3,6 +3,7 @@ apiVersion: v1 kind: ServiceAccount metadata: name: {{ include "graphdb.serviceAccountName" . }} + namespace: {{ include "graphdb.namespace" . }} labels: {{- include "graphdb.labels" . | nindent 4 }} {{- with (mergeOverwrite (deepCopy .Values.annotations) .Values.serviceAccount.annotations) }} diff --git a/templates/graphdb/statefulset.yaml b/templates/graphdb/statefulset.yaml index 6c479670..4af08eab 100644 --- a/templates/graphdb/statefulset.yaml +++ b/templates/graphdb/statefulset.yaml @@ -2,6 +2,7 @@ apiVersion: apps/v1 kind: StatefulSet metadata: name: {{ include "graphdb.fullname" . }} + namespace: {{ include "graphdb.namespace" . }} labels: {{- include "graphdb.labels" . | nindent 4 }} {{- with .Values.annotations }} diff --git a/templates/ingress.yaml b/templates/ingress.yaml index 27e1aa51..8def632e 100644 --- a/templates/ingress.yaml +++ b/templates/ingress.yaml @@ -4,6 +4,7 @@ apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: {{ include "graphdb.fullname" . }} + namespace: {{ include "graphdb.namespace" . }} labels: {{- include "graphdb.labels" . | nindent 4 }} {{- with .Values.ingress.labels }} diff --git a/templates/jobs/configmap-cluster-config.yaml b/templates/jobs/configmap-cluster-config.yaml index 995b5a44..01c75996 100644 --- a/templates/jobs/configmap-cluster-config.yaml +++ b/templates/jobs/configmap-cluster-config.yaml @@ -5,6 +5,7 @@ apiVersion: v1 kind: ConfigMap metadata: name: {{ include "graphdb.fullname.configmap.cluster" . }} + namespace: {{ include "graphdb.namespace" . }} labels: {{- include "graphdb.labels" . | nindent 4 }} {{- with .Values.annotations }} diff --git a/templates/jobs/configmap-utils.yaml b/templates/jobs/configmap-utils.yaml index 79e2d899..02cc9f7a 100644 --- a/templates/jobs/configmap-utils.yaml +++ b/templates/jobs/configmap-utils.yaml @@ -2,6 +2,7 @@ apiVersion: v1 kind: ConfigMap metadata: name: {{ include "graphdb.fullname.configmap.utils" . }} + namespace: {{ include "graphdb.namespace" . }} labels: {{- include "graphdb.labels" . | nindent 4 }} annotations: diff --git a/templates/jobs/job-create-cluster.yaml b/templates/jobs/job-create-cluster.yaml index 70b10665..641dc5f6 100644 --- a/templates/jobs/job-create-cluster.yaml +++ b/templates/jobs/job-create-cluster.yaml @@ -3,6 +3,7 @@ apiVersion: batch/v1 kind: Job metadata: name: {{ include "graphdb.fullname.job.create-cluster" . }} + namespace: {{ include "graphdb.namespace" . }} labels: {{- include "graphdb.labels" . | nindent 4 }} annotations: diff --git a/templates/jobs/job-patch-cluster.yaml b/templates/jobs/job-patch-cluster.yaml index 1dda0c73..71041d30 100644 --- a/templates/jobs/job-patch-cluster.yaml +++ b/templates/jobs/job-patch-cluster.yaml @@ -3,6 +3,7 @@ apiVersion: batch/v1 kind: Job metadata: name: {{ include "graphdb.fullname.job.patch-cluster" . }} + namespace: {{ include "graphdb.namespace" . }} labels: {{- include "graphdb.labels" . | nindent 4 }} annotations: diff --git a/templates/jobs/job-provision-repositories.yaml b/templates/jobs/job-provision-repositories.yaml index d5f3382b..13159b7d 100644 --- a/templates/jobs/job-provision-repositories.yaml +++ b/templates/jobs/job-provision-repositories.yaml @@ -3,6 +3,7 @@ apiVersion: batch/v1 kind: Job metadata: name: {{ include "graphdb.fullname.job.provision-repositories" . }} + namespace: {{ include "graphdb.namespace" . }} labels: {{- include "graphdb.labels" . | nindent 4 }} annotations: diff --git a/templates/jobs/job-scale-down-cluster.yaml b/templates/jobs/job-scale-down-cluster.yaml index 779eee70..2c08a958 100644 --- a/templates/jobs/job-scale-down-cluster.yaml +++ b/templates/jobs/job-scale-down-cluster.yaml @@ -3,6 +3,7 @@ apiVersion: batch/v1 kind: Job metadata: name: {{ include "graphdb.fullname.job.scale-down-cluster" . }} + namespace: {{ include "graphdb.namespace" . }} labels: {{- include "graphdb.labels" . | nindent 4 }} annotations: diff --git a/templates/jobs/job-scale-up-cluster.yaml b/templates/jobs/job-scale-up-cluster.yaml index f0046965..02fd5a1f 100644 --- a/templates/jobs/job-scale-up-cluster.yaml +++ b/templates/jobs/job-scale-up-cluster.yaml @@ -3,6 +3,7 @@ apiVersion: batch/v1 kind: Job metadata: name: {{ include "graphdb.fullname.job.scale-up-cluster" . }} + namespace: {{ include "graphdb.namespace" . }} labels: {{- include "graphdb.labels" . | nindent 4 }} annotations: diff --git a/templates/jobs/secret-provision-user.yaml b/templates/jobs/secret-provision-user.yaml index f05ed224..4566391f 100644 --- a/templates/jobs/secret-provision-user.yaml +++ b/templates/jobs/secret-provision-user.yaml @@ -3,6 +3,7 @@ apiVersion: v1 kind: Secret metadata: name: {{ include "graphdb.fullname.secret.provision-user" . }} + namespace: {{ include "graphdb.namespace" . }} labels: {{- include "graphdb.labels" . | nindent 4 }} annotations: diff --git a/templates/proxy/configmap-properties.yaml b/templates/proxy/configmap-properties.yaml index 451a1cc5..01731564 100644 --- a/templates/proxy/configmap-properties.yaml +++ b/templates/proxy/configmap-properties.yaml @@ -3,6 +3,7 @@ apiVersion: v1 kind: ConfigMap metadata: name: {{ include "graphdb-proxy.fullname.configmap.properties" . }} + namespace: {{ include "graphdb.namespace" . }} labels: {{- include "graphdb-proxy.labels" . | nindent 4 }} {{- with (mergeOverwrite (deepCopy .Values.annotations) .Values.proxy.annotations) }} diff --git a/templates/proxy/configmap.yaml b/templates/proxy/configmap.yaml index 6b63eb9b..38d782a1 100644 --- a/templates/proxy/configmap.yaml +++ b/templates/proxy/configmap.yaml @@ -3,6 +3,7 @@ apiVersion: v1 kind: ConfigMap metadata: name: {{ include "graphdb-proxy.fullname" . }} + namespace: {{ include "graphdb.namespace" . }} labels: {{- include "graphdb-proxy.labels" . | nindent 4 }} {{- with (mergeOverwrite (deepCopy .Values.annotations) .Values.proxy.annotations) }} diff --git a/templates/proxy/service-headless.yaml b/templates/proxy/service-headless.yaml index 71079749..c9be3bcf 100644 --- a/templates/proxy/service-headless.yaml +++ b/templates/proxy/service-headless.yaml @@ -3,6 +3,7 @@ apiVersion: v1 kind: Service metadata: name: {{ include "graphdb-proxy.fullname.service.headless" . }} + namespace: {{ include "graphdb.namespace" . }} labels: {{- include "graphdb-proxy.labels" . | nindent 4 }} {{- with .Values.proxy.headlessService.labels }} diff --git a/templates/proxy/service.yaml b/templates/proxy/service.yaml index acfc51c2..816d3ce4 100644 --- a/templates/proxy/service.yaml +++ b/templates/proxy/service.yaml @@ -3,6 +3,7 @@ apiVersion: v1 kind: Service metadata: name: {{ include "graphdb-proxy.fullname" . }} + namespace: {{ include "graphdb.namespace" . }} labels: {{- include "graphdb-proxy.labels" . | nindent 4 }} {{- with .Values.proxy.service.labels }} diff --git a/templates/proxy/statefulset.yaml b/templates/proxy/statefulset.yaml index ba0891c2..c3211209 100644 --- a/templates/proxy/statefulset.yaml +++ b/templates/proxy/statefulset.yaml @@ -3,6 +3,7 @@ apiVersion: apps/v1 kind: StatefulSet metadata: name: {{ include "graphdb-proxy.fullname" . }} + namespace: {{ include "graphdb.namespace" . }} labels: {{- include "graphdb-proxy.labels" . | nindent 4 }} {{- with (mergeOverwrite (deepCopy .Values.annotations) .Values.proxy.annotations) }} diff --git a/values.yaml b/values.yaml index d9fd0012..b51c51f6 100644 --- a/values.yaml +++ b/values.yaml @@ -30,6 +30,10 @@ nameOverride: "" # To override the GraphDB proxy's full name, use proxy.fullnameOverride fullnameOverride: "" +# Overrides the deployment namespace in case of multi-namespace deployments in umbrella charts. +# The default is .Release.Namespace +namespaceOverride: "" + # Additional common labels to add to all resources labels: {} @@ -427,6 +431,7 @@ import: repositories: # Optional configmap containing repository configuration ttl file(s). # GraphDB will automatically create repositories with the provided repositories configuration files + # Each key in the existing configmap will be treated as the config.ttl of a repository repositoriesConfigmap: "" ######################################################################################