Kubernetes Route to Service using Ingress hostname | Keycloak

717 views Asked by At

What field should I add to the service / ingress yaml so that I can reach the service from another pod in the same cluster using its associated (external) hostname specified in ingress?

I'm using microk8s with the default ingress class (nginx), and I need a solution that works in any kubernetes platform (azure, gke, aks)

I need to reach my authentication server (keycloak) from my nodejs application, using ingress hostname. I can't use service name, because the token validation would fail (JWT ISS checking).

thanks!

1

There are 1 answers

0
Piotr Malec On

Based on this SO post this can be done using Helm custom values and hostAliases.

A helm templated solution to the original question. I tested this with helm 3.

apiVersion: apps/v1
kind: Deployment
spec:
  template:
    spec:
    {{- with .Values.hostAliases }}
      hostAliases:
{{ toYaml . | indent 8 }}
    {{- end }}

For values such as:

hostAliases:
  - ip: "10.0.0.1"
    hostnames:
    - "host.domain.com"

If the hostAliases is omitted or commented out in the values, the hostAliases section is omitted when the template is rendered.