We've got a dev environment setup in which a part of our services are inside Kubernetes (using kind) and a part of it is not. Inside the Kubernetes pod, a request is made to a certain host (localdev.companyName.com), we own this domain and return 127.0.0.1 everytime a request is made (this was to avoid having to resolve host locally in dev computers).
While this is fine when we run our docker instances on the host ( app instance is listening on 127.0.0.1 on port 80, so the frontends can easily communicate ), this is not okay when we want to make a network request from inside the Kubernetes pod to that app instance.
This is due to the fact that 127.0.0.1 inside the kubernetes cluster is not associated to any docker instance, and we need the docker instance from the host. So my question is how can I configure my pod to resolve localdev.companyName.com to the loopback address of the host instead of Kubernetes node one ?
I tried ExternalName with the following configurations to no avail ( it's a Terraform Code )
resource "kubernetes_service" "my-service-external-name" {
metadata {
name = "my-service-external-name-external-name"
namespace = namespace name
enter code here
annotations = {
"app.kubernetes.io/name" = "localdev.companyName.com"
}
}
spec {
type = "ExternalName"
external_name = "host.docker.internal"
}
}
I've also researched about headless services. I've read this question too.