<#import "/templates/guide.adoc" as tmpl> <@tmpl.guide title="Kubernetes" summary="Get started with Keycloak on Kubernetes"> :links-admin-console: Keycloak Admin Console :links-account-console: Keycloak Account Console == Before you start Make sure you have Minikube installed, ideally with the Ingress addon enabled. To check if you have the Ingress addon enabled run: [source,bash,subs="attributes+"] ---- minikube addons list ---- If the Ingress addon is not enabled run the following to enable it: [source,bash,subs="attributes+"] ---- minikube addons enable ingress ---- == Run Keycloak The Keycloak QuickStarts repository includes some example files to help deploy Keycloak to Kubernetes. Let's start with creating the Keycloak deployment and service: [source,bash,subs="attributes+"] ---- kubectl create -f https://raw.githubusercontent.com/keycloak/keycloak-quickstarts/latest/kubernetes-examples/keycloak.yaml ---- This will start Keycloak on Kubernetes. It will also create an initial admin user with username `admin` and password `admin`. === Access Keycloak with Ingress addon enabled Start by creating an Ingress for Keycloak: [source,bash,subs="attributes+"] ---- wget -q -O - https://raw.githubusercontent.com/keycloak/keycloak-quickstarts/latest/kubernetes-examples/keycloak-ingress.yaml | \ sed "s/KEYCLOAK_HOST/keycloak.$(minikube ip).nip.io/" | \ kubectl create -f - ---- If you don't have `wget` and `sed` available, download the file and manually edit the file replacing `KEYCLOAK_HOST` with `keycloak..nip.io`. Run the following to find out the URLs of Keycloak: [source,bash,subs="attributes+"] ---- KEYCLOAK_URL=https://keycloak.$(minikube ip).nip.io && echo "" && echo "Keycloak: $KEYCLOAK_URL" && echo "Keycloak Admin Console: $KEYCLOAK_URL/admin" && echo "Keycloak Account Console: $KEYCLOAK_URL/realms/myrealm/account" && echo "" ---- Remember these URLs as you will need them throughout this guide. The URL for the account console won't work right now as you will need to create the realm first. === Access Keycloak without Ingress If you don't have the Ingress addon enabled, first run in a separate shell: [source,bash,subs="attributes+"] ---- minikube tunnel ---- and you can now access Keycloak from the following URL: [source,bash,subs="attributes+"] ---- KEYCLOAK_URL=http://$(minikube ip):$(kubectl get services/keycloak -o go-template='{{(index .spec.ports 0).nodePort}}') && echo "" && echo "Keycloak: $KEYCLOAK_URL" && echo "Keycloak Admin Console: $KEYCLOAK_URL/admin" && echo "Keycloak Account Console: $KEYCLOAK_URL/realms/myrealm/account" && echo "" ---- Remember these URLs as you will need them throughout this guide. The URL for the account console won't work 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[]