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

Include optional namespace in keycloak-operator templates #1274

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions charts/keycloak-operator/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: keycloak-operator
description: Deploy Keycloak Operator and Keycloak
type: application
version: 1.2.0
version: 1.3.0
appVersion: "24.0.4"
icon: https://www.keycloak.org/resources/images/logo-stacked.svg
home: https://www.keycloak.org
Expand All @@ -16,7 +16,7 @@ maintainers:
annotations:
artifacthub.io/changes: |
- kind: changed
description: "New feature: disable Operator templates generation"
description: "New feature: customise namespace"
links:
- name: "Issue 1270"
url: https://github.com/adfinis/helm-charts/issues/1270
- name: "Issue 1273"
url: https://github.com/adfinis/helm-charts/issues/1273
2 changes: 1 addition & 1 deletion charts/keycloak-operator/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions charts/keycloak-operator/templates/keycloak/keycloak.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ apiVersion: k8s.keycloak.org/v2alpha1
kind: Keycloak
metadata:
name: {{ default (include "keycloak-operator.fullname" .) .Values.keycloak.name }}
{{- with .Values.keycloak.namespace }}
namespace: {{ . }}
{{- end }}
labels:
{{- include "keycloak-operator.labels" . | nindent 4 }}
app.kubernetes.io/component: keycloak
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
{{- if .Values.keycloak.realmimport.enabled }}
{{- $fullname := include "keycloak-operator.fullname" . }}
{{- $labels := include "keycloak-operator.labels" . }}
{{- $namespace := .Values.keycloak.namespace }}
{{- range .Values.keycloak.realmimport.realms }}
---
apiVersion: k8s.keycloak.org/v2alpha1
kind: KeycloakRealmImport
metadata:
name: {{ $fullname }}-{{ .realm }}
{{- with $namespace }}
namespace: {{ . }}
{{- end }}
labels:
{{- $labels | nindent 4 }}
spec:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: keycloakcontroller-cluster-role
{{- with .Values.operator.namespace }}
namespace: {{ . }}
{{- end }}
Comment on lines +6 to +8
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ClusterRoles are not namespaced, so this is not required here.

Suggested change
{{- with .Values.operator.namespace }}
namespace: {{ . }}
{{- end }}

labels:
{{- include "keycloak-operator.operator.labels" . | nindent 4 }}
rules:
Expand All @@ -25,6 +28,9 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: keycloakrealmimportcontroller-cluster-role
{{- with .Values.operator.namespace }}
namespace: {{ . }}
{{- end }}
Comment on lines +31 to +33
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ClusterRoles are not namespaced, so this is not required here.

Suggested change
{{- with .Values.operator.namespace }}
namespace: {{ . }}
{{- end }}

labels:
{{- include "keycloak-operator.operator.labels" . | nindent 4 }}
rules:
Expand Down
3 changes: 3 additions & 0 deletions charts/keycloak-operator/templates/operator/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "keycloak-operator.operator.fullname" . }}
{{- with .Values.operator.namespace }}
namespace: {{ . }}
{{- end }}
Comment on lines +6 to +8
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it also required that you can deploy the operator in another namespace the the one the Helm chart is being deployed into?
I can fully understand that you would want this for the keycloak instances, but the operator would be deployed in a central namespace right?

