Skip to content

Commit

Permalink
Added namespaceOverride for overriding the deployment namespace for…
Browse files Browse the repository at this point in the history
… all resources in case of multi-namespace deployment
  • Loading branch information
mihailradkov committed Apr 22, 2024
1 parent 950510d commit a07569d
Show file tree
Hide file tree
Showing 27 changed files with 40 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 4 additions & 2 deletions templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}
Expand All @@ -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 -}}
Expand Down
7 changes: 7 additions & 0 deletions templates/_labels.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}
1 change: 1 addition & 0 deletions templates/graphdb/configmap-properties.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
1 change: 1 addition & 0 deletions templates/graphdb/configmap-settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
1 change: 1 addition & 0 deletions templates/graphdb/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
1 change: 1 addition & 0 deletions templates/graphdb/pdb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
1 change: 1 addition & 0 deletions templates/graphdb/secret-users.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
1 change: 1 addition & 0 deletions templates/graphdb/service-headless.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
1 change: 1 addition & 0 deletions templates/graphdb/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
1 change: 1 addition & 0 deletions templates/graphdb/serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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) }}
Expand Down
1 change: 1 addition & 0 deletions templates/graphdb/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
1 change: 1 addition & 0 deletions templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
1 change: 1 addition & 0 deletions templates/jobs/configmap-cluster-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
1 change: 1 addition & 0 deletions templates/jobs/configmap-utils.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions templates/jobs/job-create-cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions templates/jobs/job-patch-cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions templates/jobs/job-provision-repositories.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions templates/jobs/job-scale-down-cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions templates/jobs/job-scale-up-cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions templates/jobs/secret-provision-user.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions templates/proxy/configmap-properties.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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) }}
Expand Down
1 change: 1 addition & 0 deletions templates/proxy/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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) }}
Expand Down
1 change: 1 addition & 0 deletions templates/proxy/service-headless.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
1 change: 1 addition & 0 deletions templates/proxy/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
1 change: 1 addition & 0 deletions templates/proxy/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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) }}
Expand Down
5 changes: 5 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: {}

Expand Down Expand Up @@ -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: ""

######################################################################################
Expand Down

0 comments on commit a07569d

Please sign in to comment.