I am using multiple pods and their services, some of the services are of the type load balancer, which will expose the public IP.
But many of the services are called internally and no need to use public IP instead I can use private IP, what change do I need to make to the load balancer to use private IP.
I assume, the load balancer cost more compared to other types of services in the aks cluster.
Please let me know how to reduce the cost
3
Answers
Just do not annotate the services with
type: LoadBalancer
but instead usetype: ClusterIP
You can annotate the service so that the Loadbalancer gets an private IP from your subnet:
You can also check the docs here.
One hint: you should only expose the service from your Ingress Controller and not Services directly, This is an Kubernetes anti-pattern and insecure.
Declare
type:ClusterIP
instead oftype:LoadBalancer
underkind:Service
It will generate Private IP for the service, which can be accessed with either IP or name of service.