
How to Setup an Ingress Controller in Kubernetes in BareMetal
Sep 15
2 min read
0
28
What is Ingress Controller?
A Kubernetes Ingress Controller is a specialized application that runs within a Kubernetes cluster and acts as a reverse proxy and load balancer for external traffic. Its primary function is to implement the rules defined in Kubernetes Ingress resources, which specify how external HTTP and HTTPS traffic should be routed to services running within the cluster.
What are the benefits of Ingress Controller?
Provides secure access to services over HTTP or HTTPS paths, instead of using direct connections.
Creates access routes to multiple services, with full control over routing of services and conditions for external access.
What is an example use case?
Assuming you are a financial institution that provides Open Banking API to third-party developers for payments and fund transfer API. And that your company wanted to keep their domain uniform for all their services e.g. yourdomain.io.
Through the use of ingress controller the company can expose their API to third party in this format:
Through ingress controller. The url has been simplified and will resolve internally to the target service in Kubernetes.
Steps on How to Setup an Ingress Controller in Kubernetes?

Before installing Ingress Controller on Bare Metal, make sure to setup a Load Balancer capability using MetalLb. You can follow this tutorial that I created previously(Configure Load Balancer using MetalLB in Bare Metal Kubernetes Cluster). See image above for the HL architecture of our setup.
Step 1: Install Ingress Controller
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.13.2/deploy/static/provider/baremetal/deploy.yamlStep 2: Check Your Ingress Controller
kubectl get pods --namespace=ingress-nginxStep 3: Test your Ingress Controller
3.1 Create a Deployment and Service named payment
kubectl create deployment payment --image=httpd --port=80 --replicas=3kubectl expose deployment payment --port=8080 --target-port=80 --type=ClusterIP3.2 Create a Deployment and Service named fundtransfer
$ kubectl create deployment fundtransfer --image=httpd --port=80 --replicas=3kubectl expose deployment fundtransfer --port=8080 --target-port=80 --type=ClusterIP3.2 Create a route to the two services by creating Ingress Resource
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
name: ingress-banking
namespace: development
spec:
ingressClassName: nginx
rules:
- host: bank.cloudlet.io
http:
paths:
- backend:
service:
name: payment
port:
number: 80
path: /payment
pathType: Exact
- backend:
service:
name: fundtransfer
port:
number: 80
path: /fundtransfer
pathType: Exact3.3 Access the Two Services via Ingress in your Web Browser
Make sure to include the new domain that you had used to your DNS, if you are testing this locally without DNS, you may test it in by adding entry /etc/