apiVersion: v1
kind: Service
metadata:
  name: mosquitto-service
  namespace: iot
spec:
  type: NodePort
  selector:
    app: mosquitto
  ports:
      # By default and for convenience, the `targetPort` is set to the same value as the `port` field.
    - name: mqtt-srv
      port: 31883
      targetPort: mosq-prt
      protocol: TCP
      # Optional field
      # By default and for convenience, the Kubernetes control plane will allocate a port from a range (default: 30000-32767)
      nodePort: 31883
  externalIPs:
    - 192.168.0.4
    - 192.168.0.3
    - 192.168.0.2