2023-02-09 09:29:41 +00:00
<#import "/templates/guide.adoc" as tmpl>
2024-10-08 13:46:24 +00:00
<#import "/templates/links.adoc" as links>
2023-02-09 09:29:41 +00:00
<@tmpl.guide
title="Kubernetes"
2023-11-08 14:09:04 +00:00
summary="Get started with {project_name} on Kubernetes">
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-09 09:29:41 +00:00
Make sure you have Minikube installed, ideally with the Ingress addon enabled.
2023-02-20 12:58:57 +00:00
To check if you have the Ingress addon enabled, enter the following command:
2023-02-09 09:29:41 +00:00
[source,bash,subs="attributes+"]
----
minikube addons list
----
2023-02-20 12:58:57 +00:00
If the Ingress addon is not enabled, enter the following command to enable it:
2023-02-09 09:29:41 +00:00
[source,bash,subs="attributes+"]
----
minikube addons enable ingress
----
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
The {project_name} QuickStarts repository includes some example files to help deploy {project_name} to Kubernetes.
2023-02-09 09:29:41 +00:00
2023-11-08 14:09:04 +00:00
As a first step, create the {project_name} deployment and service by entering the following command:
2023-02-09 09:29:41 +00:00
[source,bash,subs="attributes+"]
----
2023-05-29 22:29:59 +00:00
kubectl create -f https://raw.githubusercontent.com/keycloak/keycloak-quickstarts/latest/kubernetes/keycloak.yaml
2023-02-09 09:29:41 +00:00
----
2023-11-08 14:09:04 +00:00
This command starts {project_name} on Kubernetes and creates an initial admin user with the username `admin` and password
2023-02-09 09:29:41 +00:00
`admin`.
2024-10-08 13:46:24 +00:00
NOTE: If you will eventually want more than one server replica, please see the <@links.gettingstarted id="getting-started-scaling-and-tuning" anchor="horizontal-scaling" /> {section}.
2023-11-08 14:09:04 +00:00
=== Access {project_name} with Ingress addon enabled
2023-02-09 09:29:41 +00:00
2023-11-08 14:09:04 +00:00
Now create an Ingress for {project_name} by entering the following command:
2023-02-09 09:29:41 +00:00
[source,bash,subs="attributes+"]
----
2023-05-29 22:29:59 +00:00
wget -q -O - https://raw.githubusercontent.com/keycloak/keycloak-quickstarts/latest/kubernetes/keycloak-ingress.yaml | \
2023-02-09 09:29:41 +00:00
sed "s/KEYCLOAK_HOST/keycloak.$(minikube ip).nip.io/" | \
kubectl create -f -
----
2023-02-20 12:58:57 +00:00
If `wget` and `sed` are not available, download the file and manually edit the file replacing `KEYCLOAK_HOST`
2023-02-09 09:29:41 +00:00
with `keycloak.<minikube ip address>.nip.io`.
2023-11-08 14:09:04 +00:00
Enter the following command to see the {project_name} URLs:
2023-02-09 09:29:41 +00:00
[source,bash,subs="attributes+"]
----
KEYCLOAK_URL=https://keycloak.$(minikube ip).nip.io &&
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-11-08 14:09:04 +00:00
=== Access {project_name} without Ingress
2023-02-09 09:29:41 +00:00
2023-02-20 12:58:57 +00:00
If the Ingress addon is not enabled, enter the following command in a separate shell:
2023-02-09 09:29:41 +00:00
[source,bash,subs="attributes+"]
----
minikube tunnel
----
2023-11-08 14:09:04 +00:00
You can now access {project_name} from the following URL:
2023-02-09 09:29:41 +00:00
[source,bash,subs="attributes+"]
----
KEYCLOAK_URL=http://$(minikube ip):$(kubectl get services/keycloak -o go-template='{{(index .spec.ports 0).nodePort}}') &&
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. You need them as you follow the instructions in this {section}. The URL for the Account Console does not work yet as you need to create the realm first.
2023-02-09 09:29:41 +00:00
include::templates/realm-config.adoc[]
include::templates/login-to-account.adoc[]
include::templates/first-app.adoc[]
include::templates/next.adoc[]
</@tmpl.guide>