2022-04-08 09:57:22 +00:00
<#import "/templates/guide.adoc" as tmpl>
<#import "/templates/kc.adoc" as kc>
<#import "/templates/options.adoc" as opts>
<#import "/templates/links.adoc" as links>
2023-10-11 11:24:50 +00:00
<#import "/templates/profile.adoc" as profile>
2022-04-08 09:57:22 +00:00
<@tmpl.guide
title="Advanced configuration"
summary="How to tune advanced aspects of the Keycloak CR">
2023-03-01 15:24:36 +00:00
== Advanced configuration
2023-11-08 14:09:04 +00:00
This {section} describes how to use Custom Resources (CRs) for advanced configuration of your {project_name} deployment.
2022-04-08 09:57:22 +00:00
2023-03-01 15:24:36 +00:00
=== Server configuration details
2022-04-08 09:57:22 +00:00
2023-11-08 14:09:04 +00:00
Many server options are exposed as first-class citizen fields in the Keycloak CR. The structure of the CR is based on the configuration structure of {project_name}. For example, to configure the `https-port` of the server, follow a
2023-03-01 15:24:36 +00:00
similar pattern in the CR and use the `httpsPort` field. The following example is a complex server configuration; however, it illustrates the relationship between server options and the Keycloak CR:
2022-10-21 14:42:42 +00:00
[source,yaml]
----
apiVersion: k8s.keycloak.org/v2alpha1
kind: Keycloak
metadata:
name: example-kc
spec:
db:
vendor: postgres
usernameSecret:
name: usernameSecret
key: usernameSecretKey
passwordSecret:
name: passwordSecret
key: passwordSecretKey
host: host
database: database
port: 123
schema: schema
poolInitialSize: 1
poolMinSize: 2
poolMaxSize: 3
http:
httpEnabled: true
httpPort: 8180
httpsPort: 8543
tlsSecret: my-tls-secret
hostname:
hostname: my-hostname
admin: my-admin-hostname
strict: false
strictBackchannel: false
features:
enabled:
- docker
- authorization
disabled:
- admin
- step-up-authentication
transaction:
xaEnabled: false
----
2023-03-01 15:24:36 +00:00
For a list of options, see the Keycloak CRD. For details on configuring options, see <@links.server id="all-config"/>.
2022-10-21 14:42:42 +00:00
==== Additional options
2023-03-01 15:24:36 +00:00
Some expert server options are unavailable as dedicated fields in the Keycloak CR. The following are examples of omitted fields:
2022-10-21 14:42:42 +00:00
2023-11-08 14:09:04 +00:00
* Fields that require deep understanding of the underlying {project_name} implementation
2023-10-11 11:24:50 +00:00
* Fields that are not relevant to
<@profile.ifCommunity>
a Kubernetes
</@profile.ifCommunity>
<@profile.ifProduct>
an OpenShift
</@profile.ifProduct>
environment
2023-03-01 15:24:36 +00:00
* Fields for provider configuration because they are dynamic based on the used provider implementation
2022-04-08 09:57:22 +00:00
2023-11-08 14:09:04 +00:00
The `additionalOptions` field of the Keycloak CR enables {project_name} to accept any available configuration in the form of key-value pairs.
2023-03-01 15:24:36 +00:00
You can use this field to include any option that is omitted in the Keycloak CR.
For details on configuring options, see <@links.server id="all-config"/>.
2023-10-11 11:24:50 +00:00
The values can be expressed as plain text strings or Secret object references as shown in this example:
2022-04-08 09:57:22 +00:00
[source,yaml]
----
2022-04-11 12:48:21 +00:00
apiVersion: k8s.keycloak.org/v2alpha1
2022-04-08 09:57:22 +00:00
kind: Keycloak
metadata:
name: example-kc
spec:
...
2022-10-21 12:41:02 +00:00
additionalOptions:
2022-10-21 14:42:42 +00:00
- name: spi-connections-http-client-default-connection-pool-size
2022-04-08 09:57:22 +00:00
secret: # Secret reference
2022-10-21 14:42:42 +00:00
name: http-client-secret # name of the Secret
key: poolSize # name of the Key in the Secret
- name: spi-email-template-mycustomprovider-enabled
value: true # plain text value
2022-04-08 09:57:22 +00:00
----
=== Secret References
2023-03-01 15:24:36 +00:00
Secret References are used by some dedicated options in the Keycloak CR, such as `tlsSecret`, or as a value in `additionalOptions`.
2022-04-08 09:57:22 +00:00
2023-03-01 15:24:36 +00:00
When specifying a Secret Reference, make sure that a Secret containing the referenced keys is present in the same namespace as the CR referencing it.
2023-11-08 14:09:04 +00:00
Along with the {project_name} Server Deployment, the Operator adds special labels to the referenced Secrets to watch for changes.
2022-04-08 09:57:22 +00:00
2023-11-08 14:09:04 +00:00
When a referenced Secret is modified, the Operator performs a rolling restart of the {project_name} Deployment to pick up the changes.
2022-04-08 09:57:22 +00:00
=== Unsupported features
2023-10-11 11:24:50 +00:00
The `unsupported` field of the CR contains highly experimental configuration options that are not completely tested and are Tech Preview.
2022-04-08 09:57:22 +00:00
==== Pod Template
2023-10-11 11:24:50 +00:00
The Pod Template is a raw API representation that is used for the Deployment Template.
2023-10-05 05:42:37 +00:00
This field is a temporary workaround in case no supported field exists at the top level of the CR for your use case.
2022-04-08 09:57:22 +00:00
2023-03-01 15:24:36 +00:00
The Operator merges the fields of the provided template with the values generated by the Operator for the specific Deployment.
With this feature, you have access to a high level of customizations. However, no guarantee exists that the Deployment will work as expected.
2022-04-08 09:57:22 +00:00
2023-03-01 15:24:36 +00:00
The following example illustrates injecting labels, annotations, volumes, and volume mounts:
2022-04-08 09:57:22 +00:00
[source,yaml]
----
2022-04-11 12:48:21 +00:00
apiVersion: k8s.keycloak.org/v2alpha1
2022-04-08 09:57:22 +00:00
kind: Keycloak
metadata:
name: example-kc
spec:
...
unsupported:
podTemplate:
metadata:
labels:
my-label: "keycloak"
spec:
containers:
- volumeMounts:
- name: test-volume
mountPath: /mnt/test
volumes:
- name: test-volume
secret:
secretName: keycloak-additional-secret
----
2022-10-21 14:42:42 +00:00
=== Disabling required options
2022-04-08 09:57:22 +00:00
2023-11-08 14:09:04 +00:00
{project_name} and the {project_name} Operator provide the best production-ready experience with security in mind.
2023-03-01 15:24:36 +00:00
However, during the development phase, you can disable key security features.
2022-04-08 09:57:22 +00:00
2022-10-21 14:42:42 +00:00
Specifically, you can disable the hostname and TLS as shown in the following example:
2022-04-08 09:57:22 +00:00
[source,yaml]
----
2022-04-11 12:48:21 +00:00
apiVersion: k8s.keycloak.org/v2alpha1
2022-04-08 09:57:22 +00:00
kind: Keycloak
metadata:
name: example-kc
spec:
...
2022-10-21 14:42:42 +00:00
http:
httpEnabled: true
hostname:
strict: false
strictBackchannel: false
2022-04-08 09:57:22 +00:00
----
</@tmpl.guide>