Skip to content

Request help: stream_proxy(mqtt_proxy) do not support dns resolv。 #3964

Description

@souzens

Issue description

Background:
This is the requirement for developer in our company. It is necessary to deploy the mqtt service inside the k8s cluster with container, the conventional practice in the past is to create loadbalancer service to expose nodeport, but it is troublesome for operation and maintenance. The current api entry is unified by apisix, and apisix also has mqtt_proxy plugin, so just to try it.

During the deployment process, many problems were encountered.

FIrst question:
Apply the plugin of mqtt_proxy to the route through the apisix-dashboard, but it does not actually take effect

./etcdctl --endpoints=10.111.9.154:2379 get /apisix/routes/348239466273440537 --prefix
/apisix/routes/348239466273440537

{"id":"348239466273440537","create_time":1617096496,"update_time":1617255551,"uris":["/*"],"name":"mqtt_test","desc":"xxxxx","methods":["GET","HEAD","POST","PUT","DELETE","OPTIONS","PATCH"],"hosts":["mqtttest.test.com"],"vars":[],"plugins":{"mqtt-proxy":{"disable":false,"protocol_level":4,"protocol_name":"MQTT","upstream":{"ip":"172.20.250.158","port":1883}}},"upstream":{"nodes":[{"host":"mqtt.test.svc.cluster.local","port":8080,"weight":1}],"timeout":{"connect":6000,"read":6000,"send":6000},"type":"roundrobin","pass_host":"pass"},"labels":{"domain":"test.com"},"status":1}

Second question:
Add stream_route through api, the ip field of upstream does not support domain name, ip must be used
In view of this problem, it is not convenient to use it in k8s. It is well known that the service domain name can be used for calls within the cluster.

./etcdctl --endpoints=10.111.9.154:2379 get /apisix/stream_routes --prefix
/apisix/stream_routes/1
{"id":"1","plugins":{"mqtt-proxy":{"upstream":{"ip":"mqtt.test.svc.cluster.local","port":1883},"protocol_name":"MQTT","protocol_level":4}}}

apisix error_log

2021/04/01 13:27:50 [warn] 2760#2760: *168 stream [lua] upstream.lua:193: set_upstream(): upstream node has been specified, cannot be set repeatedly while prereading client data, client: 10.254.6.185, server: 0.0.0.0:9100
2021/04/01 13:27:50 [error] 2760#2760: *168 stream [lua] balancer.lua:208: load_balancer(): failed to set server peer [mqtt.test.com:1883] err: no host allowed while connecting to upstream, client: 10.254.6.185, server: 0.0.0.0:9100, bytes from/to client:0/0, bytes from/to upstream:0/0

Environment

  • apisix version (cmd: apisix version): 2.4
  • OS (cmd: uname -a): centos & k8s

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions