Score:0

How do I create an internal Layer 4 load balancer in Kubernetes?

au flag

I am trying to create an internal (no external IP) layer 4 load balancer in AWS - either a Network LB or Classic LB - for internal traffic management instead of using the kube-proxy.

Below is my manifest file - it keeps creating an external LB regardless of how I specify the annotations. I have tried this without the "aws-load-balancer-type" annotation as well as the "aws-load-balancer-scheme", which is supposed to default to "internal". I am not sure what to try next. (I will probably try a layer 7 LB next.)

% k get svc|grep test
test-internal-lb                      LoadBalancer   10.100.253.178   a29xxx.us-west-2.elb.amazonaws.com    80:xxx/TCP,443:xxx/TCP   8s
apiVersion: v1
kind: Service
metadata:
  name: test-internal-lb
  annotations:
    service.beta.kubernetes.io/aws-load-balancer-nlb-target-type: ip
    service.beta.kubernetes.io/aws-load-balancer-scheme: internal
    service.beta.kubernetes.io/aws-load-balancer-type: nlb-ip
spec:
  type: LoadBalancer
  selector:
    app: test-app
  ports:
  - name: http
    protocol: TCP
    port: 80
    targetPort: 8080
  - name: https
    protocol: TCP
    port: 443
    targetPort: 8080
Nova avatar
au flag
It looks like this cannot be done within Kubernetes. I know I can create an internal NLB or CLB with the AWS CLI or console and set up the correct configs and tags, but every document I have found is outdated. Setting "aws-load-balancer-scheme" to "internal" does not work, nor do other configurations. They all create external LBs.
knowdotnet avatar
ne flag
i also looking for a fix. I need to create Private Load balancer service for my pods and service is will front with api gateway. This api gateway will have Public IP exposed.
Nova avatar
au flag
@knowdotnet I posted my solution below.
Score:1
au flag

SOLUTION:

test-app            LoadBalancer   172.20.40.154    internal-a03xxx.us-west-2.elb.amazonaws.com   80:8000/TCP   11d
kind: Service
metadata:
  name: test-app
  annotations:
    service.beta.kubernetes.io/aws-load-balancer-internal: “true”
    service.beta.kubernetes.io/aws-load-balancer-backend-protocol: "http"
spec:
  type: LoadBalancer
  externalTrafficPolicy: Local
  selector:
    app: test-app
  ports:
  - name: http
    protocol: TCP
    port: 80
    targetPort: 8000
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.