Home > Net >  Helm, Kubernetes, how to configure Pod to access a service outside the cluster?
Helm, Kubernetes, how to configure Pod to access a service outside the cluster?

Time:12-02

There is a lot of sources that clarify how to connect into the cluster. But when searching for information about how to connect from inside the cluster to outside the search results are polluted with the opposite information.

I want to connect my custom service that is running inside the cluster to my keycloack that is outside of the cluster on my local machine. There is no option of running keycloak inside the cluster. I am using Docker desktop for Mac to run kubernetes.

CodePudding user response:

There is no option of running keycloak inside the cluster.

Not sure may you have checked or not, you can run the keycloak on the Kubernetes.

You can refer my Github repo to get YAML files and deployment keycloak on Kubernetes : https://github.com/harsh4870/Keycloack-postgres-kubernetes-deployment

Generally, you can use the external service, if you are diverting the traffic out of the cluster.

If you are running on a Public K8s cluster on any cloud provider service will be directly able to access the external service over IP without external service creation.

Example

apiVersion: v1
kind: Service
metadata:
  name: local-host
spec:
    type: ExternalName
    externalName: 192.168.0.1

If you don't want to pass the IP in external service you can give any domain name map details in /etc/hosts files too. ref doc

Now if you Keycloak is running on Host machine (localhost) you can use the IP directly.

If you are using the minikube you can use the host.minikube.internal as host. ref doc

host.minikube.internal:<Port of keycloak>
  • Related