-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from projectsyn/application-based-certificate
Encrypt cluster-internal traffic
- Loading branch information
Showing
10 changed files
with
354 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
= Configure Keycloak ingress | ||
|
||
Incoming network traffic to the Keycloak service is usually routed via an ingress. | ||
|
||
[NOTE] | ||
==== | ||
Currently, only NGINX ingress controller is supported and tested. | ||
Others may work as well, but you may need to customize some parameters on your own (or contribute back to the component). | ||
==== | ||
|
||
See also the following manual on how to setup the Keycloak encryption: | ||
|
||
* https://github.com/keycloak/keycloak-containers/blob/master/server/README.md[Docker image configuration] | ||
First, choose where the TLS session to Keycloak is terminated. | ||
|
||
== Encryption mode: Re-encrypt | ||
|
||
In re-encryption mode, the traffic is terminated at the NGINX ingress controller, and then re-encrypted when connecting to Keycloak pods. | ||
By default, this component will use Let's Encrypt (cert-manager) so that NGINX terminates with valid certificates. | ||
The connection to Keycloak is using self-signed certificates since Keycloak does not reload certificates when they have changed in the container. | ||
|
||
Re-encryption is the default, so there's not much to configure. | ||
Proceed with xref:how-tos/keycloak-tls.adoc[Setup a TLS certificate for Keycloak]. | ||
|
||
== Encryption mode: Pass-through | ||
|
||
In the pass-through mode, the controller will not terminate the TLS session and instead directly forward the HTTPS traffic to Keycloak. | ||
The controller needs to support pass-through mode. | ||
|
||
[IMPORTANT] | ||
==== | ||
This mode requires that the NGINX Controller is configured to pass through the TLS traffic. | ||
This is not enabled by default. | ||
With https://github.com/projectsyn/component-ingress-nginx[component-ingress-nginx], you can enable it like following: | ||
[source,yaml] | ||
---- | ||
parameters: | ||
ingress_nginx: | ||
helm_values: | ||
controller: | ||
extraArgs: | ||
enable-ssl-passthrough: true | ||
---- | ||
==== | ||
|
||
[WARNING] | ||
==== | ||
When using certificates from Let's Encrypt (cert-manager), ensure that you regularly restart Keycloak. | ||
Otherwise, you may end up serving expired certificates! | ||
The default Keycloak container image does not reload the certificates when they have changed in the mounted filesystem. | ||
==== | ||
|
||
. Terminate the TLS session directly in Keycloak | ||
+ | ||
[source,yaml] | ||
---- | ||
parameters: | ||
keycloak: | ||
tls: | ||
termination: passthrough | ||
---- | ||
|
||
. If you're using CA issued certificates, change the provider: | ||
+ | ||
[source,yaml] | ||
---- | ||
parameters: | ||
keycloak: | ||
tls: | ||
provider: vault | ||
---- | ||
+ | ||
See xref:how-tos/keycloak-tls.adoc[Setup a TLS certificate for Keycloak] for how to store a certificate in vault. |
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,48 @@ | ||
= Setup a TLS certificate for Keycloak | ||
|
||
This guide provides an example how to setup a TLS certificate for Keycloak. | ||
|
||
==== | ||
Requirements | ||
* `commodore` | ||
* `kubectl` | ||
* `openssl` | ||
* `vault` | ||
==== | ||
|
||
. Prepare certificate files | ||
+ | ||
.Self-signed certificates | ||
[source,bash] | ||
---- | ||
# Adjust the lifetime as necessary | ||
lifetime=3650 | ||
openssl req -x509 -newkey rsa:4096 -nodes -keyout keycloak.key -out keycloak.crt -days ${lifetime} -subj '/CN=keycloak' | ||
---- | ||
+ | ||
.CA issued certificates | ||
[source,bash] | ||
---- | ||
# Save the cert and key in these temporary files | ||
editor keycloak.key | ||
editor keycloak.crt | ||
---- | ||
|
||
. Store certificate in Vault | ||
+ | ||
[source,bash] | ||
---- | ||
instance=keycloak | ||
parent="clusters/kv/${TENANT_ID}/${CLUSTER_ID}" | ||
|
||
# Use the 'patch' subcommand to add to existing secret | ||
vault kv patch "${parent}/${instance}" [email protected] [email protected] | ||
---- | ||
|
||
. Remove temporary files | ||
+ | ||
[source,bash] | ||
---- | ||
rm keycloak.{key,crt} | ||
---- |
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.