apiVersion: v1
kind: Service
metadata:
  name: tb-mqtts-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
    # Don't forget to replace YOUR_MQTTS_CERTIFICATE_ARN with the correct value
    service.beta.kubernetes.io/aws-load-balancer-ssl-cert: YOUR_MQTTS_CERTIFICATE_ARN
    service.beta.kubernetes.io/aws-load-balancer-backend-protocol: "tcp"
    service.beta.kubernetes.io/aws-load-balancer-ssl-ports: "mqtts"
spec:
  type: LoadBalancer
  externalTrafficPolicy: Local
  selector:
    app: tb-node
  ports:
    - port: 1883
      targetPort: 1883
      name: mqtt
    # This way NLB acts as an TLS termination point and forwards decrypted traffic to 1883 port of ThingsBoard MQTT Transport.
    - port: 8883
      targetPort: 1883
      name: mqtts
