<p>I have deployed keycloak on kubernetes cluster and I want to access it with ingress path url, but I am getting 503 service unavilable when trying to access. But with cluster-ip I am able to access keycloak. With /auth I am able to access the main page of keycloak, i.e <a href="https://my-server.com/keycloak-development/auth/" rel="nofollow noreferrer">https://my-server.com/keycloak-development/auth/</a>, but when I try to access admin console it goes to 503 error.</p>
<p>deployment.yaml</p>
<pre><code>---
  apiVersion: &quot;apps/v1&quot;
  kind: &quot;Deployment&quot;
  metadata: 
    name: &quot;keycloak-development&quot;
    namespace: &quot;development&quot;
  spec: 
    selector: 
      matchLabels: 
        app: &quot;keycloak-development&quot;
    replicas: 1
    strategy: 
      type: &quot;RollingUpdate&quot;
      rollingUpdate: 
        maxSurge: 1
        maxUnavailable: 1
    minReadySeconds: 5
    template: 
      metadata: 
        labels: 
          app: &quot;keycloak-development&quot;
      spec: 
        containers: 
          - 
            name: &quot;keycloak-development&quot;
            image: &quot;mykeycloak-image:latest&quot;
            imagePullPolicy: &quot;Always&quot;
            env: 
              - 
                name: &quot;NODE_ENV&quot;
                value: &quot;development&quot;
              -
                name: &quot;PROXY_ADDRESS_FORWARDING&quot;
                value: &quot;true&quot;
              
              -
                name: &quot;KEYCLOAK_URL&quot;
                value: &quot;https://my-server.com/keycloak-development/&quot;

                

                
            ports: 
              - 
                containerPort: 53582
        imagePullSecrets: 
          - 
            name: &quot;keycloak&quot;
</code></pre>
<p>service.yaml</p>
<pre><code>--
  apiVersion: &quot;v1&quot;
  kind: &quot;Service&quot;
  metadata: 
    name: &quot;keycloak-development&quot;
    namespace: &quot;development&quot;
    labels: 
      app: &quot;keycloak-development&quot;
  spec: 
    ports: 
      - 
        port: 53582
        targetPort: 8080
    selector: 
      app: &quot;keycloak-development&quot;

</code></pre>
<p>ingress.yaml</p>
<pre><code>---
  apiVersion: &quot;networking.k8s.io/v1beta1&quot;
  kind: &quot;Ingress&quot;
  metadata: 
    name: &quot;keycloak-development-ingress&quot;
    namespace: &quot;development&quot;
    annotations: 
      nginx.ingress.kubernetes.io/rewrite-target: &quot;/$1&quot;
  spec: 
    rules: 
      - 
        host: &quot;my-server.com&quot;
        http: 
          paths: 
            - 
              backend: 
                serviceName: &quot;keycloak-development&quot;
                servicePort: 53582
              path: &quot;/keycloak-development/(.*)&quot;
</code></pre>
<p>dockerfile</p>
<pre><code>FROM registry.access.redhat.com/ubi8-minimal

ENV KEYCLOAK_VERSION 12.0.1
ENV JDBC_POSTGRES_VERSION 42.2.5
ENV JDBC_MYSQL_VERSION 8.0.22
ENV JDBC_MARIADB_VERSION 2.5.4
ENV JDBC_MSSQL_VERSION 8.2.2.jre11

ENV LAUNCH_JBOSS_IN_BACKGROUND 1
ENV PROXY_ADDRESS_FORWARDING false
ENV JBOSS_HOME /opt/jboss/keycloak
ENV LANG en_US.UTF-8

ARG GIT_REPO
ARG GIT_BRANCH
ARG KEYCLOAK_DIST=https://github.com/keycloak/keycloak/releases/download/$KEYCLOAK_VERSION/keycloak-$KEYCLOAK_VERSION.tar.gz

USER root

RUN microdnf update -y &amp;&amp; microdnf install -y glibc-langpack-en gzip hostname java-11-openjdk-headless openssl tar which &amp;&amp; microdnf clean all 

ADD tools /opt/jboss/tools
ENV KEYCLOAK_USER admin
ENV KEYCLOAK_PASSWORD admin 

RUN /opt/jboss/tools/build-keycloak.sh

USER 1000

EXPOSE 8080
EXPOSE 8443

ENTRYPOINT [ &quot;/opt/jboss/tools/docker-entrypoint.sh&quot; ]

CMD [&quot;-b&quot;, &quot;0.0.0.0&quot;]

</code></pre>
<p>Note:- I am able to access keycloak and admin page with cluster-ip</p>

<p>After finding a lot I found the solution, we need to add these env variables to our deployment.yaml file to work</p>
<ol>
<li>KEYCLOAK_USER</li>
<li>KEYCLOAK_PASSWORD</li>
<li>PROXY_ADDRESS_FORWARDING (value:&quot;true&quot;)</li>
<li>KEYCLOAK_FRONTEND_URL (In my case it was something like this:- <a href="https://my-server.com/keycloak-development/auth/" rel="nofollow noreferrer">https://my-server.com/keycloak-development/auth/</a> )</li>
<li>KEYCLOAK_ADMIN_URL (In my case value for it was something like this:- <a href="https://my-server.com/keycloak-development/auth/realms/master/admin/" rel="nofollow noreferrer">https://my-server.com/keycloak-development/auth/realms/master/admin/</a>)</li>
</ol>
<p>For Docker image you can use (quay.io/keycloak/keycloak:8.0.2)</p>
<p>While accessing the key-cloak application if you are using ingress based routing you need to add /auth/ to your ingress path url to access (Somthing like this:- <a href="https://my-server.com/keycloak-development/auth/" rel="nofollow noreferrer">https://my-server.com/keycloak-development/auth/</a> )</p>
