1

I just follow the Keycloak Documentation for Kubernetes.

https://www.keycloak.org/getting-started/getting-started-kube

I

But After deployed it like exactly how they are saying in the documentation.

When I try to load the keyclaok page, I'm getting this,

enter image description here

if you can give me a solution or explain why this is happening, Really appreciate it!

My ingress config (keycloak-ingress.yaml) is,

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: keycloak
spec:
  tls:
    - hosts:
      - keycloak.192.168.49.2.nip.io
  rules:
  - host: keycloak.192.168.49.2.nip.io
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: keycloak
            port:
              number: 8080

1 Answers1

1

Make sure you have updated the ingress file with the proper IP of minikube.

Also check with http instead https & KEYCLOAK_HOSTNAME value

Try below YAML :

apiVersion: v1
kind: Service
metadata:
  name: keycloak
  labels:
    app: keycloak
spec:
  ports:
  - name: http
    port: 8080
    targetPort: 8080
  selector:
    app: keycloak
  type: LoadBalancer
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: keycloak
  labels:
    app: keycloak
spec:
  replicas: 1
  selector:
    matchLabels:
      app: keycloak
  template:
    metadata:
      labels:
        app: keycloak
    spec:
      containers:
      - name: keycloak
        image: quay.io/keycloak/keycloak:20.0.3
        args: ["start-dev"]
        env:
        - name: KEYCLOAK_ADMIN
          value: "admin"
        - name: KEYCLOAK_ADMIN_PASSWORD
          value: "admin"
        - name: KC_PROXY
          value: "edge"
        ports:
        - name: http
          containerPort: 8080
        readinessProbe:
          httpGet:
            path: /realms/master
            port: 8080

it will creat the LB service for you so you will be able to access it without ingress config. Run kubectl get svc -n <namespace-name> and check External IP and try opening that in browser.

Extra :

You can refer to this YAML if the default one is not working. i am using Postgres & Dpeloying the Keycloak with that.

GitHub repo path : https://github.com/harsh4870/Keycloack-postgres-kubernetes-deployment

Ref : https://faun.pub/keycloak-kubernetes-deployment-409d6ccd8a39

Harsh Manvar
  • 27,020
  • 6
  • 48
  • 102
  • Thank you so much for answering! Keycloak is opened with the External IP, no issue with that! But I think issue on my ingress config. I tried so many times to load keycloak by using hostname. But every time I got connection refused on the browser. – Gayan Kodithuwakku Feb 10 '23 at 10:03
  • did you verified other variables in your YAML and my shared yaml ? like `PROXY_ADDRESS_FORWARDING` as i was also using the ingress only. – Harsh Manvar Feb 10 '23 at 10:11
  • 1
    also did you added the mapping to `/etc/hosts` for ingress expose locally ? https://kubernetes.io/docs/tasks/access-application-cluster/ingress-minikube/ if your loadbalancer service giving your external IP you can also use it to access service. – Harsh Manvar Feb 10 '23 at 10:15
  • I tried the your shared yaml in stack, haven't tried the yaml that in your github. – Gayan Kodithuwakku Feb 10 '23 at 10:16
  • Yeah I mapped to `/etc/hosts` – Gayan Kodithuwakku Feb 10 '23 at 10:21