<#import "/templates/guide.adoc" as tmpl>
<#import "/templates/kc.adoc" as kc>
<#import "/templates/options.adoc" as opts>
<#import "/templates/links.adoc" as links>

<@tmpl.guide
title="Using custom Keycloak images"
summary="How to customize and optimize the Keycloak Container">

== Keycloak custom image with the Operator

With the Keycloak Custom Resource (CR), you can specify a custom container image for the Keycloak server.

[NOTE]
To ensure full compatibility of Operator and Operand,
make sure that the version of Keycloak release used in the custom image is aligned with the version of the operator.

=== Best practice

When using the default Keycloak image, the server will perform a costly re-augmentation every time a Pod starts.
To avoid this delay, you can provide a custom image with the augmentation built-in from the build time of the image.

With a custom image, you can also specify the Keycloak _build-time_ configurations and extensions during the build of the container.

For instructions on how to build such an image, see <@links.server id="containers"/>.

=== Providing a custom Keycloak image

To provide a custom image, you define the `image` field in the Keycloak CR as shown in this example:

[source,yaml]
----
apiVersion: k8s.keycloak.org/v2alpha1
kind: Keycloak
metadata:
  name: example-kc
spec:
  instances: 1
  image: quay.io/my-company/my-keycloak:latest
  http:
    tlsSecret: example-tls-secret
  hostname:
    hostname: test.keycloak.org
----

[NOTE]
====
With custom images, every build time option passed either through a dedicated field or the `additionalOptions` is ignored.
====

</@tmpl.guide>
