Handle exposing ports on kubernetese in bare metal

3/18/2021

I have 1 master and 2 worker on my k8s cluster.It's bare metal and I can't use any of cloud providers. I just can use DNS load balancer. I want to expose valid ports (like 80 and 443) on my nodes because of that I can't use NodePort. What is the best solution?

My only solution was to install Nginx on all of my nodes and proxy ports to my ClusterIp services.I don't know that this is a good solution or not.

enter image description here

-- heydar dasoomi
docker
kubernetes
nginx

2 Answers

3/19/2021

I found the solution. I need to edit /etc/kubernetes/manifests/kube-apiserver.yaml and edit service-node-port-range to 80 to any number that I want. Then declare my ingress service as nodePort.

-- heydar dasoomi
Source: StackOverflow

3/18/2021

Following things that you are doing right :

  1. Cluster IP service - If you don't want to expose your services to be invoked form outside the cluster, CLusterIP is right way instead of NodePort or LoadBalancer.

Following things that you can do:

  1. Create an Ingress Controller and and Ingress resource for your cluster which will listen on port 80 and 443 and proxy the requests to your services according to routes mentioned in the ingress.
  2. You can create inginx-ingress controller using link: https://kubernetes.github.io/ingress-nginx/deploy/
  3. Then create an Ingress resource using link https://kubernetes.io/docs/concepts/services-networking/ingress/
-- Gautam Rajotya
Source: StackOverflow