<#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="Keycloak Operator Installation"
priority=10
summary="How to install the Keycloak Operator on Kubernetes and OpenShift">

== Installing the Keycloak Operator
This {section} describes how to install the Keycloak Operator in a Kubernetes or OpenShift cluster.

=== Installing by using the Operator Lifecycle Manager

The recommended way to install the Keycloak Operator in Kubernetes environments is to use the Operator Lifecycle Manager (OLM).

==== Prerequisites
*  Make sure OLM is installed in your environment. For details, see https://github.com/operator-framework/operator-lifecycle-manager/blob/master/doc/install/install.md#install-a-release[Installing OLM].

* Be sure that you have cluster-admin permission or an equivalent level of permissions granted by an administrator.

==== Using the OpenShift web console

The following procedure describes how to install the Keycloak Operator. However, for general instructions on installing Operators using OLM, see https://olm.operatorframework.io/docs/tasks/install-operator-with-olm/[Install your operator with OLM]. In the default Catalog, the Keycloak Operator is named `keycloak-operator`. Make sure to use the `fast` channel to find the operator.

Perform this procedure on an OpenShift cluster.

. Open the OpenShift Container Platform web console.

. In the left column, click *Home*, *Operators*, *OperatorHub*.

. Search for "keycloak" on the search input box.
+
image::select-operator.jpeg["Select the Keycloak Operator in the UI"]

. Select the Keycloak Operator from the list of results.
. Follow the instructions on the screen.
+
Make sure you are installing from the *fast* channel:
+
image::configure-operator.jpeg["Configure Keycloak Operator"]

=== Installing by using kubectl without Operator Lifecycle Manager

You can install the Operator on a vanilla Kubernetes cluster by using `kubectl` commands:

. Install the CRDs by entering the following commands:
+
[source,bash,subs="attributes+"]
----
kubectl apply -f https://raw.githubusercontent.com/keycloak/keycloak-k8s-resources/{version}/kubernetes/keycloaks.k8s.keycloak.org-v1.yml
kubectl apply -f https://raw.githubusercontent.com/keycloak/keycloak-k8s-resources/{version}/kubernetes/keycloakrealmimports.k8s.keycloak.org-v1.yml
----

. Install the Keycloak Operator deployment by entering the following command:
+
[source,bash,subs="attributes+"]
----
kubectl apply -f https://raw.githubusercontent.com/keycloak/keycloak-k8s-resources/{version}/kubernetes/kubernetes.yml
----

Currently the Operator watches only the namespace where the Operator is installed.

</@tmpl.guide>
