Skip to content

Commit

Permalink
Include optional namespace in keycloak-operator templates
Browse files Browse the repository at this point in the history
  • Loading branch information
Gwydion Martin committed Jun 14, 2024
1 parent 9bc692d commit d5737e6
Show file tree
Hide file tree
Showing 13 changed files with 116 additions and 78 deletions.
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
126 changes: 64 additions & 62 deletions charts/keycloak-operator/README.md

Large diffs are not rendered by default.

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
Expand Up @@ -7,6 +7,9 @@ apiVersion: k8s.keycloak.org/v2alpha1
kind: KeycloakRealmImport
metadata:
name: {{ $fullname }}-{{ .realm }}
{{- with .Values.keycloak.namespace }}
namespace: {{ . }}
{{- end }}
labels:
{{- $labels | nindent 4 }}
spec:
Expand Down
6 changes: 6 additions & 0 deletions charts/keycloak-operator/templates/operator/clusterrole.yaml
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 }}
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 }}
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 }}
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
20 changes: 10 additions & 10 deletions charts/keycloak-operator/tests/__snapshot__/default_test.yaml.snap
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 @@ -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

0 comments on commit d5737e6

Please sign in to comment.