labels:
{{- include "keycloak-operator.operator.labels" . | nindent 4 }}
spec:
Expand Down
12 changes: 12 additions & 0 deletions charts/keycloak-operator/templates/operator/rolebinding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: keycloak-operator-role-binding
{{- with .Values.operator.namespace }}
namespace: {{ . }}
{{- end }}
labels:
{{- include "keycloak-operator.operator.labels" . | nindent 4 }}
roleRef:
Expand All @@ -17,6 +20,9 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: keycloak-operator-view
{{- with .Values.operator.namespace }}
namespace: {{ . }}
{{- end }}
labels:
{{- include "keycloak-operator.operator.labels" . | nindent 4 }}
roleRef:
Expand All @@ -31,6 +37,9 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: keycloakcontroller-role-binding
{{- with .Values.operator.namespace }}
namespace: {{ . }}
{{- end }}
labels:
{{- include "keycloak-operator.operator.labels" . | nindent 4 }}
roleRef:
Expand All @@ -45,6 +54,9 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: keycloakrealmimportcontroller-role-binding
{{- with .Values.operator.namespace }}
namespace: {{ . }}
{{- end }}
labels:
{{- include "keycloak-operator.operator.labels" . | nindent 4 }}
roleRef:
Expand Down
3 changes: 3 additions & 0 deletions charts/keycloak-operator/templates/operator/roles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ kind: Role
metadata:
# TODO: figure out how to replace rolename with {{ include "keycloak-operator.operator.fullname" . }}
name: keycloak-operator-role
{{- with .Values.operator.namespace }}
namespace: {{ . }}
{{- end }}
labels:
{{- include "keycloak-operator.operator.labels" . | nindent 4 }}
rules:
Expand Down
3 changes: 3 additions & 0 deletions charts/keycloak-operator/templates/operator/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ apiVersion: v1
kind: Service
metadata:
name: {{ include "keycloak-operator.operator.fullname" . }}
{{- with .Values.operator.namespace }}
namespace: {{ . }}
{{- end }}
labels:
{{- include "keycloak-operator.operator.labels" . | nindent 4 }}
spec:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "keycloak-operator.operator.serviceAccountName" . }}
{{- with .Values.operator.namespace }}
namespace: {{ . }}
{{- end }}
labels:
{{- include "keycloak-operator.operator.labels" . | nindent 4 }}
{{- with .Values.operator.serviceAccount.annotations }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ should match snapshot:
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: keycloak-operator
app.kubernetes.io/version: 24.0.4
helm.sh/chart: keycloak-operator-1.2.0
helm.sh/chart: keycloak-operator-1.3.0
name: keycloakcontroller-cluster-role
rules:
- apiGroups:
Expand All @@ -36,7 +36,7 @@ should match snapshot:
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: keycloak-operator
app.kubernetes.io/version: 24.0.4
helm.sh/chart: keycloak-operator-1.2.0
helm.sh/chart: keycloak-operator-1.3.0
name: keycloakrealmimportcontroller-cluster-role
rules:
- apiGroups:
Expand All @@ -63,7 +63,7 @@ should match snapshot:
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: keycloak-operator
app.kubernetes.io/version: 24.0.4
helm.sh/chart: keycloak-operator-1.2.0
helm.sh/chart: keycloak-operator-1.3.0
name: RELEASE-NAME-keycloak-operator-operator
spec:
replicas: 1
Expand Down Expand Up @@ -128,7 +128,7 @@ should match snapshot:
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: keycloak-operator
app.kubernetes.io/version: 24.0.4
helm.sh/chart: keycloak-operator-1.2.0
helm.sh/chart: keycloak-operator-1.3.0
name: keycloak-operator-role-binding
roleRef:
apiGroup: rbac.authorization.k8s.io
Expand All @@ -147,7 +147,7 @@ should match snapshot:
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: keycloak-operator
app.kubernetes.io/version: 24.0.4
helm.sh/chart: keycloak-operator-1.2.0
helm.sh/chart: keycloak-operator-1.3.0
name: keycloak-operator-view
roleRef:
apiGroup: rbac.authorization.k8s.io
Expand All @@ -166,7 +166,7 @@ should match snapshot:
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: keycloak-operator
app.kubernetes.io/version: 24.0.4
helm.sh/chart: keycloak-operator-1.2.0
helm.sh/chart: keycloak-operator-1.3.0
name: keycloakcontroller-role-binding
roleRef:
apiGroup: rbac.authorization.k8s.io
Expand All @@ -185,7 +185,7 @@ should match snapshot:
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: keycloak-operator
app.kubernetes.io/version: 24.0.4
helm.sh/chart: keycloak-operator-1.2.0
helm.sh/chart: keycloak-operator-1.3.0
name: keycloakrealmimportcontroller-role-binding
roleRef:
apiGroup: rbac.authorization.k8s.io
Expand All @@ -204,7 +204,7 @@ should match snapshot:
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: keycloak-operator
app.kubernetes.io/version: 24.0.4
helm.sh/chart: keycloak-operator-1.2.0
helm.sh/chart: keycloak-operator-1.3.0
name: keycloak-operator-role
rules:
- apiGroups:
Expand Down Expand Up @@ -267,7 +267,7 @@ should match snapshot:
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: keycloak-operator
app.kubernetes.io/version: 24.0.4
helm.sh/chart: keycloak-operator-1.2.0
helm.sh/chart: keycloak-operator-1.3.0
name: RELEASE-NAME-keycloak-operator-operator
spec:
ports:
Expand All @@ -290,5 +290,5 @@ should match snapshot:
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: keycloak-operator
app.kubernetes.io/version: 24.0.4
helm.sh/chart: keycloak-operator-1.2.0
helm.sh/chart: keycloak-operator-1.3.0
name: RELEASE-NAME-keycloak-operator
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ should match snapshot:
app.kubernetes.io/component: keycloak
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/version: 24.0.4
helm.sh/chart: keycloak-operator-1.2.0
helm.sh/chart: keycloak-operator-1.3.0
name: keycloak
spec:
features:
Expand Down Expand Up @@ -35,7 +35,7 @@ should match snapshot:
labels:
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/version: 24.0.4
helm.sh/chart: keycloak-operator-1.2.0
helm.sh/chart: keycloak-operator-1.3.0
name: RELEASE-NAME-keycloak-operator-test
spec:
keycloakCRName: keycloak
Expand Down