I've install Kubernetes and Metalb and ingress services and controllers on my ubuntu server and I want to connect domains to my service with ingress in my Kubernetes. The problem is that when I map a domain to a service, when I can get the domain on my server with changing the host file and connecting domain to external ip of ingress controller , it connects to the domain, but when I enter domain on my browser it on my local computer, for testing it. And I change the host file so that it reads from the server and I type the domain, for example localhost.com, it goes to the 404 page of nginx, and when I type localhost.com:33721, which is the node port of the ingress controller, it connects to my service. Does anyone know where the problem is or how I can map my service to my domain correctly? Am I correct with this or what is the best practice to map domain to my service?
I tried Many things i change the type of ingress controller to loadbalancer or node port and i tried to do port forward so that my server directly forward to ip of my ingress controller and many things else
Even if domain name
my.domain.comcan be an internal or intranet domain name, resolved by a company's internal DNS server, you would still need an Ingress Controller to handle traffic that originates "outside" of the Kubernetes cluster, even though it is within the same private network.So you would still generally use a
LoadBalancerorNodePortservice for the Ingress Controller, andClusterIPservices for your application services inside the cluster.Meaning the
my.domain.comneeds to be configured on the company's internal DNS server to resolve to the IP address of the Ingress Controller's service. Then:my.domain.comto a particular service within the cluster (let's call it my-service).my-service.my-service, which is typically of typeClusterIP, receives the request and sends it to the appropriate pod.The Ingress Controller could be a
LoadBalancerservice if the Kubernetes cluster is running in a cloud environment that supports it, or it could be aNodePortservice if running in an environment that does not support LoadBalancers (like a bare-metal cluster).MetalLB is a load balancer implementation for bare metal Kubernetes clusters. It aims to provide the services of a
LoadBalancerfor these clusters which typically do not have a native load balancer available like those in cloud environments.So in the context of a bare metal Kubernetes cluster using MetalLB, you would typically use a
LoadBalancerservice, not aNodePortservice, for your Ingress controller.Check you current setup with:
Compare it with a typical setup, assuming that your Ingress controller (e.g., NGINX or Traefik) is already installed and configured correctly:
my-app-deployment.yaml: This file contains the definition of the Deployment for your application.my-service.yaml: This file contains the definition of the Service that exposes your application within the cluster.my-ingress.yaml: This file contains the definition of the Ingress that exposes your service to the outside world.In your DNS, my.domain.com should point to the external IP provided by MetalLB for your Ingress controller. If you are testing locally and have no DNS set up, you can add an entry to your hosts file with the format
<ip-address> my.domain.comwhere<ip-address>is the external IP of your Ingress controller.