Skip to content

Commit

Permalink
K8SPXC-1365 - pxc-operator - Fix watchNamespace
Browse files Browse the repository at this point in the history
  • Loading branch information
tplavcic committed Mar 12, 2024
1 parent e8fd87c commit 38966fa
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion charts/pxc-operator/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ appVersion: 1.14.0
description: A Helm chart for deploying the Percona Operator for MySQL (based on Percona XtraDB Cluster)
name: pxc-operator
home: https://docs.percona.com/percona-operator-for-mysql/pxc/
version: 1.14.0
version: 1.14.1
maintainers:
- name: tplavcic
email: [email protected]
Expand Down
2 changes: 2 additions & 0 deletions charts/pxc-operator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ The chart can be customized using the following configurable parameters:
| `logStructured` | Force PXC operator to print JSON-wrapped log messages | `false` |
| `logLevel` | PXC Operator logging level | `INFO` |
| `disableTelemetry` | Disable sending PXC Operator telemetry data to Percona | `false` |
| `watchNamespace` | Set when a different from default namespace is needed to watch (comma separated if multiple needed) | `""` |
| `createNamespace` | Set if you want to create watched namespaces with helm | `false` |
| `rbac.create` | If false RBAC will not be created. RBAC resources will need to be created manually | `true` |
| `serviceAccount.create` | If false the ServiceAccounts will not be created. The ServiceAccounts must be created manually | `true` |
| `extraEnvVars` | Custom pod environment variables | `[]` |
Expand Down
7 changes: 5 additions & 2 deletions charts/pxc-operator/templates/namespace.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
{{ if .Values.watchNamespace }}
{{ if and .Values.watchNamespace .Values.createNamespace }}
{{ range ( split "," .Values.watchNamespace ) }}
apiVersion: v1
kind: Namespace
metadata:
name: {{ .Values.watchNamespace }}
name: {{ trim . }}
annotations:
helm.sh/resource-policy: keep
---
{{ end }}
{{ end }}
4 changes: 1 addition & 3 deletions charts/pxc-operator/templates/role-binding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ include "pxc-operator.fullname" . }}
{{- if .Values.watchNamespace }}
namespace: {{ .Values.watchNamespace }}
{{- else if not .Values.watchAllNamespaces }}
{{- if not (or .Values.watchNamespace .Values.watchAllNamespaces) }}
namespace: {{ .Release.Namespace }}
{{- end }}
labels:
Expand Down
2 changes: 2 additions & 0 deletions charts/pxc-operator/templates/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ include "pxc-operator.fullname" . }}
{{- if not (or .Values.watchNamespace .Values.watchAllNamespaces) }}
namespace: {{ .Release.Namespace }}
{{- end }}
labels:
{{ include "pxc-operator.labels" . | indent 4 }}
rules:
Expand Down
3 changes: 3 additions & 0 deletions charts/pxc-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ image: ""

# set if you want to specify a namespace to watch
# defaults to `.Release.namespace` if left blank
# multiple namespaces can be specified and separated by comma
# watchNamespace:
# set if you want that watched namespaces are created by helm
# createNamespace: false

# set if operator should be deployed in cluster wide mode. defaults to false
watchAllNamespaces: false
Expand Down

0 comments on commit 38966fa

Please sign in to comment.