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

Update community-operator chart to support having a namespace override #277

Closed
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
6 changes: 3 additions & 3 deletions charts/community-operator/templates/database_roles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
- ""
Expand All @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion charts/community-operator/templates/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions charts/community-operator/templates/operator_namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{{- if .Values.operator.namespaceOverride }}
apiVersion: v1
kind: Namespace
metadata:
name: {{ .Values.operator.namespaceOverride }}
{{- end }}
8 changes: 4 additions & 4 deletions charts/community-operator/templates/operator_roles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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 }}
Expand Down
4 changes: 4 additions & 0 deletions charts/community-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down