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

Added Keycloak Chart #1

Open
wants to merge 20 commits into
base: master
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
4 changes: 2 additions & 2 deletions charts/custom-catalogs/templates/subscriptions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ metadata:
{{- if .sameNamespace }}
spec:
targetNamespaces:
- {{ .installNamespace }}
- {{ .installNamespace }}
{{- else }}
spec: {}
{{- end }}
Expand Down Expand Up @@ -47,7 +47,7 @@ metadata:
name: {{ .name }}
namespace: {{ default "olm" .installNamespace }}
spec:
channel: {{ default "stable" .operatorChannel }}
channel: {{ default "stable" .channel }}
name: {{ .name }}
source: {{ .source }}
sourceNamespace: {{ .sourceNamespace }}
Expand Down
21 changes: 21 additions & 0 deletions charts/keycloak/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
5 changes: 5 additions & 0 deletions charts/keycloak/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v2
description: |
A chart to manage various keycloak ressources
name: keycloak
version: 0.0.0-dev
30 changes: 30 additions & 0 deletions charts/keycloak/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# keycloak

A chart to manage various keycloak ressources

![Version: 0.0.0-dev](https://img.shields.io/badge/Version-0.0.0--dev-informational?style=flat-square)

## Values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| clients | list | `[]` | Watch [Value file](values.yaml) for examples. |
| ingress.annotations | object | `{}` | Ingress annotations |
| ingress.className | string | `""` | Ingress class name |
| ingress.enabled | bool | `false` | Enable Keycloak ingress |
| ingress.hosts[0] | object | `{"host":"keycloak.danstonkube.fr","paths":[{"path":"/","pathType":"Prefix"}]}` | Ingress hostname |
| ingress.hosts[0].paths[0] | object | `{"path":"/","pathType":"Prefix"}` | Ingress path |
| ingress.hosts[0].paths[0].pathType | string | `"Prefix"` | Ingress path type can be either : `Prefix`, `ImplementationSpecific` or `Exact`, watch [Official Documentation for more informations](https://kubernetes.io/docs/concepts/services-networking/ingress/#examples) |
| ingress.tls | list | `[]` | |
| keycloakConfig.instances | int | `1` | Keycloak instance replicas |
| keycloakConfig.labels | object | `{"mylabel":"label1"}` | Keycloak instance labels |
| keycloakConfig.name | string | `"dtk"` | Keycloak instance name |
| keycloakConfig.storageClassName | string | `"local"` | Keycloak instance storage class |
| nameOverride | string | `""` | Override chart default name |
| realms | list | `[]` | Watch [Value file](values.yaml) for examples. |
| service.name | string | `"keycloak-discovery"` | |
| service.port | int | `8080` | |
| users | list | `[]` | Watch [Value file](values.yaml) for examples. |

----------------------------------------------
Autogenerated from chart metadata using [helm-docs v1.11.0](https://github.com/norwoodj/helm-docs/releases/v1.11.0) `docker run --rm --volume "$(pwd):/helm-docs" jnorwood/helm-docs:latest`.
9 changes: 9 additions & 0 deletions charts/keycloak/README.md.gotmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{{ template "chart.header" . }}
{{ template "chart.description" . }}
{{ template "chart.badgesSection" . }}

## Values

{{ template "chart.valuesTable" . }}

{{ template "helm-docs.versionFooter" . }} `docker run --rm --volume "$(pwd):/helm-docs" jnorwood/helm-docs:latest`.
16 changes: 16 additions & 0 deletions charts/keycloak/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Custom catalogs
*/}}
{{- define "name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "fullname" -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
17 changes: 17 additions & 0 deletions charts/keycloak/templates/clients.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{- range .Values.clients }}
---
apiVersion: keycloak.org/v1alpha1
kind: KeycloakClient
metadata:
name: {{ .name }}
labels: {{ .labels | toYaml | nindent 4 }}
spec:
realmSelector:
matchLabels: {{ .matchLabels | toYaml | nindent 12 }}
client:
clientId: {{ .clientId }}
secret: {{ .secret }}
{{- range $key, $val := .additionalConfig }}
{{ $key }}: {{ $val }}
{{- end }}
{{- end }}
59 changes: 59 additions & 0 deletions charts/keycloak/templates/ingress.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{{- if .Values.ingress.enabled -}}
{{- $svcPort := .Values.service.port -}}
{{- $svcName := .Values.service.name -}}
{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}}
{{- end }}
{{- end }}
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ .Values.keycloakConfig.name }}-ingress
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.ingress.className }}
{{- end }}
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ .host }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
{{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
pathType: {{ .pathType }}
{{- end }}
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ $svcName }}
port:
number: {{ $svcPort }}
{{- else }}
serviceName: {{ $svcName }}
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
10 changes: 10 additions & 0 deletions charts/keycloak/templates/keycloak_instance.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: keycloak.org/v1alpha1
kind: Keycloak
metadata:
name: {{ .Values.keycloakConfig.name }}
labels: {{ .Values.keycloakConfig.labels | toYaml | nindent 4 }}
spec:
instances: {{ .Values.keycloakConfig.instances }}
externalAccess:
enabled: false
storageClassName: {{ .Values.keycloakConfig.storageClassName }}
16 changes: 16 additions & 0 deletions charts/keycloak/templates/realms.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{- range .Values.realms }}
---
apiVersion: keycloak.org/v1alpha1
kind: KeycloakRealm
metadata:
name: {{ .name }}
labels: {{ .labels | toYaml | nindent 4 }}
spec:
realm:
id: {{ .id }}
realm: {{ .realmName }}
enabled: {{ .enabled }}
displayName: {{ .displayName }}
instanceSelector:
matchLabels: {{ .matchLabels | toYaml | nindent 12 }}
{{- end }}
26 changes: 26 additions & 0 deletions charts/keycloak/templates/users.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{{- range .Values.users }}
---
apiVersion: keycloak.org/v1alpha1
kind: KeycloakUser
metadata:
name: {{ .name }}
labels: {{ .labels | toYaml | nindent 4 }}
spec:
user:
username: {{ .username }}
email: {{ .email }}
enabled: {{ .enabled }}
emailVerified: {{ .emailVerified }}
firstName: {{ .firstName }}
lastName: {{ .lastName }}
credentials:
{{- if .password }}
- type: password
value: {{ .password.value }}
temporary: {{ .password.temporary }}
{{- end }}
{{- if .otp }}
- type: otp
value: {{ .otp.value }}
{{- end }}
{{- end }}
76 changes: 76 additions & 0 deletions charts/keycloak/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
# -- Override chart default name
nameOverride: ""

