ServiceTypes the NodePort and LoadBalancer are the most often used.LoadBalancer ServiceType, we need to have support from the underlying infrastructure. Even after having the support, we may not want to use it for every Service, as LoadBalancer resources are limited and they can increase costs significantly.NodePort ServiceType can also be tricky at times, as we need to keep updating our proxy settings and keep track of the assigned ports.Ingress resource.“An Ingress is a collection of rules that allow inbound connections to reach the cluster Services.”
Layer 7 HTTP/HTTPS load balancer for Services and provides the following:
- TLS (Transport Layer Security)
- Name-based virtual hosting
- Fanout routing
- Loadbalancing
- Custom rules.

Name-Based Virtual Hosting Ingress definition below:apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: virtual-host-ingress
namespace: default
spec:
rules:
- host: blue.example.com
http:
paths:
- backend:
service:
name: webserver-blue-svc
port:
number: 80
path: /
pathType: ImplementationSpecific
- host: green.example.com
http:
paths:
- backend:
service:
name: webserver-green-svc
port:
number: 80
path: /
pathType: ImplementationSpecific
blue.example.com and green.example.com would go to the same Ingress endpoint, and, from there, they would be forwarded to webserver-blue-svc, and webserver-green-svc, respectively.Name-Based Virtual Hosting Ingress rule:
example.com/blue and example.com/green would be forwarded to webserver-blue-svc and webserver-green-svc, respectively:apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: fan-out-ingress
namespace: default
spec:
rules:
- host: example.com
http:
paths:
- path: /blue
backend:
service:
name: webserver-blue-svc
port:
number: 80
pathType: ImplementationSpecific
- path: /green
backend:
service:
name: webserver-green-svc
port:
number: 80
pathType: ImplementationSpecific

$ minikube addons enable ingress
kubectl create command.virtual-host-ingress.yaml file with the Name-Based Virtual Hosting Ingress rule definition that we saw in the Ingress section, then we use the following command to create an Ingress resource:$ kubectl create -f virtual-host-ingress.yaml
webserver-blue-svc or webserver-green-svc services using the blue.example.com and green.example.com URLs./etc/hosts on Mac / Windows / Linux) on our workstation to the Minikube IP for those URLs.$ sudo vim /etc/hosts
127.0.0.1 localhost
::1 localhost
192.168.99.100 blue.example.com green.example.com
blue.example.com and green.example.com on the browser and access each application.By the end of this chapter, you should be able to: