# Keycloak on kubernetes: ingress vs internal service

**URL:** <https://forum.keycloak.org/t/keycloak-on-kubernetes-ingress-vs-internal-service/956>\
**Category:** Getting advice\
**Created:** [January 15, 2020, 8:37am UTC](https://forum.keycloak.org/t/keycloak-on-kubernetes-ingress-vs-internal-service/956 "2020-01-15T08:37:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![wodec](https://avatars.discourse-cdn.com/v4/letter/w/22d042/32.png) [@wodec](https://forum.keycloak.org/u/wodec)\
**Post date:** [January 15, 2020, 8:37am UTC](https://forum.keycloak.org/t/keycloak-on-kubernetes-ingress-vs-internal-service/956/1 "2020-01-15T08:37:26Z")

</div>

Hello,

We are currently setting up Keycloak on a kubernetes cluster as an openid provider.  
However, we’re running into some issues regarding the external url of keycloak for authentication (through ingress) versus the internal url (service) of keycloak within the namespace.

We have one namespace that contains both our keycloak instance and our api gateway (tyk in this case).  
In this namespace we also have a web app.  
All of them are reachable using path based routing, so let’s say:  
[https://external-domain/auth](https://external-domain/auth) is keycloak, [https://external-domain/app](https://external-domain/app) is our webapp.

Authenticating against keycloak works perfectly, we can authenticate in the webapp and login. However, then the api gateway tries to validate the authenticated token against keycloak once the webapp tries to talk to the backend api’s behind the api gateway.

The problem here is that the validation URL is retrieved by tyk from the token and it points to the external keycloak url, through the ingress.  
Obviously tyk can not reach this endpoint, since it’s in the same namespace and should validate against keycloak using the internal, service-based, URL. Therefore token validation fails and the user gets kicked out of the webapp again.

Anyone else in this situation? Any recommendations on how to handle this scenario? Is there a config possible in keycloak to handle something like this?

Thanks in advance for any feedback!

---

<div class="post-metadata">

**Author:** ![hkdeman](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/hkdeman/32/1072_2.png) [@hkdeman](https://forum.keycloak.org/u/hkdeman)\
**Post date:** [July 2, 2020, 12:39am UTC](https://forum.keycloak.org/t/keycloak-on-kubernetes-ingress-vs-internal-service/956/2 "2020-07-02T00:39:01Z")

</div>

I am facing the same issue. Did you manage to fix it?

---

<div class="post-metadata">

**Author:** ![blaisep-vgs](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/blaisep-vgs/32/1581_2.png) [@blaisep-vgs](https://forum.keycloak.org/u/blaisep-vgs)\
**Post date:** [October 26, 2020, 6:52pm UTC](https://forum.keycloak.org/t/keycloak-on-kubernetes-ingress-vs-internal-service/956/3 "2020-10-26T18:52:37Z")

</div>

I wonder about the same thing, @hkdeman…  
We might want to mention @wodec by name to see if they get the message that way.

@wodec, did you figure out how to separate the URLs ?
