In bare metal installations is not possible to use Ingress by default, you need to use MetalLB.

Here is all service types and how that works:

  • ClusterIP: Exposes the Service on a cluster-internal IP. Choosing this value makes the Service only reachable from within the cluster. This is the default ServiceType.
  • NodePort: Exposes the Service on each Node’s IP at a static port (the NodePort). A ClusterIP Service, to which the NodePort Service routes, is automatically created. You’ll be able to contact the NodePort Service, from outside the cluster, by requesting <NodeIP>:<NodePort>.
  • LoadBalancer: Exposes the Service externally using a cloud provider’s load balancer. NodePort and ClusterIP Services, to which the external load balancer routes, are automatically created

How to use LoadBalancer and Ingress in bare metal installations?

The Nginx docs shows how to setup MetalLB to allow your bare metal cluster the usage of LoadBalancer Services.

MetalLB provides a network load-balancer implementation for Kubernetes clusters that do not run on a supported cloud provider, effectively allowing the usage of LoadBalancer Services within any cluster.

Basically, the setup is easy:

kubectl apply -f https://raw.githubusercontent.com/google/metallb/v0.8.3/manifests/metallb.yaml

And then create a ConfigMap to configure: - Edit the ip range according yout network

apiVersion: v1
kind: ConfigMap
metadata:
  namespace: metallb-system
  name: config
data:
  config: |
    address-pools:
    - name: default
      protocol: layer2
      addresses:
      - 192.168.1.240-192.168.1.250 <= EDIT IP RANGE

Check the installation typing kubectl get pods -n metallb-system, this is an expected output:

$ kubectl get pods -n metallb-system
NAME                          READY   STATUS    RESTARTS   AGE
controller-65895b47d4-6wzfr   1/1     Running   0          9d
speaker-v52xj                 1/1     Running   0          9d

After MetalLB installed and configured can install Nginx Ingress following the nginx docs:

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.29.0/deploy/static/mandatory.yaml

And then:

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.29.0/deploy/static/provider/baremetal/service-nodeport.yaml

If you prefer, you could use Helm:

helm install my-nginx stable/nginx-ingress

If the kubernetes cluster has RBAC enabled, then run:

helm install my-nginx stable/nginx-ingress --set rbac.create=true

If you are using Helm 2 then specify release name using --name flag

helm install stable/nginx-ingress --name my-nginx

or

helm install stable/nginx-ingress --name my-nginx --set rbac.create=true

Detect installed version:

POD_NAME=$(kubectl get pods -l app.kubernetes.io/name=ingress-nginx -o jsonpath='{.items[0].metadata.name}') kubectl exec -it $POD_NAME -- /nginx-ingress-controller --version

Check your ingress with the command kubectl get ing and look for in EXTERNAL-IP column.

References:

https://kubernetes.github.io/ingress-nginx/deploy/

https://metallb.universe.tf/