keycloakConfig:
# -- Keycloak instance name
name: dtk
# -- Keycloak instance labels
labels:
mylabel: label1
# -- Keycloak instance replicas
instances: 1
# -- Keycloak instance storage class
storageClassName: local

service:
name: keycloak-discovery
port: 8080

ingress:
# -- Enable Keycloak ingress
enabled: false
# -- Ingress annotations
annotations: {}
# -- Ingress class name
className: ""
hosts:
# -- Ingress hostname
- host: keycloak.danstonkube.fr
paths:
# -- Ingress path
- path: /
# -- Ingress path type can be either : `Prefix`, `ImplementationSpecific` or `Exact`, watch [Official Documentation for more informations](https://kubernetes.io/docs/concepts/services-networking/ingress/#examples)
pathType: Prefix
tls: []

# -- Watch [Value file](values.yaml) for examples.
users: []
# - name: passepartout
# labels:
# mylabel: label1
# username: passepartout
# email: [email protected]
# enabled: true
# emailVerified: true
# firstName: Passe
# lastName: Partout
# password:
# value: changeme
# temporary: true
# otp:
# value: 92192190

# -- Watch [Value file](values.yaml) for examples.
realms: []
# - name: passepartout
# labels:
# mylabel: label1
# id: dtk
# realmName: dtk
# enabled: true
# displayName: Dans ton kube
# matchLabels:
# mylabeltomatch: dtk

# -- Watch [Value file](values.yaml) for examples.
clients: []
# - name: passepartout
# labels:
# mylabel: label1
# clientId: dtk
# secret: dtk-secret
# additionalConfig:
# protocol: https
# matchLabels:
# realm: dtk
55 changes: 55 additions & 0 deletions cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -920,6 +920,61 @@ Traefik is an open-source Edge Router that makes publishing your services a fun

### Security

#### Keycloak

| Key | Type | Default | Description |
|-----|------|---------|-------------|

##### Adding realms

```yaml
realms:
- name: passepartout
labels:
mylabel: label1
id: dtk
realmName: dtk
enabled: true
displayName: Dans ton kube
matchLabels:
mylabeltomatch: dtk
```

##### Adding clients

```yaml
clients:
- name: passepartout
labels:
mylabel: label1
clientId: dtk
secret: dtk-secret
additionalConfig:
protocol: https
matchLabels:
realm: dtk
```

##### Adding users

```yaml
users:
- name: passepartout
labels:
mylabel: label1
username: passepartout
email: [email protected]
enabled: true
emailVerified: true
firstName: Passe
lastName: Partout
password:
value: changeme
temporary: true
otp:
value: 92192190
```

#### User management

User management is a chart hosted on this repository, you can retrieve templates [here](../charts/users/).
Expand Down
Loading