apiVersion: v1
kind: Service
metadata:
  name: tb-mqtt-loadbalancer
  namespace: thingsboard
  annotations:
    service.beta.kubernetes.io/aws-load-balancer-type: "nlb"
    service.beta.kubernetes.io/aws-load-balancer-cross-zone-load-balancing-enabled: "true"
    service.beta.kubernetes.io/aws-load-balancer-target-group-attributes: "stickiness.enabled=true,stickiness.type=source_ip"
    service.beta.kubernetes.io/aws-load-balancer-additional-resource-tags: ThingsBoardClusterELB=ThingsBoardMqtt
spec:
  type: LoadBalancer
  externalTrafficPolicy: Local
  selector:
    app: tb-node
  ports:
    - port: 1883
      targetPort: 1883
      name: mqtt
    # This way NLB acts as transparent load balancer and forwards all traffic to port 8883 without decryption.
    - port: 8883
      targetPort: 8883
      name: mqtts