**Install Ingress Controller:**
First, you need an Ingress Controller running in your cluster (It is required as it fullfil user request when you request myapp.example.com). Common Ingress controllers include:
* NGINX Ingress Controller
* HAProxy Ingress Controller
* Traefik Ingress Controller
For example, to install NGINX Ingress, you can use Helm (package builder):
Commands:
```bash=
helm repo add ingress-nginx https://kubernetes.github.io/ingress-ngin
helm repo update
helm install nginx-ingress ingress-nginx/ingress-nginx
```
Pre-Requirements:
* Deployment & service are running for a sample NGINX application.
* deployment name: nginx-deployment
* app: ngnix
* containerPort:80
1. **Create a Service:** You need to have a service that exposes the app within the cluster. This service should be of type ClusterIP.(Exposing service on internal IP)
**nginx-service.yaml:**
```yaml!=
apiVersion: v1
kind: Service
metadata:
name: nginx-service
spec:
selector:
app: nginx
ports:
- protocol: TCP
port: 80
targetPort: 80
```
This service exposes the containerPort:80 to the internal cluster.
2. **Create Ingress Service:**
Now, let’s create an Ingress resource to expose the NGINX application to the outside world via HTTP.
**nginx-ingress.yaml:**
```yaml=
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: nginx-ingress
spec:
rules:
- host: myapp.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: nginx-service
port:
number: 80
```
3. DNS Configuration:
--> mapping the IP to the hostname.
`vim /etc/hosts`
add this line
<INGRESS_EXTERNAL_IP> myapp.example.com
Once the Ingress resource is created, you should be able to access your app by hitting the domain you've specified in the Ingress rule (myapp.example.com). The NGINX Ingress Controller (using the nginx-ingress.yaml service) will route the request to the appropriate service(nginix-service.yaml) which will resolve to your request inside the cluster.