Keycloak in minikube

Ratna
1 min readDec 17, 2020

These days everyone is using keycloak in every project. Here is a short notes of the instructions to deploy in minikube.

  1. Start minikube
minikube start

If this doesn’t start then execute following command to delete minikube and recreate minikube environment.

minikube delete
minikube start
kubectl config use-context minikube
kubectl get pods --context=minikube
minikube status

And then make sure minikube started successfully.

2. Now after starting minikube successfully, we need to do some steps to access keycloak from minikube. For that first we need to enable ingress in minikube, so run below commands for that

minikube addons list
minikube addons enable ingress

3. Now start keycloak container using below

kubectl create -f https://raw.githubusercontent.com/keycloak/keycloak-quickstarts/latest/kubernetes-examples/keycloak.yaml

4. Now we need to create service for minikube pod.

minikube ip

Above command will give the ip address of your local minikube lets say it is 192.168.64.3

And create manifest file keycloak service as below.

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: keycloak
spec:
tls:
- hosts:
- keycloak.192.168.64.3.nip.io
rules:
- host: keycloak.192.168.64.3.nip.io
http:
paths:
- backend:
serviceName: keycloak
servicePort: 8080

And save this file as keycloak-ingress.yml and go to the path and run below command.

kubectl apply -f keycloak-ingress.yml

5. Now you should be able to access keycloak but how ? Now run the below command to see the url’s

KEYCLOAK_URL=https://keycloak.$(minikube ip).nip.io/auth &&
echo "" &&
echo "Keycloak: $KEYCLOAK_URL" &&
echo "Keycloak Admin Console: $KEYCLOAK_URL/admin" &&
echo "Keycloak Account Console: $KEYCLOAK_URL/realms/myrealm/account" &&
echo ""

--

--

Ratna

Senior System Developer with 15 years of experience. Currently focused on microservice, Event Driven, CQRS architecture