-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes - **New Features** - Integrated Keycloak service into deployment configurations across multiple files, enhancing user authentication capabilities. - Introduced a new Helm chart for Keycloak, facilitating easier deployment and management. - Added Kubernetes Ingress and Service resources for Keycloak to manage external access and internal service routing. - Configured a PostgreSQL cluster specifically for Keycloak, ensuring data persistence. - **Bug Fixes** - Updated versioning in the installer script to ensure compatibility with the latest configurations. - **Documentation** - Added detailed configuration options for Keycloak deployment, including resource limits and ingress settings. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
- Loading branch information
Showing
13 changed files
with
256 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
apiVersion: v2 | ||
name: cozy-keycloak | ||
version: 0.0.0 # Placeholder, the actual version will be automatically set during the build process |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
apiVersion: postgresql.cnpg.io/v1 | ||
kind: Cluster | ||
metadata: | ||
name: keycloak-db | ||
spec: | ||
instances: 2 | ||
storage: | ||
size: 20Gi | ||
|
||
inheritedMetadata: | ||
labels: | ||
policy.cozystack.io/allow-to-apiserver: "true" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{{- $cozyConfig := lookup "v1" "ConfigMap" "cozy-system" "cozystack" }} | ||
{{- $host := index $cozyConfig.data "root-host" }} | ||
{{- $issuerType := (index $cozyConfig.data "clusterissuer") | default "http01" }} | ||
|
||
{{- $rootns := lookup "v1" "Namespace" "" "tenant-root" }} | ||
{{- $ingress := index $rootns.metadata.annotations "namespace.cozystack.io/ingress" }} | ||
|
||
apiVersion: networking.k8s.io/v1 | ||
kind: Ingress | ||
metadata: | ||
name: keycloak-ingress | ||
{{- with .Values.ingress.annotations }} | ||
annotations: | ||
{{- if ne $issuerType "cloudflare" }} | ||
acme.cert-manager.io/http01-ingress-class: {{ $ingress }} | ||
{{- end }} | ||
cert-manager.io/cluster-issuer: letsencrypt-prod | ||
{{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
spec: | ||
ingressClassName: {{ $ingress }} | ||
tls: | ||
- hosts: | ||
- keycloak.{{ $host }} | ||
secretName: web-tls | ||
rules: | ||
- host: keycloak.{{ $host }} | ||
http: | ||
paths: | ||
- path: / | ||
pathType: Prefix | ||
backend: | ||
service: | ||
name: keycloak-http | ||
port: | ||
name: http |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: keycloak-headless | ||
spec: | ||
type: ClusterIP | ||
clusterIP: None | ||
selector: | ||
app: keycloak-ha |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: keycloak-http | ||
spec: | ||
type: ClusterIP | ||
ports: | ||
- name: http | ||
port: 8080 | ||
protocol: TCP | ||
selector: | ||
app: keycloak-ha |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
{{- $cozyConfig := lookup "v1" "ConfigMap" "cozy-system" "cozystack" }} | ||
{{- $host := index $cozyConfig.data "root-host" }} | ||
{{- $password := randAlphaNum 16 -}} | ||
|
||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: {{ .Release.Name }}-credentials | ||
stringData: | ||
admin: {{ $password }} | ||
|
||
--- | ||
|
||
apiVersion: apps/v1 | ||
kind: StatefulSet | ||
metadata: | ||
name: keycloak | ||
labels: | ||
app: keycloak-ha | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: keycloak-ha | ||
replicas: 2 | ||
serviceName: keycloak-headless | ||
podManagementPolicy: Parallel | ||
updateStrategy: | ||
type: RollingUpdate | ||
template: | ||
metadata: | ||
labels: | ||
app: keycloak-ha | ||
spec: | ||
restartPolicy: Always | ||
securityContext: | ||
fsGroup: 1000 | ||
containers: | ||
- name: keycloak | ||
image: {{ .Values.image }} | ||
imagePullPolicy: Always | ||
{{- if or .Values.resources.requests .Values.resources.limits }} | ||
resources: | ||
{{- if .Values.resources.limits }} | ||
limits: | ||
{{- toYaml .Values.resources.limits | nindent 14 }} | ||
{{- end }} | ||
{{- if .Values.resources.requests }} | ||
requests: | ||
{{- toYaml .Values.resources.requests | nindent 14 }} | ||
{{- end }} | ||
{{- end }} | ||
securityContext: | ||
runAsNonRoot: true | ||
runAsUser: 1000 | ||
capabilities: | ||
drop: | ||
- ALL | ||
- CAP_NET_RAW | ||
readOnlyRootFilesystem: false | ||
allowPrivilegeEscalation: false | ||
args: | ||
- start | ||
env: | ||
- name: KC_METRICS_ENABLED | ||
value: "true" | ||
- name: KC_LOG_LEVEL | ||
value: "info" | ||
- name: KC_CACHE | ||
value: "ispn" | ||
- name: KC_CACHE_STACK | ||
value: "kubernetes" | ||
- name: KC_PROXY | ||
value: "edge" | ||
- name: KEYCLOAK_ADMIN | ||
value: admin | ||
- name: KEYCLOAK_ADMIN_PASSWORD | ||
value: {{ $password }} | ||
- name: KC_DB | ||
value: "postgres" | ||
- name: KC_DB_URL_HOST | ||
valueFrom: | ||
secretKeyRef: | ||
name: keycloak-db-app | ||
key: "host" | ||
- name: KC_DB_URL_PORT | ||
valueFrom: | ||
secretKeyRef: | ||
name: keycloak-db-app | ||
key: "port" | ||
- name: KC_DB_USERNAME | ||
valueFrom: | ||
secretKeyRef: | ||
name: keycloak-db-app | ||
key: "username" | ||
- name: KC_DB_PASSWORD | ||
valueFrom: | ||
secretKeyRef: | ||
name: keycloak-db-app | ||
key: "password" | ||
- name: KC_DB_URL_DATABASE | ||
valueFrom: | ||
secretKeyRef: | ||
name: keycloak-db-app | ||
key: "dbname" | ||
- name: KC_FEATURES | ||
value: "docker" | ||
- name: KC_HOSTNAME | ||
value: https://keycloak.{{ $host }} | ||
- name: JAVA_OPTS_APPEND | ||
value: "-Djgroups.dns.query=keycloak-headless.cozy-keycloak.svc.cozy.local" | ||
ports: | ||
- name: http | ||
containerPort: 8080 | ||
protocol: TCP | ||
livenessProbe: | ||
httpGet: | ||
path: / | ||
port: http | ||
initialDelaySeconds: 120 | ||
timeoutSeconds: 5 | ||
readinessProbe: | ||
httpGet: | ||
path: /realms/master | ||
port: http | ||
initialDelaySeconds: 60 | ||
timeoutSeconds: 1 | ||
volumes: | ||
- name: init-script | ||
configMap: | ||
name: keycloak-init-script | ||
volumeMounts: | ||
- name: init-script | ||
mountPath: /scripts | ||
readOnly: true | ||
terminationGracePeriodSeconds: 60 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
image: quay.io/keycloak/keycloak:26.0.4 | ||
|
||
ingress: | ||
annotations: | ||
nginx.ingress.kubernetes.io/affinity: "cookie" | ||
nginx.ingress.kubernetes.io/session-cookie-expires: "86400" | ||
nginx.ingress.kubernetes.io/session-cookie-max-age: "86400" | ||
nginx.ingress.kubernetes.io/session-cookie-name: "keycloak-cookie" | ||
resources: | ||
limits: | ||
memory: 1500Mi | ||
requests: | ||
memory: 500Mi | ||
cpu: 100m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/sh | ||
# Migration 7 --> 8 | ||
|
||
|
||
host=$(kubectl get hr tenant-root -n tenant-root -o yaml | grep 'host:' | awk '{print $2}') | ||
kubectl patch configmap -n cozy-system cozystack --type merge -p "{\"data\":{\"root-host\":\"$host\"}}" | ||
|
||
# Write version to cozystack-version config | ||
kubectl create configmap -n cozy-system cozystack-version --from-literal=version=8 --dry-run=client -o yaml | kubectl apply -f- |