You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/iot-operations/manage-mqtt-broker/howto-configure-brokerlistener.md
+42-31Lines changed: 42 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,27 +15,27 @@ ms.date: 11/06/2024
15
15
16
16
# Secure MQTT broker communication using BrokerListener
17
17
18
-
To customize the network access and security use the *BrokerListener* resource. A listener corresponds to a network endpoint that exposes the broker to the network. You can have one or more *BrokerListener* resources for each *Broker* resource, and thus multiple ports with different access control each.
18
+
To customize the network access and security use the BrokerListener resource. A listener corresponds to a network endpoint that exposes the broker to the network. You can have one or more BrokerListener resources for each *Broker* resource, and thus multiple ports with different access control each.
19
19
20
-
Each listener port can have its own authentication and authorization rules that define who can connect to the listener and what actions they can perform on the broker. You can use *BrokerAuthentication* and *BrokerAuthorization* resources to specify the access control policies for each listener. This flexibility allows you to fine-tune the permissions and roles of your MQTT clients, based on their needs and use cases.
20
+
Each listener port can have its own authentication and authorization rules that define who can connect to the listener and what actions they can perform on the broker. You can use [BrokerAuthentication](./howto-configure-authentication.md) and [BrokerAuthorization](./howto-configure-authorization.md) resources to specify the access control policies for each listener. This flexibility allows you to fine-tune the permissions and roles of your MQTT clients, based on their needs and use cases.
21
21
22
22
> [!TIP]
23
23
> You can only access the default MQTT broker deployment by using the cluster IP, TLS, and a service account token. Clients connecting from outside the cluster [need extra configuration](./howto-test-connection.md) before they can connect.
24
24
25
-
Listeners have the following characteristics:
25
+
Broker listeners have the following characteristics:
26
26
27
-
-You can have up to three listeners. One listener per service type of `loadBalancer`, `clusterIp`, or `nodePort`. The default *BrokerListener* named *default* is service type `clusterIp`.
28
-
-Each listener supports multiple ports
29
-
-BrokerAuthentication and BrokerAuthorization references are per port
30
-
-TLS configuration is per port
31
-
-Service names must be unique
32
-
-Ports can't conflict over different listeners
27
+
-**Name**: Name of the listener. This name is also the Kubernetes service name [unless overridden](#service-name).
28
+
-**Service type**: You can have up to three listeners, one per [service type](#service-type). The [default listener](#default-brokerlistener) is service type `ClusterIp`.
29
+
-**Ports**: Each listener supports [multiple ports](#ports). Ports [can't conflict over different listeners](#using-same-port-across-listeners).
30
+
-**Authentication and Authorization**: [BrokerAuthentication](./howto-configure-authentication.md) and [BrokerAuthorization](./howto-configure-authorization.md) are configured per port.
31
+
-**TLS**: [Manual](#enable-tls-manual-certificate-management-for-a-port) or [automatic](#enable-tls-automatic-certificate-management-for-a-port) TLS configuration is applied per port.
32
+
-**WebSockets**: [MQTT over WebSockets](#websockets-support)can be enabled per port.
33
33
34
-
For a list of the available settings, see the [Broker Listener](/rest/api/iotoperationsmq/broker-listener) API reference.
34
+
For a list of all available settings, see the [Broker Listener API reference](/rest/api/iotoperationsmq/broker-listener).
35
35
36
36
## Default BrokerListener
37
37
38
-
When you deploy Azure IoT Operations, the deployment also creates a *BrokerListener* resource named `default`. This listener is used to for encrypted internal communication between Azure IoT Operations components. The default listener is part of the [default *Broker*](./overview-broker.md#default-broker-resource), exposes a [ClusterIp service](https://kubernetes.io/docs/concepts/services-networking/service/#type-clusterip) on port 18883, uses [Kubernetes service account authentication](./howto-configure-authentication.md#enable-service-account-token-sat-authentication), has an [automatically managed](#configure-tls-with-automatic-certificate-management) TLS certificate, and doesn't use any authorization.
38
+
When you deploy Azure IoT Operations, the deployment also creates a BrokerListener resource named `default`. This listener is used to for encrypted internal communication between Azure IoT Operations components. The default listener is part of the [default *Broker*](./overview-broker.md#default-broker-resource), exposes a [ClusterIp service](https://kubernetes.io/docs/concepts/services-networking/service/#type-clusterip) on port 18883, uses [Kubernetes service account authentication](./howto-configure-authentication.md#enable-service-account-token-sat-authentication), has an [automatically managed](#configure-tls-with-automatic-certificate-management) TLS certificate, and doesn't use any authorization.
39
39
40
40
> [!CAUTION]
41
41
> To avoid disrupting internal Azure IoT Operations communication, keep the default listener unchanged and dedicated for internal use. For external communication, [create a new listener](#create-new-broker-listeners). If you need to use the ClusterIp service, add more ports to the default listener without changing any of the existing settings.
@@ -126,7 +126,7 @@ az deployment group create --resource-group <RESOURCE_GROUP> --template-file <FI
126
126
127
127
# [Kubernetes](#tab/kubernetes)
128
128
129
-
To view the default *BrokerListener* resource, use the following command:
129
+
To view the default BrokerListener resource, use the following command:
130
130
131
131
```bash
132
132
kubectl get brokerlistener default -n azure-iot-operations -o yaml
To avoid disrupting internal Azure IoT Operations communication, keep the default listener unchanged and dedicated for internal use. For external communication, [create a new listener](#create-new-broker-listeners).
176
+
To prevent disrupting internal Azure IoT Operations communication, keep the default listener unchanged and dedicated for internal use. For external communication, [create a new listener](#create-new-broker-listeners).
177
177
178
-
Since the default *BrokerListener* uses the service type *ClusterIp*, and you can have [only one listener per service type](#service-type), add more ports to the default listener without changing any of the existing settings if you need to use the *ClusterIp* service.
178
+
Since the default broker listener uses the service type ClusterIp, and you can have [only one listener per service type](#service-type), add more ports to the default listener without changing any of the existing settings if you need to use the ClusterIp service.
179
179
180
180
## Create new broker listeners
181
181
182
-
To create a new listener, you need to specify the following settings:
182
+
To create a new listener, specify the following settings:
183
183
184
-
- **Name**: Name of the *BrokerListener* resource. The name must be unique within the namespace.
185
-
- **Service name**: Name of the Kubernetes service that exposes the broker. If left empty, the listener name is used as the service name.
186
-
- **Service type**: Type of the Kubernetes service. Can be `LoadBalancer`, `ClusterIp`, or `NodePort`.
187
-
- **Ports**: List of ports that the listener listens on. Each port can have its own authentication, authorization, and TLS settings.
188
-
- To use your own authentication or authorization setting for a port, you must create the corresponding resources before creating the *BrokerListener* resource. For more information, see [Configure MQTT broker authentication](howto-configure-authentication.md) and [Configure MQTT broker authorization](howto-configure-authorization.md).
189
-
- To use TLS, see [Configure TLS with automatic certificate management](#configure-tls-with-automatic-certificate-management) or [Configure TLS with manual certificate management](#configure-tls-with-manual-certificate-management) sections.
184
+
- **Name**: Name of the listener. This name is also the Kubernetes service name [unless overridden](#service-name).
185
+
- **Service type**: Type of the Kubernetes service. See [Service type](#service-type).
186
+
- **Ports**: List of ports that to listen on. See [Ports](#ports).
187
+
- (Optional) **Service name**: override the Kubernetes service name. See [Service name](#service-name).
190
188
191
-
This example shows how to create a new listener with load balancer service type. The *BrokerListener* resource defines a two ports that accept MQTT connections from clients.
189
+
This example shows how to create a new listener with load balancer service type. The BrokerListener resource defines a two ports that accept MQTT connections from clients.
192
190
193
191
- The first port listens on port 1883 without TLS and authentication. Clients can connect to the broker without encryption or authentication. This setup is suitable for testing only. [Don't use this configuration in production](./howto-test-connection.md#only-turn-off-tls-and-authentication-for-testing).
194
192
- The second port listens on port 8883 with TLS and authentication enabled. Only [authenticated clients with a Kubernetes service account token](./howto-configure-authentication.md#default-brokerauthentication-resource) can connect. TLS is set to [automatic mode](#enable-tls-automatic-certificate-management-for-a-port), using cert-manager to manage the server certificate from the [default issuer](../secure-iot-ops/concept-default-root-ca.md#default-self-signed-issuer-and-root-ca-certificate-for-tls-server-certificates). This setup is closer to a production configuration.
@@ -237,9 +235,10 @@ This example shows how to create a new listener with load balancer service type.
237
235
238
236
Leave other settings as default, and select **Apply**.
239
237
238
+
1. Select **Create listener**.
239
+
240
240
:::image type="content" source="media/howto-configure-brokerlistener/create-loadbalancer.png" alt-text="Screenshot using Azure portal to create MQTT broker for load balancer listener.":::
241
241
242
-
1. Select **Create listener**.
243
242
244
243
# [Bicep](#tab/bicep)
245
244
@@ -332,28 +331,40 @@ spec:
332
331
333
332
## Service type
334
333
335
-
Each BrokerListener maps to a [Kubernetes service](https://kubernetes.io/docs/concepts/services-networking/service/).. The service type determines how the broker is exposed to the network. The three service types are:
334
+
Each BrokerListener maps to a [Kubernetes service](https://kubernetes.io/docs/concepts/services-networking/service/). The service type determines how the broker is exposed to the network. The supported service types are:
336
335
337
336
- **ClusterIp**: Exposes the broker on a cluster-internal IP. Clients can connect to the broker from within the cluster. This is the default service type for the default listener.
338
337
- **NodePort**: Exposes the broker on each node's IP at a static port. Clients can connect to the broker from outside the cluster. This service type is useful for development and testing.
339
338
- **LoadBalancer**: Exposes the broker externally. The service is assigned an external IP address that clients can use to connect to the broker. This is the most common service type for production deployments.
340
339
341
-
Only one listener per service type is allowed. If you need more connectivity of the same service type, add more ports to the existing listener.
340
+
### Only one listener per service type
341
+
342
+
Only one listener per service type is allowed. If you need more connectivity of the same service type, add more ports to the existing listener of that service type.
342
343
343
344
## Service name
344
345
345
-
The service name is the name of the Kubernetes service that exposes the broker. If left empty, the broker listener name is used as the service name. The service name must be unique within the namespace.
346
+
The service name is the name of the Kubernetes service that exposes the broker. If not specified, the broker listener name is used as the service name. The service name must be unique within the namespace.
346
347
347
348
> [!TIP]
348
349
> To prevent management overhead, we recommend leaving the service name empty. The listener name is unique and can be used to identify the service. Use the service name as an override only when you can't name the service after the listener.
349
350
350
351
## Ports
351
352
352
-
Each listener can have multiple ports, but each port number must be unique within the Azure IoT Operations MQTT broker. For example, if you have a NodePort listener using port 1883, you can't create another LoadBalancer listener with port 1883. Similarly, the default listener uses port 18883, so you can't create another listener with port 18883.
353
+
Each listener can have multiple ports, and each port can have its own settings for authentication, authorization, websockets, and TLS.
354
+
355
+
To use your own authentication or authorization setting for a port, you must create the corresponding resources before using it with a listener. For more information, see [Configure MQTT broker authentication](howto-configure-authentication.md) and [Configure MQTT broker authorization](howto-configure-authorization.md).
356
+
357
+
To use TLS, see [Configure TLS with automatic certificate management](#configure-tls-with-automatic-certificate-management) or [Configure TLS with manual certificate management](#configure-tls-with-manual-certificate-management) sections.
358
+
359
+
### Using same port across listeners
360
+
361
+
Using the same port number across different listeners isn't supported. Each port number must be unique within the Azure IoT Operations MQTT broker.
362
+
363
+
For example, if you have a listener using port 1883, you can't create another listener with port 1883. Similarly, the default listener uses port 18883, so you can't create another listener with port 18883.
353
364
354
365
## WebSockets support
355
366
356
-
Azure IoT Operations MQTT broker supports MQTT over WebSockets. To enable WebSockets, set the protocol to `WebSockets` in the port settings.
367
+
Azure IoT Operations MQTT broker supports MQTT over WebSockets. To enable WebSockets, set the protocol to `WebSockets` for the port.
357
368
358
369
## Configure TLS with automatic certificate management
359
370
@@ -896,7 +907,7 @@ az deployment group create --resource-group <RESOURCE_GROUP> --template-file <FI
896
907
897
908
# [Kubernetes](#tab/kubernetes)
898
909
899
-
Modify the `tls` setting in a *BrokerListener* resource to specify manual TLS configuration referencing the Kubernetes secret. Note the name of the secret used for the TLS server certificate (`server-cert-secret` in the example previously).
910
+
Modify the `tls` setting in a BrokerListener resource to specify manual TLS configuration referencing the Kubernetes secret. Note the name of the secret used for the TLS server certificate (`server-cert-secret` in the example previously).
Once the *BrokerListener* resource is created, the operator automatically creates a Kubernetes service and deploys the listener. You can check the status of the service by running `kubectl get svc`.
930
+
Once the BrokerListener resource is created, the operator automatically creates a Kubernetes service and deploys the listener. You can check the status of the service by running `kubectl get svc`.
0 commit comments