<p>I am creating a service in kubernetes. How can I change the Classic Load Balancer to Network Load Balancer? I am turning to network load balancer for the external client ip it provides. I use AWS. Here is my configuration:</p>
<pre><code>apiVersion : apps/v1
kind: Deployment
metadata:
  name: my-web-deployment-multi-pod
  labels:
    app : my-k8s-deployment
spec:
  replicas: 3
  selector:
    matchLabels:
      project: cia
  template:
    metadata:
      labels:
        project: cia
    spec:
      containers:
        - name : my-web
          image: adv4000/k8sphp:latest
          ports:
            - containerPort: 80   # Port on Pod

        - name : not-my-web
          image: tomcat:8.5.38
          ports:
            - containerPort: 8080  # Port on Pod



apiVersion: v1
kind: Service
metadata:
  name: my-multi-pods-service
spec:
  type: LoadBalancer
  selector:
    project: cia
  ports:
    - name      : my-web-app-listener
      protocol  : TCP
      port      : 80
      targetPort: 80

    - name      : not-my-web-app-listener
      protocol  : TCP
      port      : 8888
      targetPort: 8080
</code></pre>

AlexWhite
<p>To use a Network Load Balancer on AWS, use the annotation <code>service.beta.kubernetes.io/aws-load-balancer-type</code> with the value set to <code>nlb</code>.</p>
<p>Your service would end up looking like something below:</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: my-multi-pods-service
  annotations:
    service.beta.kubernetes.io/aws-load-balancer-type: &quot;nlb&quot;
spec:
  type: LoadBalancer
  selector:
    project: cia
  ports:
    - name      : my-web-app-listener
      protocol  : TCP
      port      : 80
      targetPort: 80

    - name      : not-my-web-app-listener
      protocol  : TCP
      port      : 8888
      targetPort: 8080
</code></pre>
<p>For further read, look at this: <a href="https://kubernetes.io/docs/concepts/services-networking/service/#aws-nlb-support" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/services-networking/service/#aws-nlb-support</a></p>
