2023-02-09 09:29:41 +00:00
|
|
|
<#import "/templates/guide.adoc" as tmpl>
|
|
|
|
|
|
|
|
<@tmpl.guide
|
2023-02-13 07:40:02 +00:00
|
|
|
title="OpenShift"
|
2023-11-08 14:09:04 +00:00
|
|
|
summary="Get started with {project_name} on OpenShift">
|
2023-02-09 09:29:41 +00:00
|
|
|
|
2023-11-08 14:09:04 +00:00
|
|
|
:links-admin-console: {project_name} Admin Console
|
|
|
|
:links-account-console: {project_name} Account Console
|
2023-02-09 09:29:41 +00:00
|
|
|
|
2023-02-13 07:40:02 +00:00
|
|
|
== Before you start
|
2023-02-09 09:29:41 +00:00
|
|
|
|
2024-05-07 08:01:09 +00:00
|
|
|
include::templates/hw-requirements.adoc[]
|
|
|
|
|
2023-02-20 12:58:57 +00:00
|
|
|
. Install https://code-ready.github.io/crc/[Red Hat Code Ready Containers] and follow the steps in the documentation to install a
|
2023-02-09 09:29:41 +00:00
|
|
|
local OpenShift cluster.
|
|
|
|
|
2023-02-20 12:58:57 +00:00
|
|
|
. Make sure the cluster is functional by entering the following command:
|
|
|
|
+
|
2023-02-09 09:29:41 +00:00
|
|
|
[source,bash,subs="attributes+"]
|
|
|
|
----
|
|
|
|
crc status
|
|
|
|
----
|
|
|
|
|
2023-02-20 12:58:57 +00:00
|
|
|
. Look for output similar to the following to confirm the cluster is working.
|
|
|
|
+
|
2023-02-13 07:40:02 +00:00
|
|
|
[source,subs="attributes+"]
|
2023-02-09 09:29:41 +00:00
|
|
|
----
|
|
|
|
CRC VM: Running
|
|
|
|
OpenShift: Running
|
|
|
|
...
|
|
|
|
----
|
|
|
|
|
2023-02-20 12:58:57 +00:00
|
|
|
. Log in as the user `developer`:
|
|
|
|
+
|
2023-02-09 09:29:41 +00:00
|
|
|
[source,bash,subs="attributes+"]
|
|
|
|
----
|
|
|
|
oc login -u developer -p developer
|
|
|
|
----
|
|
|
|
|
2023-02-20 12:58:57 +00:00
|
|
|
. Create a project called `keycloak` by entering the following command:
|
|
|
|
+
|
2023-02-09 09:29:41 +00:00
|
|
|
[source,bash,subs="attributes+"]
|
|
|
|
----
|
|
|
|
oc new-project keycloak
|
|
|
|
----
|
|
|
|
|
2023-11-08 14:09:04 +00:00
|
|
|
== Start {project_name}
|
2023-02-09 09:29:41 +00:00
|
|
|
|
2023-11-08 14:09:04 +00:00
|
|
|
. To start a {project_name} server in your project, enter the following command:
|
2023-02-20 12:58:57 +00:00
|
|
|
+
|
2023-02-09 09:29:41 +00:00
|
|
|
[source,bash,subs="attributes+"]
|
|
|
|
----
|
2023-05-29 22:29:59 +00:00
|
|
|
oc process -f https://raw.githubusercontent.com/keycloak/keycloak-quickstarts/latest/openshift/keycloak.yaml \
|
2024-07-11 16:07:57 +00:00
|
|
|
-p KC_BOOTSTRAP_ADMIN_USERNAME=admin \
|
|
|
|
-p KC_BOOTSTRAP_ADMIN_PASSWORD=admin \
|
2023-02-09 09:29:41 +00:00
|
|
|
-p NAMESPACE=keycloak \
|
|
|
|
| oc create -f -
|
|
|
|
----
|
2023-08-16 19:35:03 +00:00
|
|
|
+
|
2023-10-12 21:33:25 +00:00
|
|
|
In this example, the user name and password are `admin`.
|
2023-02-09 09:29:41 +00:00
|
|
|
|
2023-02-20 12:58:57 +00:00
|
|
|
. Once the command above completes, look for a message similar to this:
|
|
|
|
+
|
2023-02-09 09:29:41 +00:00
|
|
|
[source,bash,subs="attributes+"]
|
|
|
|
----
|
|
|
|
service/keycloak created
|
|
|
|
route.route.openshift.io/keycloak created
|
|
|
|
deploymentconfig.apps.openshift.io/keycloak created.
|
|
|
|
----
|
2023-02-20 12:58:57 +00:00
|
|
|
+
|
2023-11-08 14:09:04 +00:00
|
|
|
At this point, OpenShift will provision a {project_name} pod and related resources. As part of the process, OpenShift will
|
|
|
|
try to pull the {project_name} server image. This operation might take some time depending on your network connection.
|
2023-02-09 09:29:41 +00:00
|
|
|
|
2023-11-08 14:09:04 +00:00
|
|
|
. To make sure {project_name} is provisioned, execute the following command:
|
2023-02-20 12:58:57 +00:00
|
|
|
+
|
2023-02-09 09:29:41 +00:00
|
|
|
[source,bash,subs="attributes+"]
|
|
|
|
----
|
|
|
|
oc get pods
|
|
|
|
----
|
|
|
|
|
2023-02-20 12:58:57 +00:00
|
|
|
. After a while, look for a message similar to the following; it indicates the pod is ready:
|
|
|
|
+
|
2023-02-09 09:29:41 +00:00
|
|
|
[source,bash,subs="attributes+"]
|
|
|
|
----
|
|
|
|
NAME READY STATUS RESTARTS AGE
|
|
|
|
keycloak-1-deploy 0/1 Completed 0 1h
|
|
|
|
keycloak-1-l9kdx 1/1 Running 0 1h
|
|
|
|
----
|
|
|
|
|
2023-11-08 14:09:04 +00:00
|
|
|
. Once the server is provisioned, enter the following command to find out the {project_name} URLs:
|
2023-02-20 12:58:57 +00:00
|
|
|
+
|
2023-02-09 09:29:41 +00:00
|
|
|
[source,bash,subs="attributes+"]
|
|
|
|
----
|
|
|
|
KEYCLOAK_URL=https://$(oc get route keycloak --template='{{ .spec.host }}') &&
|
|
|
|
echo "" &&
|
2023-11-08 14:09:04 +00:00
|
|
|
echo "{project_name}: $KEYCLOAK_URL" &&
|
|
|
|
echo "{project_name} Admin Console: $KEYCLOAK_URL/admin" &&
|
|
|
|
echo "{project_name} Account Console: $KEYCLOAK_URL/realms/myrealm/account" &&
|
2023-02-09 09:29:41 +00:00
|
|
|
echo ""
|
|
|
|
----
|
|
|
|
|
2023-05-04 09:04:44 +00:00
|
|
|
Remember these URLs as you will need them throughout this {section}. The URL for the account console won't work
|
2023-02-09 09:29:41 +00:00
|
|
|
right now as you will need to create the realm first.
|
|
|
|
|
|
|
|
include::templates/realm-config.adoc[]
|
|
|
|
|
|
|
|
include::templates/login-to-account.adoc[]
|
|
|
|
|
|
|
|
include::templates/first-app.adoc[]
|
|
|
|
|
|
|
|
include::templates/next.adoc[]
|
|
|
|
|
|
|
|
</@tmpl.guide>
|