diff --git a/charts/community-operator/templates/database_roles.yaml b/charts/community-operator/templates/database_roles.yaml index b5662ff6..1bbe3e95 100644 --- a/charts/community-operator/templates/database_roles.yaml +++ b/charts/community-operator/templates/database_roles.yaml @@ -3,14 +3,14 @@ apiVersion: v1 kind: ServiceAccount metadata: name: {{ .Values.database.name }} - namespace: {{ if .Values.database.namespace }} {{ .Values.database.namespace }} {{ else }} {{ .Release.Namespace }} {{ end }} + namespace: {{ if .Values.database.namespace }} {{ .Values.database.namespace }} {{ else }} {{ default .Release.Namespace .Values.operator.namespaceOverride | trunc 63 | trimSuffix "-" }} {{ end }} --- apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: name: {{ .Values.database.name }} - namespace: {{ if .Values.database.namespace }} {{ .Values.database.namespace }} {{ else }} {{ .Release.Namespace }} {{ end }} + namespace: {{ if .Values.database.namespace }} {{ .Values.database.namespace }} {{ else }} {{ default .Release.Namespace .Values.operator.namespaceOverride | trunc 63 | trimSuffix "-" }} {{ end }} rules: - apiGroups: - "" @@ -32,7 +32,7 @@ kind: RoleBinding apiVersion: rbac.authorization.k8s.io/v1 metadata: name: {{ .Values.database.name }} - namespace: {{ if .Values.database.namespace }} {{ .Values.database.namespace }} {{ else }} {{ .Release.Namespace }} {{ end }} + namespace: {{ if .Values.database.namespace }} {{ .Values.database.namespace }} {{ else }} {{ default .Release.Namespace .Values.operator.namespaceOverride | trunc 63 | trimSuffix "-" }} {{ end }} subjects: - kind: ServiceAccount name: {{ .Values.database.name }} diff --git a/charts/community-operator/templates/operator.yaml b/charts/community-operator/templates/operator.yaml index 15af4014..61fad3f4 100644 --- a/charts/community-operator/templates/operator.yaml +++ b/charts/community-operator/templates/operator.yaml @@ -7,7 +7,7 @@ metadata: labels: owner: mongodb name: {{ .Values.operator.name }} - namespace: {{ .Release.Namespace }} + namespace: {{ default .Release.Namespace .Values.operator.namespaceOverride | trunc 63 | trimSuffix "-" }} spec: replicas: {{ .Values.operator.replicas }} selector: diff --git a/charts/community-operator/templates/operator_namespace.yaml b/charts/community-operator/templates/operator_namespace.yaml new file mode 100644 index 00000000..00fe1283 --- /dev/null +++ b/charts/community-operator/templates/operator_namespace.yaml @@ -0,0 +1,6 @@ +{{- if .Values.operator.namespaceOverride }} +apiVersion: v1 +kind: Namespace +metadata: + name: {{ .Values.operator.namespaceOverride }} +{{- end }} diff --git a/charts/community-operator/templates/operator_roles.yaml b/charts/community-operator/templates/operator_roles.yaml index 0f0988b9..635a49b3 100644 --- a/charts/community-operator/templates/operator_roles.yaml +++ b/charts/community-operator/templates/operator_roles.yaml @@ -3,7 +3,7 @@ apiVersion: v1 kind: ServiceAccount metadata: name: {{ .Values.operator.name }} - namespace: {{ .Release.Namespace }} + namespace: {{ default .Release.Namespace .Values.operator.namespaceOverride | trunc 63 | trimSuffix "-" }} --- apiVersion: rbac.authorization.k8s.io/v1 @@ -13,7 +13,7 @@ metadata: {{- if not (eq (.Values.operator.watchNamespace | default "*") "*") }} namespace: {{ .Values.operator.watchNamespace }} {{- else }} - namespace: {{ .Release.Namespace }} + namespace: {{ default .Release.Namespace .Values.operator.namespaceOverride | trunc 63 | trimSuffix "-" }} {{- end }} rules: - apiGroups: @@ -65,12 +65,12 @@ metadata: {{- if ne (.Values.operator.watchNamespace | default "*") "*" }} namespace: {{ .Values.operator.watchNamespace }} {{- else }} - namespace: {{ .Release.Namespace }} + namespace: {{ default .Release.Namespace .Values.operator.namespaceOverride | trunc 63 | trimSuffix "-" }} {{- end }} subjects: - kind: ServiceAccount name: {{ .Values.operator.name }} - namespace: {{ .Release.Namespace }} + namespace: {{ default .Release.Namespace .Values.operator.namespaceOverride | trunc 63 | trimSuffix "-" }} roleRef: kind: {{ if eq (.Values.operator.watchNamespace | default "") "*" }} ClusterRole {{ else }} Role {{ end }} name: {{ .Values.operator.name }} diff --git a/charts/community-operator/values.yaml b/charts/community-operator/values.yaml index b04749bf..3ebc4d30 100644 --- a/charts/community-operator/values.yaml +++ b/charts/community-operator/values.yaml @@ -8,6 +8,10 @@ operator: # Deployment, ServiceAccount, Role etc. name: mongodb-kubernetes-operator + # Allow the operator namespace to be overridden which is useful when having this operator + # be a subchart dependency + #namespaceOverride: mongodb-solution + # Name of the operator image operatorImageName: mongodb-kubernetes-operator