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
+39-55Lines changed: 39 additions & 55 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,15 @@ To customize the network access and security use the **BrokerListener** resource
20
20
21
21
Each listener 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.
22
22
23
+
Listeners have the following characteristics:
24
+
25
+
- You can have up to three listeners. One listener per service type of `loadBalancer`, `clusterIp`, or `nodePort`. The default *BrokerListener* named *listener* is service type `clusterIp`.
26
+
- Each listener supports multiple ports
27
+
- AuthN and authZ references are per port
28
+
- TLS configuration is per port
29
+
- Service names must be unique
30
+
- Ports cannot conflict over different listeners
31
+
23
32
The *BrokerListener* resource has these fields:
24
33
25
34
| Field Name | Required | Description |
@@ -50,7 +59,7 @@ The *BrokerListener* resource has these fields:
50
59
| ports.tls.manual | No | Manual TLS server certificate management through a defined secret. For more information, see [Configure TLS with manual certificate management](howto-configure-tls-manual.md).|
51
60
| ports.tls.manual.secretName | Yes | Kubernetes secret containing an X.509 client certificate. This is a reference to the secret through an identifying name, not the secret itself. |
52
61
| ports.tls.manual.secretNamespace | No | Certificate K8S namespace. Omit to use current namespace. |
53
-
| serviceName | No | The name of Kubernetes service created for this listener. Kubernetes creates DNS records for this `serviceName` that clients should use to connect to MQTT broker. This subfield is optional and defaults to `aio-mq-dmqtt-frontend`. Important: If you have multiple listeners with the same `serviceType` and `serviceName`, the listeners share the same Kubernetes service. For more information, see [Service name and service type](#service-name-and-service-type). |
62
+
| serviceName | No | The name of Kubernetes service created for this listener. Kubernetes creates DNS records for this `serviceName` that clients should use to connect to MQTT broker. This subfield is optional and defaults to `aio-mq-dmqtt-frontend`. |
54
63
| serviceType | No | The type of the Kubernetes service created for this listener. This subfield is optional and defaults to `clusterIp`. Must be either `loadBalancer`, `clusterIp`, or `nodePort`. |
55
64
56
65
## Default BrokerListener
@@ -74,28 +83,28 @@ metadata:
74
83
spec:
75
84
brokerRef: broker
76
85
ports:
77
-
- authenticationRef: authn
78
-
port: 8883
79
-
protocol: Mqtt
80
-
tls:
81
-
automatic:
82
-
issuerRef:
83
-
apiGroup: cert-manager.io
84
-
kind: Issuer
85
-
name: mq-dmqtt-frontend
86
-
mode: Automatic
87
-
serviceName: aio-mq-dmqtt-frontend
88
-
serviceType: ClusterIp
86
+
- authenticationRef: authn
87
+
port: 8883
88
+
protocol: Mqtt
89
+
tls:
90
+
automatic:
91
+
issuerRef:
92
+
apiGroup: cert-manager.io
93
+
kind: Issuer
94
+
name: mq-dmqtt-frontend
95
+
mode: Automatic
96
+
serviceName: aio-mq-dmqtt-frontend
97
+
serviceType: ClusterIp
89
98
```
90
99
91
100
To learn more about the default BrokerAuthentication resource linked to this listener, see [Default BrokerAuthentication resource](howto-configure-authentication.md#default-brokerauthentication-resource).
92
101
93
102
## Create new BrokerListeners
94
103
95
-
This example shows how to create two new *BrokerListener* resources for a *Broker* resource named *my-broker*. Each *BrokerListener* resource defines a port and a TLS setting for a listener that accepts MQTT connections from clients.
104
+
This example shows how to create a new *BrokerListener* resource for a *Broker* resource named *my-broker*. The *BrokerListener* resource defines a two ports that accept MQTT connections from clients.
96
105
97
-
- The first *BrokerListener* resource, named *my-test-listener*, defines a listener on port 1883 with no TLS and authentication off. Clients can connect to the broker without encryption or authentication.
98
-
- The second *BrokerListener* resource, named *my-secure-listener*, defines a listener on port 8883 with TLS and authentication enabled. Only authenticated clients can connect to the broker with TLS encryption. The `tls` field is set to `automatic`, which means that the listener uses cert-manager to get and renew its server certificate.
106
+
- The first port listens on port 1883 with no TLS and authentication off. Clients can connect to the broker without encryption or authentication.
107
+
- The second port listens on port 8883 with TLS and authentication enabled. Only authenticated clients can connect to the broker with TLS encryption. TLS is set to `automatic`, which means that the listener uses cert-manager to get and renew its server certificate.
99
108
100
109
To create these *BrokerListener* resources, apply this YAML manifest to your Kubernetes cluster:
101
110
@@ -106,48 +115,23 @@ metadata:
106
115
name: my-test-listener
107
116
namespace: azure-iot-operations
108
117
spec:
109
-
authenticationEnabled: false
110
-
authorizationEnabled: false
111
-
brokerRef: broker
112
-
port: 1883
113
-
---
114
-
apiVersion: mq.iotoperations.azure.com/v1beta1
115
-
kind: BrokerListener
116
-
metadata:
117
-
name: my-secure-listener
118
-
namespace: azure-iot-operations
119
-
spec:
120
-
authenticationEnabled: true
121
-
authorizationEnabled: false
122
118
brokerRef: broker
123
-
port: 8883
124
-
tls:
125
-
automatic:
126
-
issuerRef:
127
-
name: e2e-cert-issuer
128
-
kind: Issuer
129
-
group: cert-manager.io
119
+
serviceType: loadBalancer
120
+
serviceName: my-new-listener
121
+
ports:
122
+
port: 1883
123
+
protocol: Mqtt
124
+
port: 18883
125
+
authenticationRef: authn
126
+
protocol: Mqtt
127
+
tls:
128
+
automatic:
129
+
issuerRef:
130
+
name: e2e-cert-issuer
131
+
kind: Issuer
132
+
group: cert-manager.io
130
133
```
131
134
132
-
## Service name and service type
133
-
134
-
If you have multiple BrokerListener resources with the same `serviceType` and `serviceName`, the resources share the same Kubernetes service. This means that the service exposes all the ports of all the listeners. For example, if you have two listeners with the same `serviceType` and `serviceName`, one on port 1883 and the other on port 8883, the service exposes both ports. Clients can connect to the broker on either port.
135
-
136
-
There are two important rules to follow when sharing service name:
137
-
138
-
1. Listeners with the same `serviceType` must share the same `serviceName`.
139
-
140
-
1. Listeners with different `serviceType` must have different `serviceName`.
141
-
142
-
Notably, the service for the default listener on port 8883 is `clusterIp` and named `aio-mq-dmqtt-frontend`. The following table summarizes what happens when you create a new listener on a different port:
143
-
144
-
| New listener `serviceType` | New listener `serviceName` | Result |
145
-
| --- | --- | --- |
146
-
| `clusterIp` | `aio-mq-dmqtt-frontend` | The new listener creates successfully, and the service exposes both ports. |
147
-
| `clusterIp` | `my-service` | The new listener fails to create because the service type conflicts with the default listener. |
148
-
| `loadBalancer` or `nodePort` | `aio-mq-dmqtt-frontend` | The new listener fails to create because the service name conflicts with the default listener. |
149
-
| `loadBalancer` or `nodePort` | `my-service` | The new listener creates successfully, and a new service is created. |
@@ -99,7 +102,7 @@ If you don't have a CA certificate, cert-manager can generate a root CA certific
99
102
kubectl apply -f ca.yaml
100
103
```
101
104
102
-
Cert-manager creates a CA certificate using its defaults. The properties of this certificate can be changed by modifying the Certificate spec. See [cert-manager documentation](https://cert-manager.io/docs/reference/api-docs/#cert-manager.io/v1.CertificateSpec) for a list of valid options.
105
+
Cert-manager creates a CA certificate using its defaults. The properties of this certificate can be changed by modifying the Certificate specification. See [cert-manager documentation](https://cert-manager.io/docs/reference/api-docs/#cert-manager.io/v1.CertificateSpec) for a list of valid options.
103
106
104
107
### Distribute the root certificate
105
108
@@ -179,9 +182,7 @@ metadata:
179
182
namespace: azure-iot-operations
180
183
spec:
181
184
brokerRef: broker
182
-
authenticationEnabled: false # If set to true, a BrokerAuthentication resource must be configured
183
-
authorizationEnabled: false
184
-
serviceType: loadBalancer # Optional; defaults to 'clusterIP'
185
+
serviceType: loadBalancer
185
186
serviceName: my-new-tls-listener # Avoid conflicts with default service name 'aio-mq-dmqtt-frontend'
186
187
port: 8884 # Avoid conflicts with default port 8883
187
188
tls:
@@ -268,74 +269,80 @@ To help you get started, Azure IoT Operations is deployed with a default "quicks
268
269
269
270
* The public portion of the root CA certificate is stored in a ConfigMap called `aio-ca-trust-bundle-test-only`. You can retrieve the CA certificate from the ConfigMap and inspect it with kubectl and openssl.
* By default, there's already a CA issuer configured in the `azure-iot-operations` namespace called `aio-ca-issuer`. It's used as the common CA issuer for all TLS server certificates for IoT Operations. MQTT broker uses an issuer created from the same CA certificate to issue TLS server certificates for the default TLS listener on port 8883. You can inspect the issuer with the following command:
310
314
311
-
```console
312
-
$ kubectl get issuer aio-ca-issuer -n azure-iot-operations -o yaml
0 commit comments