-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update tests * Fix for custom value of http.relativePath * Set Keycloak to be disabled by default * Change proxy mode * Idempotent autogenerated certs * Idempotent autogenerated certs - another approach * Add atomic option * Add loop label * Mount CA cert * Fix for restarting PG apps * Gather facts for postgresql * Better when condition * Set database.hostname to pgbouncer when enabled * Update alternative names of tls.crt * Add doc * Enable metrics by default for readinessProbe * Add podAntiAffinity to be just preferred * Add busybox image for dbchecker option * Use local repo also for dbchecker image * Update chart version to bump its appVersion
- Loading branch information
1 parent
8d3db1a
commit 3b574be
Showing
19 changed files
with
299 additions
and
129 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
keycloak_helm_chart_file_name: keycloakx-1.6.0.tgz | ||
keycloak_helm_chart_file_name: keycloakx-1.6.1.tgz |
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
21 changes: 13 additions & 8 deletions
21
ansible/playbooks/roles/keycloak/templates/dynamic-chart-values.yml.j2
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 |
---|---|---|
@@ -1,21 +1,26 @@ | ||
#jinja2: lstrip_blocks: True | ||
|
||
# Keep data structure in sync with Helm chart's values. | ||
# ref: https://raw.githubusercontent.com/codecentric/helm-charts/keycloakx-1.6.0/charts/keycloakx/values.yaml | ||
{#- | ||
This file is used only locally to override chart's values defined in `configuration/keycloak` doc. | ||
Keep data structure in sync with Helm chart's values. | ||
ref: https://github.com/codecentric/helm-charts/blob/keycloakx-1.6.1/charts/keycloakx/values.yaml | ||
-#} | ||
|
||
{% if specification.image_registry.use_local %} | ||
image: | ||
repository: {{ image_registry_address }}/{{ _chart_values.image.repository }} | ||
{% else %} | ||
image: | ||
repository: {{ _chart_values.image.repository }} | ||
dbchecker: | ||
image: | ||
repository: {{ image_registry_address }}/{{ _chart_values.dbchecker.image.repository }} | ||
{% endif %} | ||
|
||
{% if specification.database.epiphany_managed and _chart_values.database.hostname | lower == 'autoconfigured' %} | ||
database: | ||
{% if groups.postgresql | count == 1 %} | ||
hostname: {{ hostvars[groups.postgresql[0]].ansible_default_ipv4.address }} | ||
{% set pgbouncer_items = applications_vars.specification.applications | default([]) | selectattr('name', '==', 'pgbouncer') %} | ||
{% if pgbouncer_items | count > 0 and pgbouncer_items[0].enabled is defined and pgbouncer_items[0].enabled %} | ||
hostname: {{ pgbouncer_items[0].pgbouncer.env.DB_HOST }} | ||
{% else %} | ||
hostname: {{ (applications_vars.specification.applications | selectattr('name', '==', 'pgbouncer') | first).pgbouncer.env.DB_HOST }} | ||
hostname: {{ hostvars[groups.postgresql[0]].ansible_default_ipv4.address }} | ||
{% endif %} | ||
{% endif %} |
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
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,131 @@ | ||
# Keycloak | ||
|
||
## How to run Keycloak | ||
|
||
1. Enable `kubernetes_master`, `kubernetes_node`, `repository` and `postgresql` components in the input manifest (yaml) | ||
by increasing `count` value. Enable `load_balancer` if needed. | ||
|
||
```yaml | ||
kind: epiphany-cluster | ||
title: Epiphany cluster Config | ||
provider: azure | ||
name: default | ||
specification: | ||
components: | ||
repository: | ||
count: 1 | ||
kubernetes_master: | ||
count: 1 | ||
kubernetes_node: | ||
count: 2 | ||
postgresql: | ||
count: 2 | ||
load_balancer: | ||
count: 1 | ||
``` | ||
2. Enable `keycloak` in `configuration/features` doc: | ||
|
||
```yaml | ||
kind: configuration/features | ||
title: Features to be enabled/disabled | ||
name: default | ||
specification: | ||
features: | ||
... | ||
- name: keycloak | ||
enabled: true | ||
``` | ||
|
||
3. Enable PostgreSQL related applications by setting `enabled: true` and adjust other parameters in `configuration/applications` | ||
doc. | ||
|
||
The default applications configuration is | ||
available [here](https://github.com/epiphany-platform/epiphany/blob/develop/schema/common/defaults/configuration/applications.yml) | ||
|
||
Note: To get working with Pgbouncer, Keycloak requires Pgbouncer configuration parameter `POOL_MODE` set to `session`, | ||
see [Installing Pgbouncer and Pgpool](DATABASES.md#installing-pgbouncer-and-pgpool) section. The reason is that Keycloak | ||
uses SET SQL statements. For details, see [SQL feature map for pooling modes](https://www.pgbouncer.org/features.html). | ||
|
||
4. Adjust default Keycloak settings to your needs by editing `configuration/keycloak` doc. | ||
|
||
By default, only HTTPS protocol is enabled and auto-generated TLS certificate is used. | ||
|
||
You can provide your own certificate: | ||
|
||
```yaml | ||
kind: configuration/keycloak | ||
title: Keycloak Config | ||
name: default | ||
specification: | ||
... | ||
chart_values: | ||
secrets: | ||
... | ||
tls-certs: | ||
type: kubernetes.io/tls | ||
data: | ||
# the data is abbreviated in this example | ||
# `ca.crt` is optional (not used by Keycloak) | ||
ca.crt: | | ||
LS0tLS1CRUdJTiBDRVJUSUZJQ0FUR... | ||
# a server certificate or certificate chain in PEM format | ||
tls.crt: | | ||
MIIC2DCCAcCgAwIBAgIBATANBgkqh... | ||
tls.key: | | ||
MIIEpgIBAAKCAQEA7yn3bRHQ5FHMQ... | ||
``` | ||
All default passwords should be changed. You may need to adjust `specification.chart_values.resources`. | ||
|
||
By default, Epiphany managed PostgreSQL cluster is used for Keycloak database | ||
and `specification.chart_values.database.hostname` is set to `AUTOCONFIGURED` | ||
which means: `pgbouncer` `ClusterIP` service is used if enabled, otherwise the first host of `postgresql` group. | ||
|
||
5. Run `epicli apply` on your input manifest. | ||
|
||
6. Reconfigure HA proxy (if needed). | ||
|
||
By default, Keycloak listens only for HTTPS traffic on port which is exposed via `NodePort` service. | ||
|
||
Some Keycloak features rely on the assumption that the remote address of the HTTP request connecting to Keycloak | ||
is the real IP address of the client machine. | ||
|
||
When you have HAProxy in front of Keycloak, this might not be the case, so we need to ensure that the X-Forwarded-For | ||
header is set by HAProxy. In order to achive this the content has to be modified by HAProxy. For that reason, | ||
TLS is terminated by HAProxy and the modified content is re-encrypted. Different keys and certificates are used on HAProxy | ||
as well as on Keycloak. | ||
|
||
Example of backend configuration: | ||
|
||
```text | ||
backend keycloak | ||
balance roundrobin | ||
option forwardfor | ||
server kubernetes-node-vm-0 10.1.1.151:30104 check ssl verify required ca-file /etc/ssl/haproxy/epiphany-keycloak-ca.crt | ||
server kubernetes-node-vm-1 10.1.1.235:30104 check ssl verify required ca-file /etc/ssl/haproxy/epiphany-keycloak-ca.crt | ||
``` | ||
|
||
It's recommended to not expose some endpoints, see https://www.keycloak.org/server/reverseproxy#_exposed_path_recommendations. | ||
|
||
Example of frontend configuration: | ||
|
||
```text | ||
frontend https_fe | ||
bind *:443 ssl crt /etc/ssl/haproxy/cert.crt | ||
# Do not expose health checks & metrics, see https://www.keycloak.org/server/reverseproxy#_exposed_path_recommendations | ||
http-request deny if { path_beg /auth/health/ } || { path /auth/health } || { path_beg /auth/metrics/ } || { path /auth/metrics } | ||
use_backend keycloak if { path -m beg /auth/ } || { path /auth } | ||
``` | ||
|
||
7. Log into GUI | ||
|
||
Note: Accessing the Keycloak GUI depends on your configuration. | ||
|
||
One method for reaching GUI is to use SSH tunnel with forwarding `NodePort`: | ||
|
||
```bash | ||
ssh -L 30104:localhost:30104 <user>@<k8s_host> -i <ssh_key_file> | ||
``` | ||
|
||
GUI should be reachable at: https://localhost:30104/auth |
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
Oops, something went wrong.