Let's create an internal load balancer for the previous nginx pod. In order to use an internal load balancer, you need to add an annotation (service.beta.kubernetes.io/aws-load-balancer-internal: 0.0.0.0/0), as follows:
$ cat internal-elb.yaml
apiVersion: v1
kind: Service
metadata:
name: nginx
annotations:
service.beta.kubernetes.io/aws-load-balancer-internal: 0.0.0.0/0
spec:
ports:
- protocol: TCP
port: 80
type: LoadBalancer
selector:
project: devops-with-kubernetes
app: nginx
$ kubectl create -f internal-elb.yaml
service "nginx" created
Then, the EKS Cloud provider will create and configure a classic ELB as in the following screenshot:
Since it's an internal ELB, you can't gain access to the ELB from outside of the AWS network, for example, from your laptop. However, it's useful to expose your application to the outside of the Kubernetes cluster within VPC.
The AWS charges ELB per hour. If your Kubernetes Service serves within Kubernetes cluster pods, you may consider using type:ClusterIP.